From 20988afec925f921b562f42628516471f1ad992f Mon Sep 17 00:00:00 2001 From: "raveit65 (via Travis CI)" Date: Sat, 7 Dec 2024 00:13:31 +0000 Subject: Deploy mate-desktop/mate-panel to github.com/mate-desktop/mate-panel.git:gh-pages --- .../index.html | 191 + .../report-02d390.html | 1591 +++++ .../report-0e0727.html | 6265 ++++++++++++++++++++ .../report-0e9e9c.html | 868 +++ .../report-0f6d0c.html | 2409 ++++++++ .../report-1eba91.html | 1074 ++++ .../report-2de153.html | 1980 +++++++ .../report-313d65.html | 1077 ++++ .../report-3bfab8.html | 868 +++ .../report-4646d6.html | 1906 ++++++ .../report-51a1d8.html | 3246 ++++++++++ .../report-56cac4.html | 1977 ++++++ .../report-713bcf.html | 912 +++ .../report-7c33d7.html | 2409 ++++++++ .../report-890f6c.html | 6243 +++++++++++++++++++ .../report-891289.html | 1524 +++++ .../report-92ce7b.html | 3246 ++++++++++ .../report-a82458.html | 967 +++ .../report-b083bc.html | 3246 ++++++++++ .../report-b8f564.html | 2089 +++++++ .../report-cf3974.html | 2089 +++++++ .../report-cfdb46.html | 2588 ++++++++ .../report-d08495.html | 3246 ++++++++++ .../report-d1a39f.html | 1375 +++++ .../report-d88d55.html | 3246 ++++++++++ .../report-db7134.html | 1031 ++++ .../report-dcd45f.html | 6243 +++++++++++++++++++ .../report-e04d58.html | 6243 +++++++++++++++++++ .../report-f493c1.html | 3246 ++++++++++ .../report-fb6164.html | 1493 +++++ .../report-fd4917.html | 6243 +++++++++++++++++++ .../report-fec02c.html | 1509 +++++ .../scanview.css | 62 + .../sorttable.js | 492 ++ 34 files changed, 83194 insertions(+) create mode 100644 2024-06-18-172109-13286-1@e182420b844f_master/index.html create mode 100644 2024-06-18-172109-13286-1@e182420b844f_master/report-02d390.html create mode 100644 2024-06-18-172109-13286-1@e182420b844f_master/report-0e0727.html create mode 100644 2024-06-18-172109-13286-1@e182420b844f_master/report-0e9e9c.html create mode 100644 2024-06-18-172109-13286-1@e182420b844f_master/report-0f6d0c.html create mode 100644 2024-06-18-172109-13286-1@e182420b844f_master/report-1eba91.html create mode 100644 2024-06-18-172109-13286-1@e182420b844f_master/report-2de153.html create mode 100644 2024-06-18-172109-13286-1@e182420b844f_master/report-313d65.html create mode 100644 2024-06-18-172109-13286-1@e182420b844f_master/report-3bfab8.html create mode 100644 2024-06-18-172109-13286-1@e182420b844f_master/report-4646d6.html create mode 100644 2024-06-18-172109-13286-1@e182420b844f_master/report-51a1d8.html create mode 100644 2024-06-18-172109-13286-1@e182420b844f_master/report-56cac4.html create mode 100644 2024-06-18-172109-13286-1@e182420b844f_master/report-713bcf.html create mode 100644 2024-06-18-172109-13286-1@e182420b844f_master/report-7c33d7.html create mode 100644 2024-06-18-172109-13286-1@e182420b844f_master/report-890f6c.html create mode 100644 2024-06-18-172109-13286-1@e182420b844f_master/report-891289.html create mode 100644 2024-06-18-172109-13286-1@e182420b844f_master/report-92ce7b.html create mode 100644 2024-06-18-172109-13286-1@e182420b844f_master/report-a82458.html create mode 100644 2024-06-18-172109-13286-1@e182420b844f_master/report-b083bc.html create mode 100644 2024-06-18-172109-13286-1@e182420b844f_master/report-b8f564.html create mode 100644 2024-06-18-172109-13286-1@e182420b844f_master/report-cf3974.html create mode 100644 2024-06-18-172109-13286-1@e182420b844f_master/report-cfdb46.html create mode 100644 2024-06-18-172109-13286-1@e182420b844f_master/report-d08495.html create mode 100644 2024-06-18-172109-13286-1@e182420b844f_master/report-d1a39f.html create mode 100644 2024-06-18-172109-13286-1@e182420b844f_master/report-d88d55.html create mode 100644 2024-06-18-172109-13286-1@e182420b844f_master/report-db7134.html create mode 100644 2024-06-18-172109-13286-1@e182420b844f_master/report-dcd45f.html create mode 100644 2024-06-18-172109-13286-1@e182420b844f_master/report-e04d58.html create mode 100644 2024-06-18-172109-13286-1@e182420b844f_master/report-f493c1.html create mode 100644 2024-06-18-172109-13286-1@e182420b844f_master/report-fb6164.html create mode 100644 2024-06-18-172109-13286-1@e182420b844f_master/report-fd4917.html create mode 100644 2024-06-18-172109-13286-1@e182420b844f_master/report-fec02c.html create mode 100644 2024-06-18-172109-13286-1@e182420b844f_master/scanview.css create mode 100644 2024-06-18-172109-13286-1@e182420b844f_master/sorttable.js (limited to '2024-06-18-172109-13286-1@e182420b844f_master') diff --git a/2024-06-18-172109-13286-1@e182420b844f_master/index.html b/2024-06-18-172109-13286-1@e182420b844f_master/index.html new file mode 100644 index 00000000..e1e33419 --- /dev/null +++ b/2024-06-18-172109-13286-1@e182420b844f_master/index.html @@ -0,0 +1,191 @@ + + +rootdir - scan-build results + + + + + + +

rootdir - scan-build results

+ + + + + + + +
User:root@3115f818dd9e
Working Directory:/rootdir
Command Line:make -j 2
Clang Version:clang version 18.1.6 (Fedora 18.1.6-3.fc40) +
Date:Tue Jun 18 17:21:09 2024
+

Bug Summary

+ + + + + + + + + + + +
Bug TypeQuantityDisplay?
All Bugs31
Logic error
Assigned value is garbage or undefined1
Cast from non-struct type to struct type14
Dereference of null pointer2
Result of operation is garbage or undefined3
Unused code
Dead assignment4
Dead initialization1
Unreachable code6
+

Reports

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Bug GroupBug Type ▾FileFunction/MethodLinePath Length
Logic errorAssigned value is garbage or undefinedmate-panel/panel-toplevel.cpanel_toplevel_update_size24117View Report
Logic errorCast from non-struct type to struct typelibmate-panel-applet/mate-panel-applet-gsettings.cregister_dconf_editor_relocatable_schema991View Report
Logic errorCast from non-struct type to struct typemate-panel/panel-profile.cremove_from_dict8471View Report
Logic errorCast from non-struct type to struct typelibmate-panel-applet/mate-panel-applet-gsettings.cadd_to_dict441View Report
Logic errorCast from non-struct type to struct typelibmate-panel-applet/mate-panel-applet.cmate_panel_applet_set_flags2281View Report
Logic errorCast from non-struct type to struct typemate-panel/panel-profile.cunregister_dconf_editor_relocatable_schema8711View Report
Logic errorCast from non-struct type to struct typelibmate-panel-applet/mate-panel-applet.cmate_panel_applet_get_property17041View Report
Logic errorCast from non-struct type to struct typelibmate-panel-applet/mate-panel-applet.cmate_panel_applet_setup18251View Report
Logic errorCast from non-struct type to struct typemate-panel/mate-submodules/libegg/eggsmclient-xsmp.carray_prop11991View Report
Logic errorCast from non-struct type to struct typemate-panel/mate-submodules/libegg/eggsmclient-xsmp.cptrarray_prop12321View Report
Logic errorCast from non-struct type to struct typelibmate-panel-applet/mate-panel-applet.cmate_panel_applet_set_size_hints3291View Report
Logic errorCast from non-struct type to struct typemate-panel/panel-multimonitor.cpanel_multimonitor_get_randr_monitors2111View Report
Logic errorCast from non-struct type to struct typelibmate-panel-applet/mate-panel-applet.cmate_panel_applet_set_size_hints3361View Report
Logic errorCast from non-struct type to struct typemate-panel/panel-context-menu.cpanel_context_menu_create3051View Report
Logic errorCast from non-struct type to struct typelibmate-panel-applet/mate-panel-applet.cget_property_cb22461View Report
Unused codeDead assignmentmate-panel/panel-toplevel.cpanel_toplevel_update_attach_orientation25541View Report
Unused codeDead assignmentmate-panel/panel-toplevel.cpanel_toplevel_update_expanded_position20621View Report
Unused codeDead assignmentmate-panel/panel-toplevel.cpanel_toplevel_resize_to_pointer5911View Report
Unused codeDead assignmentmate-panel/panel-toplevel.cpanel_toplevel_update_expanded_position20631View Report
Unused codeDead initializationapplets/notification_area/status-notifier/sn-host-v0-gen.csn_host_v0_gen_skeleton_dbus_interface_get_properties8051View Report
Logic errorDereference of null pointermate-panel/libpanel-util/panel-launch.c_panel_launch_handle_error7241View Report
Logic errorDereference of null pointerlibmate-panel-applet/tmp-introspectems2xjmx/MatePanelApplet-4.0.cmain79912View Report
Logic errorResult of operation is garbage or undefinedapplets/wncklet/window-list.cpreview_window_reposition42424View Report
Logic errorResult of operation is garbage or undefinedapplets/wncklet/window-list.cpreview_window_reposition41822View Report
Logic errorResult of operation is garbage or undefinedmate-panel/libpanel-util/panel-glib.cpanel_g_utf8_strstrcase14726View Report
Unused codeUnreachable codemate-panel/panel-test-applets.cmain3601View Report
Unused codeUnreachable codemate-panel/launcher.clauncher_load_from_gsettings9511View Report
Unused codeUnreachable codemate-panel/libpanel-util/panel-launch.cpanel_launch_desktop_file_with_fallback2851View Report
Unused codeUnreachable codeapplets/fish/fish.chandle_keypress15781View Report
Unused codeUnreachable codelibmate-panel-applet/tmp-introspectems2xjmx/MatePanelApplet-4.0.cvalue_to_string2391View Report
Unused codeUnreachable codemate-panel/panel-background.cpanel_background_make_string7821View Report
+ + diff --git a/2024-06-18-172109-13286-1@e182420b844f_master/report-02d390.html b/2024-06-18-172109-13286-1@e182420b844f_master/report-02d390.html new file mode 100644 index 00000000..f4e6a940 --- /dev/null +++ b/2024-06-18-172109-13286-1@e182420b844f_master/report-02d390.html @@ -0,0 +1,1591 @@ + + + +sn-host-v0-gen.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:applets/notification_area/status-notifier/sn-host-v0-gen.c
Warning:line 805, column 24
Value stored to 'skeleton' during its initialization is never read
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name sn-host-v0-gen.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/applets/notification_area/status-notifier -fcoverage-compilation-dir=/rootdir/applets/notification_area/status-notifier -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I ../../.. -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/startup-notification-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/gio-unix-2.0 -I /usr/include/dconf -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/gio-unix-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I . -I ./.. -D MATELOCALEDIR="/usr/local/share/locale" -D G_LOG_DOMAIN="notification-area-applet" -D PIC -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-18-172109-13286-1 -x c sn-host-v0-gen.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * This file is generated by gdbus-codegen, do not modify it.
3 *
4 * The license of this code is the same as for the D-Bus interface description
5 * it was derived from. Note that it links to GLib, so must comply with the
6 * LGPL linking clauses.
7 */
8
9#ifdef HAVE_CONFIG_H1
10# include "config.h"
11#endif
12
13#include "sn-host-v0-gen.h"
14
15#include <string.h>
16#ifdef G_OS_UNIX
17# include <gio/gunixfdlist.h>
18#endif
19
20#ifdef G_ENABLE_DEBUG
21#define g_marshal_value_peek_boolean(v)(v)->data[0].v_int g_value_get_boolean (v)
22#define g_marshal_value_peek_char(v)(v)->data[0].v_int g_value_get_schar (v)
23#define g_marshal_value_peek_uchar(v)(v)->data[0].v_uint g_value_get_uchar (v)
24#define g_marshal_value_peek_int(v)(v)->data[0].v_int g_value_get_int (v)
25#define g_marshal_value_peek_uint(v)(v)->data[0].v_uint g_value_get_uint (v)
26#define g_marshal_value_peek_long(v)(v)->data[0].v_long g_value_get_long (v)
27#define g_marshal_value_peek_ulong(v)(v)->data[0].v_ulong g_value_get_ulong (v)
28#define g_marshal_value_peek_int64(v)(v)->data[0].v_int64 g_value_get_int64 (v)
29#define g_marshal_value_peek_uint64(v)(v)->data[0].v_uint64 g_value_get_uint64 (v)
30#define g_marshal_value_peek_enum(v)(v)->data[0].v_long g_value_get_enum (v)
31#define g_marshal_value_peek_flags(v)(v)->data[0].v_ulong g_value_get_flags (v)
32#define g_marshal_value_peek_float(v)(v)->data[0].v_float g_value_get_float (v)
33#define g_marshal_value_peek_double(v)(v)->data[0].v_double g_value_get_double (v)
34#define g_marshal_value_peek_string(v)(v)->data[0].v_pointer (char*) g_value_get_string (v)
35#define g_marshal_value_peek_param(v)(v)->data[0].v_pointer g_value_get_param (v)
36#define g_marshal_value_peek_boxed(v)(v)->data[0].v_pointer g_value_get_boxed (v)
37#define g_marshal_value_peek_pointer(v)(v)->data[0].v_pointer g_value_get_pointer (v)
38#define g_marshal_value_peek_object(v)(v)->data[0].v_pointer g_value_get_object (v)
39#define g_marshal_value_peek_variant(v)(v)->data[0].v_pointer g_value_get_variant (v)
40#else /* !G_ENABLE_DEBUG */
41/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
42 * Do not access GValues directly in your code. Instead, use the
43 * g_value_get_*() functions
44 */
45#define g_marshal_value_peek_boolean(v)(v)->data[0].v_int (v)->data[0].v_int
46#define g_marshal_value_peek_char(v)(v)->data[0].v_int (v)->data[0].v_int
47#define g_marshal_value_peek_uchar(v)(v)->data[0].v_uint (v)->data[0].v_uint
48#define g_marshal_value_peek_int(v)(v)->data[0].v_int (v)->data[0].v_int
49#define g_marshal_value_peek_uint(v)(v)->data[0].v_uint (v)->data[0].v_uint
50#define g_marshal_value_peek_long(v)(v)->data[0].v_long (v)->data[0].v_long
51#define g_marshal_value_peek_ulong(v)(v)->data[0].v_ulong (v)->data[0].v_ulong
52#define g_marshal_value_peek_int64(v)(v)->data[0].v_int64 (v)->data[0].v_int64
53#define g_marshal_value_peek_uint64(v)(v)->data[0].v_uint64 (v)->data[0].v_uint64
54#define g_marshal_value_peek_enum(v)(v)->data[0].v_long (v)->data[0].v_long
55#define g_marshal_value_peek_flags(v)(v)->data[0].v_ulong (v)->data[0].v_ulong
56#define g_marshal_value_peek_float(v)(v)->data[0].v_float (v)->data[0].v_float
57#define g_marshal_value_peek_double(v)(v)->data[0].v_double (v)->data[0].v_double
58#define g_marshal_value_peek_string(v)(v)->data[0].v_pointer (v)->data[0].v_pointer
59#define g_marshal_value_peek_param(v)(v)->data[0].v_pointer (v)->data[0].v_pointer
60#define g_marshal_value_peek_boxed(v)(v)->data[0].v_pointer (v)->data[0].v_pointer
61#define g_marshal_value_peek_pointer(v)(v)->data[0].v_pointer (v)->data[0].v_pointer
62#define g_marshal_value_peek_object(v)(v)->data[0].v_pointer (v)->data[0].v_pointer
63#define g_marshal_value_peek_variant(v)(v)->data[0].v_pointer (v)->data[0].v_pointer
64#endif /* !G_ENABLE_DEBUG */
65
66typedef struct
67{
68 GDBusArgInfo parent_struct;
69 gboolean use_gvariant;
70} _ExtendedGDBusArgInfo;
71
72typedef struct
73{
74 GDBusMethodInfo parent_struct;
75 const gchar *signal_name;
76 gboolean pass_fdlist;
77} _ExtendedGDBusMethodInfo;
78
79typedef struct
80{
81 GDBusSignalInfo parent_struct;
82 const gchar *signal_name;
83} _ExtendedGDBusSignalInfo;
84
85typedef struct
86{
87 GDBusPropertyInfo parent_struct;
88 const gchar *hyphen_name;
89 guint use_gvariant : 1;
90 guint emits_changed_signal : 1;
91} _ExtendedGDBusPropertyInfo;
92
93typedef struct
94{
95 GDBusInterfaceInfo parent_struct;
96 const gchar *hyphen_name;
97} _ExtendedGDBusInterfaceInfo;
98
99typedef struct
100{
101 const _ExtendedGDBusPropertyInfo *info;
102 guint prop_id;
103 GValue orig_value; /* the value before the change */
104} ChangedProperty;
105
106static void
107_changed_property_free (ChangedProperty *data)
108{
109 g_value_unset (&data->orig_value);
110 g_free (data);
111}
112
113static gboolean
114_g_strv_equal0 (gchar **a, gchar **b)
115{
116 gboolean ret = FALSE(0);
117 guint n;
118 if (a == NULL((void*)0) && b == NULL((void*)0))
119 {
120 ret = TRUE(!(0));
121 goto out;
122 }
123 if (a == NULL((void*)0) || b == NULL((void*)0))
124 goto out;
125 if (g_strv_length (a) != g_strv_length (b))
126 goto out;
127 for (n = 0; a[n] != NULL((void*)0); n++)
128 if (g_strcmp0 (a[n], b[n]) != 0)
129 goto out;
130 ret = TRUE(!(0));
131out:
132 return ret;
133}
134
135static gboolean
136_g_variant_equal0 (GVariant *a, GVariant *b)
137{
138 gboolean ret = FALSE(0);
139 if (a == NULL((void*)0) && b == NULL((void*)0))
140 {
141 ret = TRUE(!(0));
142 goto out;
143 }
144 if (a == NULL((void*)0) || b == NULL((void*)0))
145 goto out;
146 ret = g_variant_equal (a, b);
147out:
148 return ret;
149}
150
151G_GNUC_UNUSED__attribute__ ((__unused__)) static gboolean
152_g_value_equal (const GValue *a, const GValue *b)
153{
154 gboolean ret = FALSE(0);
155 g_assert (G_VALUE_TYPE (a) == G_VALUE_TYPE (b))do { if ((((GValue*) (a))->g_type) == (((GValue*) (b))->
g_type)) ; else g_assertion_message_expr ("notification-area-applet"
, "sn-host-v0-gen.c", 155, ((const char*) (__func__)), "G_VALUE_TYPE (a) == G_VALUE_TYPE (b)"
); } while (0)
;
156 switch (G_VALUE_TYPE (a)(((GValue*) (a))->g_type))
157 {
158 case G_TYPE_BOOLEAN((GType) ((5) << (2))):
159 ret = (g_value_get_boolean (a) == g_value_get_boolean (b));
160 break;
161 case G_TYPE_UCHAR((GType) ((4) << (2))):
162 ret = (g_value_get_uchar (a) == g_value_get_uchar (b));
163 break;
164 case G_TYPE_INT((GType) ((6) << (2))):
165 ret = (g_value_get_int (a) == g_value_get_int (b));
166 break;
167 case G_TYPE_UINT((GType) ((7) << (2))):
168 ret = (g_value_get_uint (a) == g_value_get_uint (b));
169 break;
170 case G_TYPE_INT64((GType) ((10) << (2))):
171 ret = (g_value_get_int64 (a) == g_value_get_int64 (b));
172 break;
173 case G_TYPE_UINT64((GType) ((11) << (2))):
174 ret = (g_value_get_uint64 (a) == g_value_get_uint64 (b));
175 break;
176 case G_TYPE_DOUBLE((GType) ((15) << (2))):
177 {
178 /* Avoid -Wfloat-equal warnings by doing a direct bit compare */
179 gdouble da = g_value_get_double (a);
180 gdouble db = g_value_get_double (b);
181 ret = memcmp (&da, &db, sizeof (gdouble)) == 0;
182 }
183 break;
184 case G_TYPE_STRING((GType) ((16) << (2))):
185 ret = (g_strcmp0 (g_value_get_string (a), g_value_get_string (b)) == 0);
186 break;
187 case G_TYPE_VARIANT((GType) ((21) << (2))):
188 ret = _g_variant_equal0 (g_value_get_variant (a), g_value_get_variant (b));
189 break;
190 default:
191 if (G_VALUE_TYPE (a)(((GValue*) (a))->g_type) == G_TYPE_STRV(g_strv_get_type ()))
192 ret = _g_strv_equal0 (g_value_get_boxed (a), g_value_get_boxed (b));
193 else
194 g_critical ("_g_value_equal() does not handle type %s", g_type_name (G_VALUE_TYPE (a)(((GValue*) (a))->g_type)));
195 break;
196 }
197 return ret;
198}
199
200/* ------------------------------------------------------------------------
201 * Code for interface org.kde.StatusNotifierHost
202 * ------------------------------------------------------------------------
203 */
204
205/**
206 * SECTION:SnHostV0Gen
207 * @title: SnHostV0Gen
208 * @short_description: Generated C code for the org.kde.StatusNotifierHost D-Bus interface
209 *
210 * This section contains code for working with the <link linkend="gdbus-interface-org-kde-StatusNotifierHost.top_of_page">org.kde.StatusNotifierHost</link> D-Bus interface in C.
211 */
212
213/* ---- Introspection data for org.kde.StatusNotifierHost ---- */
214
215static const _ExtendedGDBusInterfaceInfo _sn_host_v0_gen_interface_info =
216{
217 {
218 -1,
219 (gchar *) "org.kde.StatusNotifierHost",
220 NULL((void*)0),
221 NULL((void*)0),
222 NULL((void*)0),
223 NULL((void*)0)
224 },
225 "host-v0-gen",
226};
227
228
229/**
230 * sn_host_v0_gen_interface_info:
231 *
232 * Gets a machine-readable description of the <link linkend="gdbus-interface-org-kde-StatusNotifierHost.top_of_page">org.kde.StatusNotifierHost</link> D-Bus interface.
233 *
234 * Returns: (transfer none): A #GDBusInterfaceInfo. Do not free.
235 */
236GDBusInterfaceInfo *
237sn_host_v0_gen_interface_info (void)
238{
239 return (GDBusInterfaceInfo *) &_sn_host_v0_gen_interface_info.parent_struct;
240}
241
242/**
243 * sn_host_v0_gen_override_properties:
244 * @klass: The class structure for a #GObject derived class.
245 * @property_id_begin: The property id to assign to the first overridden property.
246 *
247 * Overrides all #GObject properties in the #SnHostV0Gen interface for a concrete class.
248 * The properties are overridden in the order they are defined.
249 *
250 * Returns: The last property id.
251 */
252guint
253sn_host_v0_gen_override_properties (GObjectClass *klass G_GNUC_UNUSED__attribute__ ((__unused__)), guint property_id_begin)
254{
255 return property_id_begin - 1;
256}
257
258
259
260/**
261 * SnHostV0Gen:
262 *
263 * Abstract interface type for the D-Bus interface <link linkend="gdbus-interface-org-kde-StatusNotifierHost.top_of_page">org.kde.StatusNotifierHost</link>.
264 */
265
266/**
267 * SnHostV0GenIface:
268 * @parent_iface: The parent interface.
269 *
270 * Virtual table for the D-Bus interface <link linkend="gdbus-interface-org-kde-StatusNotifierHost.top_of_page">org.kde.StatusNotifierHost</link>.
271 */
272
273typedef SnHostV0GenIface SnHostV0GenInterface;
274G_DEFINE_INTERFACE (SnHostV0Gen, sn_host_v0_gen, G_TYPE_OBJECT)static void sn_host_v0_gen_default_init (SnHostV0GenInterface
*klass); GType sn_host_v0_gen_get_type (void) { static GType
static_g_define_type_id = 0; if ((__extension__ ({ _Static_assert
(sizeof *(&static_g_define_type_id) == sizeof (gpointer)
, "Expression evaluates to false"); (void) (0 ? (gpointer) * (
&static_g_define_type_id) : ((void*)0)); (!(__extension__
({ _Static_assert (sizeof *(&static_g_define_type_id) ==
sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter_pointer (
&static_g_define_type_id)); })) ) { GType g_define_type_id
= g_type_register_static_simple (((GType) ((2) << (2))
), g_intern_static_string ("SnHostV0Gen"), sizeof (SnHostV0GenInterface
), (GClassInitFunc)(void (*)(void)) sn_host_v0_gen_default_init
, 0, (GInstanceInitFunc)((void*)0), (GTypeFlags) 0); if (((GType
) ((20) << (2))) != ((GType) ((0) << (2)))) g_type_interface_add_prerequisite
(g_define_type_id, ((GType) ((20) << (2)))); { {;;} } (
__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); 0 ?
(void) (*(&static_g_define_type_id) = (g_define_type_id)
) : (void) 0; g_once_init_leave_pointer ((&static_g_define_type_id
), (gpointer) (guintptr) (g_define_type_id)); })) ; } return static_g_define_type_id
; }
275
276static void
277sn_host_v0_gen_default_init (SnHostV0GenIface *iface G_GNUC_UNUSED__attribute__ ((__unused__)))
278{
279}
280
281/* ------------------------------------------------------------------------ */
282
283/**
284 * SnHostV0GenProxy:
285 *
286 * The #SnHostV0GenProxy structure contains only private data and should only be accessed using the provided API.
287 */
288
289/**
290 * SnHostV0GenProxyClass:
291 * @parent_class: The parent class.
292 *
293 * Class structure for #SnHostV0GenProxy.
294 */
295
296struct _SnHostV0GenProxyPrivate
297{
298 GData *qdata;
299};
300
301static void sn_host_v0_gen_proxy_iface_init (SnHostV0GenIface *iface);
302
303#if GLIB_VERSION_MAX_ALLOWED((((2) << 16 | (80) << 8))) >= GLIB_VERSION_2_38(((2) << 16 | (38) << 8))
304G_DEFINE_TYPE_WITH_CODE (SnHostV0GenProxy, sn_host_v0_gen_proxy, G_TYPE_DBUS_PROXY,static void sn_host_v0_gen_proxy_init (SnHostV0GenProxy *self
); static void sn_host_v0_gen_proxy_class_init (SnHostV0GenProxyClass
*klass); static GType sn_host_v0_gen_proxy_get_type_once (void
); static gpointer sn_host_v0_gen_proxy_parent_class = ((void
*)0); static gint SnHostV0GenProxy_private_offset; static void
sn_host_v0_gen_proxy_class_intern_init (gpointer klass) { sn_host_v0_gen_proxy_parent_class
= g_type_class_peek_parent (klass); if (SnHostV0GenProxy_private_offset
!= 0) g_type_class_adjust_private_offset (klass, &SnHostV0GenProxy_private_offset
); sn_host_v0_gen_proxy_class_init ((SnHostV0GenProxyClass*) klass
); } __attribute__ ((__unused__)) static inline gpointer sn_host_v0_gen_proxy_get_instance_private
(SnHostV0GenProxy *self) { return (((gpointer) ((guint8*) (self
) + (glong) (SnHostV0GenProxy_private_offset)))); } GType sn_host_v0_gen_proxy_get_type
(void) { static GType static_g_define_type_id = 0; if ((__extension__
({ _Static_assert (sizeof *(&static_g_define_type_id) ==
sizeof (gpointer), "Expression evaluates to false"); (void) (
0 ? (gpointer) * (&static_g_define_type_id) : ((void*)0))
; (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter_pointer (
&static_g_define_type_id)); })) ) { GType g_define_type_id
= sn_host_v0_gen_proxy_get_type_once (); (__extension__ ({ _Static_assert
(sizeof *(&static_g_define_type_id) == sizeof (gpointer)
, "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id
) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer
((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id
)); })) ; } return static_g_define_type_id; } __attribute__ (
(__noinline__)) static GType sn_host_v0_gen_proxy_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
((g_dbus_proxy_get_type ()), g_intern_static_string ("SnHostV0GenProxy"
), sizeof (SnHostV0GenProxyClass), (GClassInitFunc)(void (*)(
void)) sn_host_v0_gen_proxy_class_intern_init, sizeof (SnHostV0GenProxy
), (GInstanceInitFunc)(void (*)(void)) sn_host_v0_gen_proxy_init
, (GTypeFlags) 0); { {{ SnHostV0GenProxy_private_offset = g_type_add_instance_private
(g_define_type_id, sizeof (SnHostV0GenProxyPrivate)); } { const
GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc
)(void (*)(void)) sn_host_v0_gen_proxy_iface_init, ((void*)0)
, ((void*)0) }; g_type_add_interface_static (g_define_type_id
, (sn_host_v0_gen_get_type ()), &g_implement_interface_info
); };} } return g_define_type_id; }
305 G_ADD_PRIVATE (SnHostV0GenProxy)static void sn_host_v0_gen_proxy_init (SnHostV0GenProxy *self
); static void sn_host_v0_gen_proxy_class_init (SnHostV0GenProxyClass
*klass); static GType sn_host_v0_gen_proxy_get_type_once (void
); static gpointer sn_host_v0_gen_proxy_parent_class = ((void
*)0); static gint SnHostV0GenProxy_private_offset; static void
sn_host_v0_gen_proxy_class_intern_init (gpointer klass) { sn_host_v0_gen_proxy_parent_class
= g_type_class_peek_parent (klass); if (SnHostV0GenProxy_private_offset
!= 0) g_type_class_adjust_private_offset (klass, &SnHostV0GenProxy_private_offset
); sn_host_v0_gen_proxy_class_init ((SnHostV0GenProxyClass*) klass
); } __attribute__ ((__unused__)) static inline gpointer sn_host_v0_gen_proxy_get_instance_private
(SnHostV0GenProxy *self) { return (((gpointer) ((guint8*) (self
) + (glong) (SnHostV0GenProxy_private_offset)))); } GType sn_host_v0_gen_proxy_get_type
(void) { static GType static_g_define_type_id = 0; if ((__extension__
({ _Static_assert (sizeof *(&static_g_define_type_id) ==
sizeof (gpointer), "Expression evaluates to false"); (void) (
0 ? (gpointer) * (&static_g_define_type_id) : ((void*)0))
; (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter_pointer (
&static_g_define_type_id)); })) ) { GType g_define_type_id
= sn_host_v0_gen_proxy_get_type_once (); (__extension__ ({ _Static_assert
(sizeof *(&static_g_define_type_id) == sizeof (gpointer)
, "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id
) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer
((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id
)); })) ; } return static_g_define_type_id; } __attribute__ (
(__noinline__)) static GType sn_host_v0_gen_proxy_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
((g_dbus_proxy_get_type ()), g_intern_static_string ("SnHostV0GenProxy"
), sizeof (SnHostV0GenProxyClass), (GClassInitFunc)(void (*)(
void)) sn_host_v0_gen_proxy_class_intern_init, sizeof (SnHostV0GenProxy
), (GInstanceInitFunc)(void (*)(void)) sn_host_v0_gen_proxy_init
, (GTypeFlags) 0); { {{ SnHostV0GenProxy_private_offset = g_type_add_instance_private
(g_define_type_id, sizeof (SnHostV0GenProxyPrivate)); } { const
GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc
)(void (*)(void)) sn_host_v0_gen_proxy_iface_init, ((void*)0)
, ((void*)0) }; g_type_add_interface_static (g_define_type_id
, (sn_host_v0_gen_get_type ()), &g_implement_interface_info
); };} } return g_define_type_id; }
306 G_IMPLEMENT_INTERFACE (SN_TYPE_HOST_V0_GEN, sn_host_v0_gen_proxy_iface_init))static void sn_host_v0_gen_proxy_init (SnHostV0GenProxy *self
); static void sn_host_v0_gen_proxy_class_init (SnHostV0GenProxyClass
*klass); static GType sn_host_v0_gen_proxy_get_type_once (void
); static gpointer sn_host_v0_gen_proxy_parent_class = ((void
*)0); static gint SnHostV0GenProxy_private_offset; static void
sn_host_v0_gen_proxy_class_intern_init (gpointer klass) { sn_host_v0_gen_proxy_parent_class
= g_type_class_peek_parent (klass); if (SnHostV0GenProxy_private_offset
!= 0) g_type_class_adjust_private_offset (klass, &SnHostV0GenProxy_private_offset
); sn_host_v0_gen_proxy_class_init ((SnHostV0GenProxyClass*) klass
); } __attribute__ ((__unused__)) static inline gpointer sn_host_v0_gen_proxy_get_instance_private
(SnHostV0GenProxy *self) { return (((gpointer) ((guint8*) (self
) + (glong) (SnHostV0GenProxy_private_offset)))); } GType sn_host_v0_gen_proxy_get_type
(void) { static GType static_g_define_type_id = 0; if ((__extension__
({ _Static_assert (sizeof *(&static_g_define_type_id) ==
sizeof (gpointer), "Expression evaluates to false"); (void) (
0 ? (gpointer) * (&static_g_define_type_id) : ((void*)0))
; (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter_pointer (
&static_g_define_type_id)); })) ) { GType g_define_type_id
= sn_host_v0_gen_proxy_get_type_once (); (__extension__ ({ _Static_assert
(sizeof *(&static_g_define_type_id) == sizeof (gpointer)
, "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id
) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer
((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id
)); })) ; } return static_g_define_type_id; } __attribute__ (
(__noinline__)) static GType sn_host_v0_gen_proxy_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
((g_dbus_proxy_get_type ()), g_intern_static_string ("SnHostV0GenProxy"
), sizeof (SnHostV0GenProxyClass), (GClassInitFunc)(void (*)(
void)) sn_host_v0_gen_proxy_class_intern_init, sizeof (SnHostV0GenProxy
), (GInstanceInitFunc)(void (*)(void)) sn_host_v0_gen_proxy_init
, (GTypeFlags) 0); { {{ SnHostV0GenProxy_private_offset = g_type_add_instance_private
(g_define_type_id, sizeof (SnHostV0GenProxyPrivate)); } { const
GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc
)(void (*)(void)) sn_host_v0_gen_proxy_iface_init, ((void*)0)
, ((void*)0) }; g_type_add_interface_static (g_define_type_id
, (sn_host_v0_gen_get_type ()), &g_implement_interface_info
); };} } return g_define_type_id; }
307
308#else
309G_DEFINE_TYPE_WITH_CODE (SnHostV0GenProxy, sn_host_v0_gen_proxy, G_TYPE_DBUS_PROXY,static void sn_host_v0_gen_proxy_init (SnHostV0GenProxy *self
); static void sn_host_v0_gen_proxy_class_init (SnHostV0GenProxyClass
*klass); static GType sn_host_v0_gen_proxy_get_type_once (void
); static gpointer sn_host_v0_gen_proxy_parent_class = ((void
*)0); static gint SnHostV0GenProxy_private_offset; static void
sn_host_v0_gen_proxy_class_intern_init (gpointer klass) { sn_host_v0_gen_proxy_parent_class
= g_type_class_peek_parent (klass); if (SnHostV0GenProxy_private_offset
!= 0) g_type_class_adjust_private_offset (klass, &SnHostV0GenProxy_private_offset
); sn_host_v0_gen_proxy_class_init ((SnHostV0GenProxyClass*) klass
); } __attribute__ ((__unused__)) static inline gpointer sn_host_v0_gen_proxy_get_instance_private
(SnHostV0GenProxy *self) { return (((gpointer) ((guint8*) (self
) + (glong) (SnHostV0GenProxy_private_offset)))); } GType sn_host_v0_gen_proxy_get_type
(void) { static GType static_g_define_type_id = 0; if ((__extension__
({ _Static_assert (sizeof *(&static_g_define_type_id) ==
sizeof (gpointer), "Expression evaluates to false"); (void) (
0 ? (gpointer) * (&static_g_define_type_id) : ((void*)0))
; (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter_pointer (
&static_g_define_type_id)); })) ) { GType g_define_type_id
= sn_host_v0_gen_proxy_get_type_once (); (__extension__ ({ _Static_assert
(sizeof *(&static_g_define_type_id) == sizeof (gpointer)
, "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id
) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer
((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id
)); })) ; } return static_g_define_type_id; } __attribute__ (
(__noinline__)) static GType sn_host_v0_gen_proxy_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
((g_dbus_proxy_get_type ()), g_intern_static_string ("SnHostV0GenProxy"
), sizeof (SnHostV0GenProxyClass), (GClassInitFunc)(void (*)(
void)) sn_host_v0_gen_proxy_class_intern_init, sizeof (SnHostV0GenProxy
), (GInstanceInitFunc)(void (*)(void)) sn_host_v0_gen_proxy_init
, (GTypeFlags) 0); { {{ const GInterfaceInfo g_implement_interface_info
= { (GInterfaceInitFunc)(void (*)(void)) sn_host_v0_gen_proxy_iface_init
, ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id
, (sn_host_v0_gen_get_type ()), &g_implement_interface_info
); };} } return g_define_type_id; }
310 G_IMPLEMENT_INTERFACE (SN_TYPE_HOST_V0_GEN, sn_host_v0_gen_proxy_iface_init))static void sn_host_v0_gen_proxy_init (SnHostV0GenProxy *self
); static void sn_host_v0_gen_proxy_class_init (SnHostV0GenProxyClass
*klass); static GType sn_host_v0_gen_proxy_get_type_once (void
); static gpointer sn_host_v0_gen_proxy_parent_class = ((void
*)0); static gint SnHostV0GenProxy_private_offset; static void
sn_host_v0_gen_proxy_class_intern_init (gpointer klass) { sn_host_v0_gen_proxy_parent_class
= g_type_class_peek_parent (klass); if (SnHostV0GenProxy_private_offset
!= 0) g_type_class_adjust_private_offset (klass, &SnHostV0GenProxy_private_offset
); sn_host_v0_gen_proxy_class_init ((SnHostV0GenProxyClass*) klass
); } __attribute__ ((__unused__)) static inline gpointer sn_host_v0_gen_proxy_get_instance_private
(SnHostV0GenProxy *self) { return (((gpointer) ((guint8*) (self
) + (glong) (SnHostV0GenProxy_private_offset)))); } GType sn_host_v0_gen_proxy_get_type
(void) { static GType static_g_define_type_id = 0; if ((__extension__
({ _Static_assert (sizeof *(&static_g_define_type_id) ==
sizeof (gpointer), "Expression evaluates to false"); (void) (
0 ? (gpointer) * (&static_g_define_type_id) : ((void*)0))
; (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter_pointer (
&static_g_define_type_id)); })) ) { GType g_define_type_id
= sn_host_v0_gen_proxy_get_type_once (); (__extension__ ({ _Static_assert
(sizeof *(&static_g_define_type_id) == sizeof (gpointer)
, "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id
) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer
((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id
)); })) ; } return static_g_define_type_id; } __attribute__ (
(__noinline__)) static GType sn_host_v0_gen_proxy_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
((g_dbus_proxy_get_type ()), g_intern_static_string ("SnHostV0GenProxy"
), sizeof (SnHostV0GenProxyClass), (GClassInitFunc)(void (*)(
void)) sn_host_v0_gen_proxy_class_intern_init, sizeof (SnHostV0GenProxy
), (GInstanceInitFunc)(void (*)(void)) sn_host_v0_gen_proxy_init
, (GTypeFlags) 0); { {{ const GInterfaceInfo g_implement_interface_info
= { (GInterfaceInitFunc)(void (*)(void)) sn_host_v0_gen_proxy_iface_init
, ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id
, (sn_host_v0_gen_get_type ()), &g_implement_interface_info
); };} } return g_define_type_id; }
311
312#endif
313static void
314sn_host_v0_gen_proxy_finalize (GObject *object)
315{
316 SnHostV0GenProxy *proxy = SN_HOST_V0_GEN_PROXY (object)((((SnHostV0GenProxy*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((object)), ((sn_host_v0_gen_proxy_get_type (
)))))))
;
317 g_datalist_clear (&proxy->priv->qdata);
318 G_OBJECT_CLASS (sn_host_v0_gen_proxy_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((sn_host_v0_gen_proxy_parent_class)), (((GType) ((20) <<
(2))))))))
->finalize (object);
319}
320
321static void
322sn_host_v0_gen_proxy_get_property (GObject *object G_GNUC_UNUSED__attribute__ ((__unused__)),
323 guint prop_id G_GNUC_UNUSED__attribute__ ((__unused__)),
324 GValue *value G_GNUC_UNUSED__attribute__ ((__unused__)),
325 GParamSpec *pspec G_GNUC_UNUSED__attribute__ ((__unused__)))
326{
327}
328
329static void
330sn_host_v0_gen_proxy_set_property (GObject *object G_GNUC_UNUSED__attribute__ ((__unused__)),
331 guint prop_id G_GNUC_UNUSED__attribute__ ((__unused__)),
332 const GValue *value G_GNUC_UNUSED__attribute__ ((__unused__)),
333 GParamSpec *pspec G_GNUC_UNUSED__attribute__ ((__unused__)))
334{
335}
336
337static void
338sn_host_v0_gen_proxy_g_signal (GDBusProxy *proxy,
339 const gchar *sender_name G_GNUC_UNUSED__attribute__ ((__unused__)),
340 const gchar *signal_name,
341 GVariant *parameters)
342{
343 _ExtendedGDBusSignalInfo *info;
344 GVariantIter iter;
345 GVariant *child;
346 GValue *paramv;
347 gsize num_params;
348 gsize n;
349 guint signal_id;
350 info = (_ExtendedGDBusSignalInfo *) g_dbus_interface_info_lookup_signal ((GDBusInterfaceInfo *) &_sn_host_v0_gen_interface_info.parent_struct, signal_name);
351 if (info == NULL((void*)0))
352 return;
353 num_params = g_variant_n_children (parameters);
354 paramv = g_new0 (GValue, num_params + 1)((GValue *) g_malloc0_n ((num_params + 1), sizeof (GValue)));
355 g_value_init (&paramv[0], SN_TYPE_HOST_V0_GEN(sn_host_v0_gen_get_type ()));
356 g_value_set_object (&paramv[0], proxy);
357 g_variant_iter_init (&iter, parameters);
358 n = 1;
359 while ((child = g_variant_iter_next_value (&iter)) != NULL((void*)0))
360 {
361 _ExtendedGDBusArgInfo *arg_info = (_ExtendedGDBusArgInfo *) info->parent_struct.args[n - 1];
362 if (arg_info->use_gvariant)
363 {
364 g_value_init (&paramv[n], G_TYPE_VARIANT((GType) ((21) << (2))));
365 g_value_set_variant (&paramv[n], child);
366 n++;
367 }
368 else
369 g_dbus_gvariant_to_gvalue (child, &paramv[n++]);
370 g_variant_unref (child);
371 }
372 signal_id = g_signal_lookup (info->signal_name, SN_TYPE_HOST_V0_GEN(sn_host_v0_gen_get_type ()));
373 g_signal_emitv (paramv, signal_id, 0, NULL((void*)0));
374 for (n = 0; n < num_params + 1; n++)
375 g_value_unset (&paramv[n]);
376 g_free (paramv);
377}
378
379static void
380sn_host_v0_gen_proxy_g_properties_changed (GDBusProxy *_proxy,
381 GVariant *changed_properties,
382 const gchar *const *invalidated_properties)
383{
384 SnHostV0GenProxy *proxy = SN_HOST_V0_GEN_PROXY (_proxy)((((SnHostV0GenProxy*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((_proxy)), ((sn_host_v0_gen_proxy_get_type (
)))))))
;
385 guint n;
386 const gchar *key;
387 GVariantIter *iter;
388 _ExtendedGDBusPropertyInfo *info;
389 g_variant_get (changed_properties, "a{sv}", &iter);
390 while (g_variant_iter_next (iter, "{&sv}", &key, NULL((void*)0)))
391 {
392 info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_sn_host_v0_gen_interface_info.parent_struct, key);
393 g_datalist_remove_data (&proxy->priv->qdata, key)g_datalist_id_set_data_full (((&proxy->priv->qdata)
), (g_quark_try_string (key)), (((void*)0)), ((void*)0))
;
394 if (info != NULL((void*)0))
395 g_object_notify (G_OBJECT (proxy)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((proxy)), (((GType) ((20) << (2))))))))
, info->hyphen_name);
396 }
397 g_variant_iter_free (iter);
398 for (n = 0; invalidated_properties[n] != NULL((void*)0); n++)
399 {
400 info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_sn_host_v0_gen_interface_info.parent_struct, invalidated_properties[n]);
401 g_datalist_remove_data (&proxy->priv->qdata, invalidated_properties[n])g_datalist_id_set_data_full (((&proxy->priv->qdata)
), (g_quark_try_string (invalidated_properties[n])), (((void*
)0)), ((void*)0))
;
402 if (info != NULL((void*)0))
403 g_object_notify (G_OBJECT (proxy)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((proxy)), (((GType) ((20) << (2))))))))
, info->hyphen_name);
404 }
405}
406
407static void
408sn_host_v0_gen_proxy_init (SnHostV0GenProxy *proxy)
409{
410#if GLIB_VERSION_MAX_ALLOWED((((2) << 16 | (80) << 8))) >= GLIB_VERSION_2_38(((2) << 16 | (38) << 8))
411 proxy->priv = sn_host_v0_gen_proxy_get_instance_private (proxy);
412#else
413 proxy->priv = G_TYPE_INSTANCE_GET_PRIVATE (proxy, SN_TYPE_HOST_V0_GEN_PROXY, SnHostV0GenProxyPrivate)((SnHostV0GenProxyPrivate*) g_type_instance_get_private ((GTypeInstance
*) (proxy), ((sn_host_v0_gen_proxy_get_type ())))) GCC warning
"Deprecated pre-processor symbol: replace with \"G_ADD_PRIVATE\""
+
;
414#endif
415
416 g_dbus_proxy_set_interface_info (G_DBUS_PROXY (proxy)((((GDBusProxy*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((proxy)), ((g_dbus_proxy_get_type ()))))))
, sn_host_v0_gen_interface_info ());
417}
418
419static void
420sn_host_v0_gen_proxy_class_init (SnHostV0GenProxyClass *klass)
421{
422 GObjectClass *gobject_class;
423 GDBusProxyClass *proxy_class;
424
425 gobject_class = G_OBJECT_CLASS (klass)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((klass)), (((GType) ((20) << (2))))))))
;
426 gobject_class->finalize = sn_host_v0_gen_proxy_finalize;
427 gobject_class->get_property = sn_host_v0_gen_proxy_get_property;
428 gobject_class->set_property = sn_host_v0_gen_proxy_set_property;
429
430 proxy_class = G_DBUS_PROXY_CLASS (klass)((((GDBusProxyClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((klass)), ((g_dbus_proxy_get_type ()))))))
;
431 proxy_class->g_signal = sn_host_v0_gen_proxy_g_signal;
432 proxy_class->g_properties_changed = sn_host_v0_gen_proxy_g_properties_changed;
433
434#if GLIB_VERSION_MAX_ALLOWED((((2) << 16 | (80) << 8))) < GLIB_VERSION_2_38(((2) << 16 | (38) << 8))
435 g_type_class_add_private (klass, sizeof (SnHostV0GenProxyPrivate));
436#endif
437}
438
439static void
440sn_host_v0_gen_proxy_iface_init (SnHostV0GenIface *iface G_GNUC_UNUSED__attribute__ ((__unused__)))
441{
442}
443
444/**
445 * sn_host_v0_gen_proxy_new:
446 * @connection: A #GDBusConnection.
447 * @flags: Flags from the #GDBusProxyFlags enumeration.
448 * @name: (nullable): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection.
449 * @object_path: An object path.
450 * @cancellable: (nullable): A #GCancellable or %NULL.
451 * @callback: A #GAsyncReadyCallback to call when the request is satisfied.
452 * @user_data: User data to pass to @callback.
453 *
454 * Asynchronously creates a proxy for the D-Bus interface <link linkend="gdbus-interface-org-kde-StatusNotifierHost.top_of_page">org.kde.StatusNotifierHost</link>. See g_dbus_proxy_new() for more details.
455 *
456 * When the operation is finished, @callback will be invoked in the thread-default main loop of the thread you are calling this method from (see g_main_context_push_thread_default()).
457 * You can then call sn_host_v0_gen_proxy_new_finish() to get the result of the operation.
458 *
459 * See sn_host_v0_gen_proxy_new_sync() for the synchronous, blocking version of this constructor.
460 */
461void
462sn_host_v0_gen_proxy_new (
463 GDBusConnection *connection,
464 GDBusProxyFlags flags,
465 const gchar *name,
466 const gchar *object_path,
467 GCancellable *cancellable,
468 GAsyncReadyCallback callback,
469 gpointer user_data)
470{
471 g_async_initable_new_async (SN_TYPE_HOST_V0_GEN_PROXY(sn_host_v0_gen_proxy_get_type ()), G_PRIORITY_DEFAULT0, cancellable, callback, user_data, "g-flags", flags, "g-name", name, "g-connection", connection, "g-object-path", object_path, "g-interface-name", "org.kde.StatusNotifierHost", NULL((void*)0));
472}
473
474/**
475 * sn_host_v0_gen_proxy_new_finish:
476 * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to sn_host_v0_gen_proxy_new().
477 * @error: Return location for error or %NULL
478 *
479 * Finishes an operation started with sn_host_v0_gen_proxy_new().
480 *
481 * Returns: (transfer full) (type SnHostV0GenProxy): The constructed proxy object or %NULL if @error is set.
482 */
483SnHostV0Gen *
484sn_host_v0_gen_proxy_new_finish (
485 GAsyncResult *res,
486 GError **error)
487{
488 GObject *ret;
489 GObject *source_object;
490 source_object = g_async_result_get_source_object (res);
491 ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object)((((GAsyncInitable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((source_object)), ((g_async_initable_get_type ()))))))
, res, error);
492 g_object_unref (source_object);
493 if (ret != NULL((void*)0))
494 return SN_HOST_V0_GEN (ret)((((SnHostV0Gen*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ret)), ((sn_host_v0_gen_get_type ()))))))
;
495 else
496 return NULL((void*)0);
497}
498
499/**
500 * sn_host_v0_gen_proxy_new_sync:
501 * @connection: A #GDBusConnection.
502 * @flags: Flags from the #GDBusProxyFlags enumeration.
503 * @name: (nullable): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection.
504 * @object_path: An object path.
505 * @cancellable: (nullable): A #GCancellable or %NULL.
506 * @error: Return location for error or %NULL
507 *
508 * Synchronously creates a proxy for the D-Bus interface <link linkend="gdbus-interface-org-kde-StatusNotifierHost.top_of_page">org.kde.StatusNotifierHost</link>. See g_dbus_proxy_new_sync() for more details.
509 *
510 * The calling thread is blocked until a reply is received.
511 *
512 * See sn_host_v0_gen_proxy_new() for the asynchronous version of this constructor.
513 *
514 * Returns: (transfer full) (type SnHostV0GenProxy): The constructed proxy object or %NULL if @error is set.
515 */
516SnHostV0Gen *
517sn_host_v0_gen_proxy_new_sync (
518 GDBusConnection *connection,
519 GDBusProxyFlags flags,
520 const gchar *name,
521 const gchar *object_path,
522 GCancellable *cancellable,
523 GError **error)
524{
525 GInitable *ret;
526 ret = g_initable_new (SN_TYPE_HOST_V0_GEN_PROXY(sn_host_v0_gen_proxy_get_type ()), cancellable, error, "g-flags", flags, "g-name", name, "g-connection", connection, "g-object-path", object_path, "g-interface-name", "org.kde.StatusNotifierHost", NULL((void*)0));
527 if (ret != NULL((void*)0))
528 return SN_HOST_V0_GEN (ret)((((SnHostV0Gen*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ret)), ((sn_host_v0_gen_get_type ()))))))
;
529 else
530 return NULL((void*)0);
531}
532
533
534/**
535 * sn_host_v0_gen_proxy_new_for_bus:
536 * @bus_type: A #GBusType.
537 * @flags: Flags from the #GDBusProxyFlags enumeration.
538 * @name: A bus name (well-known or unique).
539 * @object_path: An object path.
540 * @cancellable: (nullable): A #GCancellable or %NULL.
541 * @callback: A #GAsyncReadyCallback to call when the request is satisfied.
542 * @user_data: User data to pass to @callback.
543 *
544 * Like sn_host_v0_gen_proxy_new() but takes a #GBusType instead of a #GDBusConnection.
545 *
546 * When the operation is finished, @callback will be invoked in the thread-default main loop of the thread you are calling this method from (see g_main_context_push_thread_default()).
547 * You can then call sn_host_v0_gen_proxy_new_for_bus_finish() to get the result of the operation.
548 *
549 * See sn_host_v0_gen_proxy_new_for_bus_sync() for the synchronous, blocking version of this constructor.
550 */
551void
552sn_host_v0_gen_proxy_new_for_bus (
553 GBusType bus_type,
554 GDBusProxyFlags flags,
555 const gchar *name,
556 const gchar *object_path,
557 GCancellable *cancellable,
558 GAsyncReadyCallback callback,
559 gpointer user_data)
560{
561 g_async_initable_new_async (SN_TYPE_HOST_V0_GEN_PROXY(sn_host_v0_gen_proxy_get_type ()), G_PRIORITY_DEFAULT0, cancellable, callback, user_data, "g-flags", flags, "g-name", name, "g-bus-type", bus_type, "g-object-path", object_path, "g-interface-name", "org.kde.StatusNotifierHost", NULL((void*)0));
562}
563
564/**
565 * sn_host_v0_gen_proxy_new_for_bus_finish:
566 * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to sn_host_v0_gen_proxy_new_for_bus().
567 * @error: Return location for error or %NULL
568 *
569 * Finishes an operation started with sn_host_v0_gen_proxy_new_for_bus().
570 *
571 * Returns: (transfer full) (type SnHostV0GenProxy): The constructed proxy object or %NULL if @error is set.
572 */
573SnHostV0Gen *
574sn_host_v0_gen_proxy_new_for_bus_finish (
575 GAsyncResult *res,
576 GError **error)
577{
578 GObject *ret;
579 GObject *source_object;
580 source_object = g_async_result_get_source_object (res);
581 ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object)((((GAsyncInitable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((source_object)), ((g_async_initable_get_type ()))))))
, res, error);
582 g_object_unref (source_object);
583 if (ret != NULL((void*)0))
584 return SN_HOST_V0_GEN (ret)((((SnHostV0Gen*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ret)), ((sn_host_v0_gen_get_type ()))))))
;
585 else
586 return NULL((void*)0);
587}
588
589/**
590 * sn_host_v0_gen_proxy_new_for_bus_sync:
591 * @bus_type: A #GBusType.
592 * @flags: Flags from the #GDBusProxyFlags enumeration.
593 * @name: A bus name (well-known or unique).
594 * @object_path: An object path.
595 * @cancellable: (nullable): A #GCancellable or %NULL.
596 * @error: Return location for error or %NULL
597 *
598 * Like sn_host_v0_gen_proxy_new_sync() but takes a #GBusType instead of a #GDBusConnection.
599 *
600 * The calling thread is blocked until a reply is received.
601 *
602 * See sn_host_v0_gen_proxy_new_for_bus() for the asynchronous version of this constructor.
603 *
604 * Returns: (transfer full) (type SnHostV0GenProxy): The constructed proxy object or %NULL if @error is set.
605 */
606SnHostV0Gen *
607sn_host_v0_gen_proxy_new_for_bus_sync (
608 GBusType bus_type,
609 GDBusProxyFlags flags,
610 const gchar *name,
611 const gchar *object_path,
612 GCancellable *cancellable,
613 GError **error)
614{
615 GInitable *ret;
616 ret = g_initable_new (SN_TYPE_HOST_V0_GEN_PROXY(sn_host_v0_gen_proxy_get_type ()), cancellable, error, "g-flags", flags, "g-name", name, "g-bus-type", bus_type, "g-object-path", object_path, "g-interface-name", "org.kde.StatusNotifierHost", NULL((void*)0));
617 if (ret != NULL((void*)0))
618 return SN_HOST_V0_GEN (ret)((((SnHostV0Gen*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ret)), ((sn_host_v0_gen_get_type ()))))))
;
619 else
620 return NULL((void*)0);
621}
622
623
624/* ------------------------------------------------------------------------ */
625
626/**
627 * SnHostV0GenSkeleton:
628 *
629 * The #SnHostV0GenSkeleton structure contains only private data and should only be accessed using the provided API.
630 */
631
632/**
633 * SnHostV0GenSkeletonClass:
634 * @parent_class: The parent class.
635 *
636 * Class structure for #SnHostV0GenSkeleton.
637 */
638
639struct _SnHostV0GenSkeletonPrivate
640{
641 GValue *properties;
642 GList *changed_properties;
643 GSource *changed_properties_idle_source;
644 GMainContext *context;
645 GMutex lock;
646};
647
648static void
649_sn_host_v0_gen_skeleton_handle_method_call (
650 GDBusConnection *connection G_GNUC_UNUSED__attribute__ ((__unused__)),
651 const gchar *sender G_GNUC_UNUSED__attribute__ ((__unused__)),
652 const gchar *object_path G_GNUC_UNUSED__attribute__ ((__unused__)),
653 const gchar *interface_name,
654 const gchar *method_name,
655 GVariant *parameters,
656 GDBusMethodInvocation *invocation,
657 gpointer user_data)
658{
659 SnHostV0GenSkeleton *skeleton = SN_HOST_V0_GEN_SKELETON (user_data)((((SnHostV0GenSkeleton*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((user_data)), ((sn_host_v0_gen_skeleton_get_type
()))))))
;
660 _ExtendedGDBusMethodInfo *info;
661 GVariantIter iter;
662 GVariant *child;
663 GValue *paramv;
664 gsize num_params;
665 guint num_extra;
666 gsize n;
667 guint signal_id;
668 GValue return_value = G_VALUE_INIT{ 0, { { 0 } } };
669 info = (_ExtendedGDBusMethodInfo *) g_dbus_method_invocation_get_method_info (invocation);
670 g_assert (info != NULL)do { if (info != ((void*)0)) ; else g_assertion_message_expr (
"notification-area-applet", "sn-host-v0-gen.c", 670, ((const char
*) (__func__)), "info != NULL"); } while (0)
;
671 num_params = g_variant_n_children (parameters);
672 num_extra = info->pass_fdlist ? 3 : 2; paramv = g_new0 (GValue, num_params + num_extra)((GValue *) g_malloc0_n ((num_params + num_extra), sizeof (GValue
)))
;
673 n = 0;
674 g_value_init (&paramv[n], SN_TYPE_HOST_V0_GEN(sn_host_v0_gen_get_type ()));
675 g_value_set_object (&paramv[n++], skeleton);
676 g_value_init (&paramv[n], G_TYPE_DBUS_METHOD_INVOCATION(g_dbus_method_invocation_get_type ()));
677 g_value_set_object (&paramv[n++], invocation);
678 if (info->pass_fdlist)
679 {
680#ifdef G_OS_UNIX
681 g_value_init (&paramv[n], G_TYPE_UNIX_FD_LIST(g_unix_fd_list_get_type ()));
682 g_value_set_object (&paramv[n++], g_dbus_message_get_unix_fd_list (g_dbus_method_invocation_get_message (invocation)));
683#else
684 g_assert_not_reached ()do { g_assertion_message_expr ("notification-area-applet", "sn-host-v0-gen.c"
, 684, ((const char*) (__func__)), ((void*)0)); } while (0)
;
685#endif
686 }
687 g_variant_iter_init (&iter, parameters);
688 while ((child = g_variant_iter_next_value (&iter)) != NULL((void*)0))
689 {
690 _ExtendedGDBusArgInfo *arg_info = (_ExtendedGDBusArgInfo *) info->parent_struct.in_args[n - num_extra];
691 if (arg_info->use_gvariant)
692 {
693 g_value_init (&paramv[n], G_TYPE_VARIANT((GType) ((21) << (2))));
694 g_value_set_variant (&paramv[n], child);
695 n++;
696 }
697 else
698 g_dbus_gvariant_to_gvalue (child, &paramv[n++]);
699 g_variant_unref (child);
700 }
701 signal_id = g_signal_lookup (info->signal_name, SN_TYPE_HOST_V0_GEN(sn_host_v0_gen_get_type ()));
702 g_value_init (&return_value, G_TYPE_BOOLEAN((GType) ((5) << (2))));
703 g_signal_emitv (paramv, signal_id, 0, &return_value);
704 if (!g_value_get_boolean (&return_value))
705 g_dbus_method_invocation_return_error (invocation, G_DBUS_ERRORg_dbus_error_quark(), G_DBUS_ERROR_UNKNOWN_METHOD, "Method %s is not implemented on interface %s", method_name, interface_name);
706 g_value_unset (&return_value);
707 for (n = 0; n < num_params + num_extra; n++)
708 g_value_unset (&paramv[n]);
709 g_free (paramv);
710}
711
712static GVariant *
713_sn_host_v0_gen_skeleton_handle_get_property (
714 GDBusConnection *connection G_GNUC_UNUSED__attribute__ ((__unused__)),
715 const gchar *sender G_GNUC_UNUSED__attribute__ ((__unused__)),
716 const gchar *object_path G_GNUC_UNUSED__attribute__ ((__unused__)),
717 const gchar *interface_name G_GNUC_UNUSED__attribute__ ((__unused__)),
718 const gchar *property_name,
719 GError **error,
720 gpointer user_data)
721{
722 SnHostV0GenSkeleton *skeleton = SN_HOST_V0_GEN_SKELETON (user_data)((((SnHostV0GenSkeleton*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((user_data)), ((sn_host_v0_gen_skeleton_get_type
()))))))
;
723 GValue value = G_VALUE_INIT{ 0, { { 0 } } };
724 GParamSpec *pspec;
725 _ExtendedGDBusPropertyInfo *info;
726 GVariant *ret;
727 ret = NULL((void*)0);
728 info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_sn_host_v0_gen_interface_info.parent_struct, property_name);
729 g_assert (info != NULL)do { if (info != ((void*)0)) ; else g_assertion_message_expr (
"notification-area-applet", "sn-host-v0-gen.c", 729, ((const char
*) (__func__)), "info != NULL"); } while (0)
;
730 pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (skeleton)((((GObjectClass*) (((GTypeInstance*) ((skeleton)))->g_class
))))
, info->hyphen_name);
731 if (pspec == NULL((void*)0))
732 {
733 g_set_error (error, G_DBUS_ERRORg_dbus_error_quark(), G_DBUS_ERROR_INVALID_ARGS, "No property with name %s", property_name);
734 }
735 else
736 {
737 g_value_init (&value, pspec->value_type);
738 g_object_get_property (G_OBJECT (skeleton)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((skeleton)), (((GType) ((20) << (2))))))))
, info->hyphen_name, &value);
739 ret = g_dbus_gvalue_to_gvariant (&value, G_VARIANT_TYPE (info->parent_struct.signature)(g_variant_type_checked_ ((info->parent_struct.signature))
)
);
740 g_value_unset (&value);
741 }
742 return ret;
743}
744
745static gboolean
746_sn_host_v0_gen_skeleton_handle_set_property (
747 GDBusConnection *connection G_GNUC_UNUSED__attribute__ ((__unused__)),
748 const gchar *sender G_GNUC_UNUSED__attribute__ ((__unused__)),
749 const gchar *object_path G_GNUC_UNUSED__attribute__ ((__unused__)),
750 const gchar *interface_name G_GNUC_UNUSED__attribute__ ((__unused__)),
751 const gchar *property_name,
752 GVariant *variant,
753 GError **error,
754 gpointer user_data)
755{
756 SnHostV0GenSkeleton *skeleton = SN_HOST_V0_GEN_SKELETON (user_data)((((SnHostV0GenSkeleton*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((user_data)), ((sn_host_v0_gen_skeleton_get_type
()))))))
;
757 GValue value = G_VALUE_INIT{ 0, { { 0 } } };
758 GParamSpec *pspec;
759 _ExtendedGDBusPropertyInfo *info;
760 gboolean ret;
761 ret = FALSE(0);
762 info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_sn_host_v0_gen_interface_info.parent_struct, property_name);
763 g_assert (info != NULL)do { if (info != ((void*)0)) ; else g_assertion_message_expr (
"notification-area-applet", "sn-host-v0-gen.c", 763, ((const char
*) (__func__)), "info != NULL"); } while (0)
;
764 pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (skeleton)((((GObjectClass*) (((GTypeInstance*) ((skeleton)))->g_class
))))
, info->hyphen_name);
765 if (pspec == NULL((void*)0))
766 {
767 g_set_error (error, G_DBUS_ERRORg_dbus_error_quark(), G_DBUS_ERROR_INVALID_ARGS, "No property with name %s", property_name);
768 }
769 else
770 {
771 if (info->use_gvariant)
772 g_value_set_variant (&value, variant);
773 else
774 g_dbus_gvariant_to_gvalue (variant, &value);
775 g_object_set_property (G_OBJECT (skeleton)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((skeleton)), (((GType) ((20) << (2))))))))
, info->hyphen_name, &value);
776 g_value_unset (&value);
777 ret = TRUE(!(0));
778 }
779 return ret;
780}
781
782static const GDBusInterfaceVTable _sn_host_v0_gen_skeleton_vtable =
783{
784 _sn_host_v0_gen_skeleton_handle_method_call,
785 _sn_host_v0_gen_skeleton_handle_get_property,
786 _sn_host_v0_gen_skeleton_handle_set_property,
787 {NULL((void*)0)}
788};
789
790static GDBusInterfaceInfo *
791sn_host_v0_gen_skeleton_dbus_interface_get_info (GDBusInterfaceSkeleton *skeleton G_GNUC_UNUSED__attribute__ ((__unused__)))
792{
793 return sn_host_v0_gen_interface_info ();
794}
795
796static GDBusInterfaceVTable *
797sn_host_v0_gen_skeleton_dbus_interface_get_vtable (GDBusInterfaceSkeleton *skeleton G_GNUC_UNUSED__attribute__ ((__unused__)))
798{
799 return (GDBusInterfaceVTable *) &_sn_host_v0_gen_skeleton_vtable;
800}
801
802static GVariant *
803sn_host_v0_gen_skeleton_dbus_interface_get_properties (GDBusInterfaceSkeleton *_skeleton)
804{
805 SnHostV0GenSkeleton *skeleton = SN_HOST_V0_GEN_SKELETON (_skeleton)((((SnHostV0GenSkeleton*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((_skeleton)), ((sn_host_v0_gen_skeleton_get_type
()))))))
;
Value stored to 'skeleton' during its initialization is never read
806
807 GVariantBuilder builder;
808 guint n;
809 g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}")(g_variant_type_checked_ (("a{sv}"))));
810 if (_sn_host_v0_gen_interface_info.parent_struct.properties == NULL((void*)0))
811 goto out;
812 for (n = 0; _sn_host_v0_gen_interface_info.parent_struct.properties[n] != NULL((void*)0); n++)
813 {
814 GDBusPropertyInfo *info = _sn_host_v0_gen_interface_info.parent_struct.properties[n];
815 if (info->flags & G_DBUS_PROPERTY_INFO_FLAGS_READABLE)
816 {
817 GVariant *value;
818 value = _sn_host_v0_gen_skeleton_handle_get_property (g_dbus_interface_skeleton_get_connection (G_DBUS_INTERFACE_SKELETON (skeleton)((((GDBusInterfaceSkeleton*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((skeleton)), ((g_dbus_interface_skeleton_get_type
()))))))
), NULL((void*)0), g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)((((GDBusInterfaceSkeleton*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((skeleton)), ((g_dbus_interface_skeleton_get_type
()))))))
), "org.kde.StatusNotifierHost", info->name, NULL((void*)0), skeleton);
819 if (value != NULL((void*)0))
820 {
821 g_variant_take_ref (value);
822 g_variant_builder_add (&builder, "{sv}", info->name, value);
823 g_variant_unref (value);
824 }
825 }
826 }
827out:
828 return g_variant_builder_end (&builder);
829}
830
831static void
832sn_host_v0_gen_skeleton_dbus_interface_flush (GDBusInterfaceSkeleton *_skeleton G_GNUC_UNUSED__attribute__ ((__unused__)))
833{
834}
835
836static void sn_host_v0_gen_skeleton_iface_init (SnHostV0GenIface *iface);
837#if GLIB_VERSION_MAX_ALLOWED((((2) << 16 | (80) << 8))) >= GLIB_VERSION_2_38(((2) << 16 | (38) << 8))
838G_DEFINE_TYPE_WITH_CODE (SnHostV0GenSkeleton, sn_host_v0_gen_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON,static void sn_host_v0_gen_skeleton_init (SnHostV0GenSkeleton
*self); static void sn_host_v0_gen_skeleton_class_init (SnHostV0GenSkeletonClass
*klass); static GType sn_host_v0_gen_skeleton_get_type_once (
void); static gpointer sn_host_v0_gen_skeleton_parent_class =
((void*)0); static gint SnHostV0GenSkeleton_private_offset; static
void sn_host_v0_gen_skeleton_class_intern_init (gpointer klass
) { sn_host_v0_gen_skeleton_parent_class = g_type_class_peek_parent
(klass); if (SnHostV0GenSkeleton_private_offset != 0) g_type_class_adjust_private_offset
(klass, &SnHostV0GenSkeleton_private_offset); sn_host_v0_gen_skeleton_class_init
((SnHostV0GenSkeletonClass*) klass); } __attribute__ ((__unused__
)) static inline gpointer sn_host_v0_gen_skeleton_get_instance_private
(SnHostV0GenSkeleton *self) { return (((gpointer) ((guint8*)
(self) + (glong) (SnHostV0GenSkeleton_private_offset)))); } GType
sn_host_v0_gen_skeleton_get_type (void) { static GType static_g_define_type_id
= 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); (void
) (0 ? (gpointer) * (&static_g_define_type_id) : ((void*)
0)); (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter_pointer (
&static_g_define_type_id)); })) ) { GType g_define_type_id
= sn_host_v0_gen_skeleton_get_type_once (); (__extension__ (
{ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof
(gpointer), "Expression evaluates to false"); 0 ? (void) (*(
&static_g_define_type_id) = (g_define_type_id)) : (void) 0
; g_once_init_leave_pointer ((&static_g_define_type_id), (
gpointer) (guintptr) (g_define_type_id)); })) ; } return static_g_define_type_id
; } __attribute__ ((__noinline__)) static GType sn_host_v0_gen_skeleton_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
((g_dbus_interface_skeleton_get_type ()), g_intern_static_string
("SnHostV0GenSkeleton"), sizeof (SnHostV0GenSkeletonClass), (
GClassInitFunc)(void (*)(void)) sn_host_v0_gen_skeleton_class_intern_init
, sizeof (SnHostV0GenSkeleton), (GInstanceInitFunc)(void (*)(
void)) sn_host_v0_gen_skeleton_init, (GTypeFlags) 0); { {{ SnHostV0GenSkeleton_private_offset
= g_type_add_instance_private (g_define_type_id, sizeof (SnHostV0GenSkeletonPrivate
)); } { const GInterfaceInfo g_implement_interface_info = { (
GInterfaceInitFunc)(void (*)(void)) sn_host_v0_gen_skeleton_iface_init
, ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id
, (sn_host_v0_gen_get_type ()), &g_implement_interface_info
); };} } return g_define_type_id; }
839 G_ADD_PRIVATE (SnHostV0GenSkeleton)static void sn_host_v0_gen_skeleton_init (SnHostV0GenSkeleton
*self); static void sn_host_v0_gen_skeleton_class_init (SnHostV0GenSkeletonClass
*klass); static GType sn_host_v0_gen_skeleton_get_type_once (
void); static gpointer sn_host_v0_gen_skeleton_parent_class =
((void*)0); static gint SnHostV0GenSkeleton_private_offset; static
void sn_host_v0_gen_skeleton_class_intern_init (gpointer klass
) { sn_host_v0_gen_skeleton_parent_class = g_type_class_peek_parent
(klass); if (SnHostV0GenSkeleton_private_offset != 0) g_type_class_adjust_private_offset
(klass, &SnHostV0GenSkeleton_private_offset); sn_host_v0_gen_skeleton_class_init
((SnHostV0GenSkeletonClass*) klass); } __attribute__ ((__unused__
)) static inline gpointer sn_host_v0_gen_skeleton_get_instance_private
(SnHostV0GenSkeleton *self) { return (((gpointer) ((guint8*)
(self) + (glong) (SnHostV0GenSkeleton_private_offset)))); } GType
sn_host_v0_gen_skeleton_get_type (void) { static GType static_g_define_type_id
= 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); (void
) (0 ? (gpointer) * (&static_g_define_type_id) : ((void*)
0)); (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter_pointer (
&static_g_define_type_id)); })) ) { GType g_define_type_id
= sn_host_v0_gen_skeleton_get_type_once (); (__extension__ (
{ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof
(gpointer), "Expression evaluates to false"); 0 ? (void) (*(
&static_g_define_type_id) = (g_define_type_id)) : (void) 0
; g_once_init_leave_pointer ((&static_g_define_type_id), (
gpointer) (guintptr) (g_define_type_id)); })) ; } return static_g_define_type_id
; } __attribute__ ((__noinline__)) static GType sn_host_v0_gen_skeleton_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
((g_dbus_interface_skeleton_get_type ()), g_intern_static_string
("SnHostV0GenSkeleton"), sizeof (SnHostV0GenSkeletonClass), (
GClassInitFunc)(void (*)(void)) sn_host_v0_gen_skeleton_class_intern_init
, sizeof (SnHostV0GenSkeleton), (GInstanceInitFunc)(void (*)(
void)) sn_host_v0_gen_skeleton_init, (GTypeFlags) 0); { {{ SnHostV0GenSkeleton_private_offset
= g_type_add_instance_private (g_define_type_id, sizeof (SnHostV0GenSkeletonPrivate
)); } { const GInterfaceInfo g_implement_interface_info = { (
GInterfaceInitFunc)(void (*)(void)) sn_host_v0_gen_skeleton_iface_init
, ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id
, (sn_host_v0_gen_get_type ()), &g_implement_interface_info
); };} } return g_define_type_id; }
840 G_IMPLEMENT_INTERFACE (SN_TYPE_HOST_V0_GEN, sn_host_v0_gen_skeleton_iface_init))static void sn_host_v0_gen_skeleton_init (SnHostV0GenSkeleton
*self); static void sn_host_v0_gen_skeleton_class_init (SnHostV0GenSkeletonClass
*klass); static GType sn_host_v0_gen_skeleton_get_type_once (
void); static gpointer sn_host_v0_gen_skeleton_parent_class =
((void*)0); static gint SnHostV0GenSkeleton_private_offset; static
void sn_host_v0_gen_skeleton_class_intern_init (gpointer klass
) { sn_host_v0_gen_skeleton_parent_class = g_type_class_peek_parent
(klass); if (SnHostV0GenSkeleton_private_offset != 0) g_type_class_adjust_private_offset
(klass, &SnHostV0GenSkeleton_private_offset); sn_host_v0_gen_skeleton_class_init
((SnHostV0GenSkeletonClass*) klass); } __attribute__ ((__unused__
)) static inline gpointer sn_host_v0_gen_skeleton_get_instance_private
(SnHostV0GenSkeleton *self) { return (((gpointer) ((guint8*)
(self) + (glong) (SnHostV0GenSkeleton_private_offset)))); } GType
sn_host_v0_gen_skeleton_get_type (void) { static GType static_g_define_type_id
= 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); (void
) (0 ? (gpointer) * (&static_g_define_type_id) : ((void*)
0)); (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter_pointer (
&static_g_define_type_id)); })) ) { GType g_define_type_id
= sn_host_v0_gen_skeleton_get_type_once (); (__extension__ (
{ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof
(gpointer), "Expression evaluates to false"); 0 ? (void) (*(
&static_g_define_type_id) = (g_define_type_id)) : (void) 0
; g_once_init_leave_pointer ((&static_g_define_type_id), (
gpointer) (guintptr) (g_define_type_id)); })) ; } return static_g_define_type_id
; } __attribute__ ((__noinline__)) static GType sn_host_v0_gen_skeleton_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
((g_dbus_interface_skeleton_get_type ()), g_intern_static_string
("SnHostV0GenSkeleton"), sizeof (SnHostV0GenSkeletonClass), (
GClassInitFunc)(void (*)(void)) sn_host_v0_gen_skeleton_class_intern_init
, sizeof (SnHostV0GenSkeleton), (GInstanceInitFunc)(void (*)(
void)) sn_host_v0_gen_skeleton_init, (GTypeFlags) 0); { {{ SnHostV0GenSkeleton_private_offset
= g_type_add_instance_private (g_define_type_id, sizeof (SnHostV0GenSkeletonPrivate
)); } { const GInterfaceInfo g_implement_interface_info = { (
GInterfaceInitFunc)(void (*)(void)) sn_host_v0_gen_skeleton_iface_init
, ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id
, (sn_host_v0_gen_get_type ()), &g_implement_interface_info
); };} } return g_define_type_id; }
841
842#else
843G_DEFINE_TYPE_WITH_CODE (SnHostV0GenSkeleton, sn_host_v0_gen_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON,static void sn_host_v0_gen_skeleton_init (SnHostV0GenSkeleton
*self); static void sn_host_v0_gen_skeleton_class_init (SnHostV0GenSkeletonClass
*klass); static GType sn_host_v0_gen_skeleton_get_type_once (
void); static gpointer sn_host_v0_gen_skeleton_parent_class =
((void*)0); static gint SnHostV0GenSkeleton_private_offset; static
void sn_host_v0_gen_skeleton_class_intern_init (gpointer klass
) { sn_host_v0_gen_skeleton_parent_class = g_type_class_peek_parent
(klass); if (SnHostV0GenSkeleton_private_offset != 0) g_type_class_adjust_private_offset
(klass, &SnHostV0GenSkeleton_private_offset); sn_host_v0_gen_skeleton_class_init
((SnHostV0GenSkeletonClass*) klass); } __attribute__ ((__unused__
)) static inline gpointer sn_host_v0_gen_skeleton_get_instance_private
(SnHostV0GenSkeleton *self) { return (((gpointer) ((guint8*)
(self) + (glong) (SnHostV0GenSkeleton_private_offset)))); } GType
sn_host_v0_gen_skeleton_get_type (void) { static GType static_g_define_type_id
= 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); (void
) (0 ? (gpointer) * (&static_g_define_type_id) : ((void*)
0)); (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter_pointer (
&static_g_define_type_id)); })) ) { GType g_define_type_id
= sn_host_v0_gen_skeleton_get_type_once (); (__extension__ (
{ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof
(gpointer), "Expression evaluates to false"); 0 ? (void) (*(
&static_g_define_type_id) = (g_define_type_id)) : (void) 0
; g_once_init_leave_pointer ((&static_g_define_type_id), (
gpointer) (guintptr) (g_define_type_id)); })) ; } return static_g_define_type_id
; } __attribute__ ((__noinline__)) static GType sn_host_v0_gen_skeleton_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
((g_dbus_interface_skeleton_get_type ()), g_intern_static_string
("SnHostV0GenSkeleton"), sizeof (SnHostV0GenSkeletonClass), (
GClassInitFunc)(void (*)(void)) sn_host_v0_gen_skeleton_class_intern_init
, sizeof (SnHostV0GenSkeleton), (GInstanceInitFunc)(void (*)(
void)) sn_host_v0_gen_skeleton_init, (GTypeFlags) 0); { {{ const
GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc
)(void (*)(void)) sn_host_v0_gen_skeleton_iface_init, ((void*
)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id
, (sn_host_v0_gen_get_type ()), &g_implement_interface_info
); };} } return g_define_type_id; }
844 G_IMPLEMENT_INTERFACE (SN_TYPE_HOST_V0_GEN, sn_host_v0_gen_skeleton_iface_init))static void sn_host_v0_gen_skeleton_init (SnHostV0GenSkeleton
*self); static void sn_host_v0_gen_skeleton_class_init (SnHostV0GenSkeletonClass
*klass); static GType sn_host_v0_gen_skeleton_get_type_once (
void); static gpointer sn_host_v0_gen_skeleton_parent_class =
((void*)0); static gint SnHostV0GenSkeleton_private_offset; static
void sn_host_v0_gen_skeleton_class_intern_init (gpointer klass
) { sn_host_v0_gen_skeleton_parent_class = g_type_class_peek_parent
(klass); if (SnHostV0GenSkeleton_private_offset != 0) g_type_class_adjust_private_offset
(klass, &SnHostV0GenSkeleton_private_offset); sn_host_v0_gen_skeleton_class_init
((SnHostV0GenSkeletonClass*) klass); } __attribute__ ((__unused__
)) static inline gpointer sn_host_v0_gen_skeleton_get_instance_private
(SnHostV0GenSkeleton *self) { return (((gpointer) ((guint8*)
(self) + (glong) (SnHostV0GenSkeleton_private_offset)))); } GType
sn_host_v0_gen_skeleton_get_type (void) { static GType static_g_define_type_id
= 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); (void
) (0 ? (gpointer) * (&static_g_define_type_id) : ((void*)
0)); (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter_pointer (
&static_g_define_type_id)); })) ) { GType g_define_type_id
= sn_host_v0_gen_skeleton_get_type_once (); (__extension__ (
{ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof
(gpointer), "Expression evaluates to false"); 0 ? (void) (*(
&static_g_define_type_id) = (g_define_type_id)) : (void) 0
; g_once_init_leave_pointer ((&static_g_define_type_id), (
gpointer) (guintptr) (g_define_type_id)); })) ; } return static_g_define_type_id
; } __attribute__ ((__noinline__)) static GType sn_host_v0_gen_skeleton_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
((g_dbus_interface_skeleton_get_type ()), g_intern_static_string
("SnHostV0GenSkeleton"), sizeof (SnHostV0GenSkeletonClass), (
GClassInitFunc)(void (*)(void)) sn_host_v0_gen_skeleton_class_intern_init
, sizeof (SnHostV0GenSkeleton), (GInstanceInitFunc)(void (*)(
void)) sn_host_v0_gen_skeleton_init, (GTypeFlags) 0); { {{ const
GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc
)(void (*)(void)) sn_host_v0_gen_skeleton_iface_init, ((void*
)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id
, (sn_host_v0_gen_get_type ()), &g_implement_interface_info
); };} } return g_define_type_id; }
845
846#endif
847static void
848sn_host_v0_gen_skeleton_finalize (GObject *object)
849{
850 SnHostV0GenSkeleton *skeleton = SN_HOST_V0_GEN_SKELETON (object)((((SnHostV0GenSkeleton*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((object)), ((sn_host_v0_gen_skeleton_get_type
()))))))
;
851 g_list_free_full (skeleton->priv->changed_properties, (GDestroyNotify) _changed_property_free);
852 if (skeleton->priv->changed_properties_idle_source != NULL((void*)0))
853 g_source_destroy (skeleton->priv->changed_properties_idle_source);
854 g_main_context_unref (skeleton->priv->context);
855 g_mutex_clear (&skeleton->priv->lock);
856 G_OBJECT_CLASS (sn_host_v0_gen_skeleton_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((sn_host_v0_gen_skeleton_parent_class)), (((GType) ((20) <<
(2))))))))
->finalize (object);
857}
858
859static void
860sn_host_v0_gen_skeleton_init (SnHostV0GenSkeleton *skeleton)
861{
862#if GLIB_VERSION_MAX_ALLOWED((((2) << 16 | (80) << 8))) >= GLIB_VERSION_2_38(((2) << 16 | (38) << 8))
863 skeleton->priv = sn_host_v0_gen_skeleton_get_instance_private (skeleton);
864#else
865 skeleton->priv = G_TYPE_INSTANCE_GET_PRIVATE (skeleton, SN_TYPE_HOST_V0_GEN_SKELETON, SnHostV0GenSkeletonPrivate)((SnHostV0GenSkeletonPrivate*) g_type_instance_get_private ((
GTypeInstance*) (skeleton), ((sn_host_v0_gen_skeleton_get_type
())))) GCC warning "Deprecated pre-processor symbol: replace with \"G_ADD_PRIVATE\""
+
;
866#endif
867
868 g_mutex_init (&skeleton->priv->lock);
869 skeleton->priv->context = g_main_context_ref_thread_default ();
870}
871
872static void
873sn_host_v0_gen_skeleton_class_init (SnHostV0GenSkeletonClass *klass)
874{
875 GObjectClass *gobject_class;
876 GDBusInterfaceSkeletonClass *skeleton_class;
877
878 gobject_class = G_OBJECT_CLASS (klass)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((klass)), (((GType) ((20) << (2))))))))
;
879 gobject_class->finalize = sn_host_v0_gen_skeleton_finalize;
880
881 skeleton_class = G_DBUS_INTERFACE_SKELETON_CLASS (klass)((((GDBusInterfaceSkeletonClass*) (void *) g_type_check_class_cast
((GTypeClass*) ((klass)), ((g_dbus_interface_skeleton_get_type
()))))))
;
882 skeleton_class->get_info = sn_host_v0_gen_skeleton_dbus_interface_get_info;
883 skeleton_class->get_properties = sn_host_v0_gen_skeleton_dbus_interface_get_properties;
884 skeleton_class->flush = sn_host_v0_gen_skeleton_dbus_interface_flush;
885 skeleton_class->get_vtable = sn_host_v0_gen_skeleton_dbus_interface_get_vtable;
886
887#if GLIB_VERSION_MAX_ALLOWED((((2) << 16 | (80) << 8))) < GLIB_VERSION_2_38(((2) << 16 | (38) << 8))
888 g_type_class_add_private (klass, sizeof (SnHostV0GenSkeletonPrivate));
889#endif
890}
891
892static void
893sn_host_v0_gen_skeleton_iface_init (SnHostV0GenIface *iface G_GNUC_UNUSED__attribute__ ((__unused__)))
894{
895}
896
897/**
898 * sn_host_v0_gen_skeleton_new:
899 *
900 * Creates a skeleton object for the D-Bus interface <link linkend="gdbus-interface-org-kde-StatusNotifierHost.top_of_page">org.kde.StatusNotifierHost</link>.
901 *
902 * Returns: (transfer full) (type SnHostV0GenSkeleton): The skeleton object.
903 */
904SnHostV0Gen *
905sn_host_v0_gen_skeleton_new (void)
906{
907 return SN_HOST_V0_GEN (g_object_new (SN_TYPE_HOST_V0_GEN_SKELETON, NULL))((((SnHostV0Gen*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_new ((sn_host_v0_gen_skeleton_get_type ()), ((void
*)0)))), ((sn_host_v0_gen_get_type ()))))))
;
908}
909
diff --git a/2024-06-18-172109-13286-1@e182420b844f_master/report-0e0727.html b/2024-06-18-172109-13286-1@e182420b844f_master/report-0e0727.html new file mode 100644 index 00000000..f861e8f5 --- /dev/null +++ b/2024-06-18-172109-13286-1@e182420b844f_master/report-0e0727.html @@ -0,0 +1,6265 @@ + + + +panel-toplevel.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:mate-panel/panel-toplevel.c
Warning:line 2411, column 9
Assigned value is garbage or undefined
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name panel-toplevel.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/mate-panel -fcoverage-compilation-dir=/rootdir/mate-panel -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I .. -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/startup-notification-1.0 -I /usr/include/mate-menus -I /usr/include/gio-unix-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/dconf -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/dconf -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I . -I . -I ../mate-panel -I ../mate-panel/mate-submodules -I ../mate-panel/libpanel-util -D MATELOCALEDIR="/usr/local/share/locale" -D PANELDATADIR="/usr/local/share/mate-panel" -I /usr/include/gtk-layer-shell -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/gtk-3.0 -I /usr/include/cloudproviders -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/atk-1.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/gio-unix-2.0 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -D PANEL_MODULES_DIR="/usr/local/lib/mate-panel/modules" -D MATEMENU_I_KNOW_THIS_IS_UNSTABLE -I /usr/include/gtk-layer-shell -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/gtk-3.0 -I /usr/include/cloudproviders -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/atk-1.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/gio-unix-2.0 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-18-172109-13286-1 -x c panel-toplevel.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
2 *
3 * panel-toplevel.c: The panel's toplevel window object.
4 *
5 * Copyright (C) 2003 Sun Microsystems, Inc.
6 * Copyright (C) 2004 Rob Adams
7 * Copyright (C) 2012-2021 MATE Developers
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of the
12 * License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
22 * 02110-1301, USA.
23 *
24 * Authors:
25 * Mark McLoughlin <mark@skynet.ie>
26 */
27
28#include <config.h>
29
30#include "panel-toplevel.h"
31
32#include <stdlib.h>
33#include <string.h>
34
35#include <gtk/gtk.h>
36#include <gdk/gdkkeysyms.h>
37#include <glib/gi18n.h>
38
39#ifdef HAVE_X111
40#include <gdk/gdkx.h>
41#endif
42
43#include "panel-util.h"
44#include "panel-profile.h"
45#include "panel-frame.h"
46#include "panel-multimonitor.h"
47#include "panel-a11y.h"
48#include "panel-typebuiltins.h"
49#include "panel-marshal.h"
50#include "panel-widget.h"
51#include "panel-bindings.h"
52#include "panel-config-global.h"
53#include "panel-lockdown.h"
54#include "panel-schemas.h"
55
56#ifdef HAVE_X111
57#include "xstuff.h"
58#include "panel-xutils.h"
59#include "panel-struts.h"
60#endif
61#ifdef HAVE_WAYLAND1
62#include "wayland-backend.h"
63#endif
64
65#define DEFAULT_SIZE48 48
66#define DEFAULT_AUTO_HIDE_SIZE1 1
67#define DEFAULT_HIDE_DELAY300 300
68#define DEFAULT_UNHIDE_DELAY100 100
69#define DEFAULT_DND_THRESHOLD8 8
70#define MINIMUM_WIDTH100 100
71#define MAXIMUM_SIZE_SCREEN_RATIO5 5
72#define SNAP_TOLERANCE_FACTOR6 6
73#define DEFAULT_ARROW_SIZE20 20
74#define HANDLE_SIZE10 10
75#define N_ATTACH_TOPLEVEL_SIGNALS5 5
76#define N_ATTACH_WIDGET_SIGNALS5 5
77
78typedef enum {
79 PANEL_GRAB_OP_NONE,
80 PANEL_GRAB_OP_MOVE,
81 PANEL_GRAB_OP_RESIZE,
82 PANEL_GRAB_OP_RESIZE_UP,
83 PANEL_GRAB_OP_RESIZE_DOWN,
84 PANEL_GRAB_OP_RESIZE_LEFT,
85 PANEL_GRAB_OP_RESIZE_RIGHT
86} PanelGrabOpType;
87
88struct _PanelToplevelPrivate {
89 gchar *settings_path;
90
91 gboolean expand;
92 PanelOrientation orientation;
93 int size;
94 gint scale;
95
96 /* relative to the monitor origin */
97 int x;
98 int y;
99 /* relative to the bottom right corner, -1 to ignore and use x, y*/
100 int x_right;
101 int y_bottom;
102
103 int monitor;
104 /* this is used when the configured monitor is missing. We keep it so
105 * we can move the toplevel to the right monitor when it becomes
106 * available */
107 int configured_monitor;
108
109 int hide_delay;
110 int unhide_delay;
111 int auto_hide_size;
112 PanelAnimationSpeed animation_speed;
113
114 int snap_tolerance;
115 GtkSettings *gtk_settings;
116
117 PanelState state;
118
119 char *name;
120 char *description;
121
122 guint hide_timeout;
123 guint unhide_timeout;
124
125 GdkRectangle geometry;
126 PanelFrameEdge edges;
127
128 int original_width;
129 int original_height;
130
131 PanelGrabOpType grab_op;
132
133 /* The offset within the panel from which the panel
134 * drag was initiated relative to the screen origin.
135 */
136 int drag_offset_x;
137 int drag_offset_y;
138
139 /* Saved state before for cancelled grab op */
140 int orig_monitor;
141 int orig_x;
142 int orig_y;
143 int orig_x_right;
144 int orig_y_bottom;
145 int orig_size;
146 int orig_orientation;
147
148 /* relative to the monitor origin */
149 int animation_end_x;
150 int animation_end_y;
151 int animation_end_width;
152 int animation_end_height;
153 gint64 animation_start_time; /* monotonic start time in microseconds */
154 GTimeSpan animation_duration_time; /* monotonic duration time in microseconds */
155 guint animation_timeout;
156
157 PanelWidget *panel_widget;
158 PanelFrame *inner_frame;
159 GtkWidget *grid;
160 GtkWidget *hide_button_top;
161 GtkWidget *hide_button_bottom;
162 GtkWidget *hide_button_left;
163 GtkWidget *hide_button_right;
164
165 PanelToplevel *attach_toplevel;
166 gulong attach_toplevel_signals [N_ATTACH_TOPLEVEL_SIGNALS5];
167 GtkWidget *attach_widget;
168 gulong attach_widget_signals [N_ATTACH_WIDGET_SIGNALS5];
169 gint n_autohide_disablers;
170
171 guint auto_hide : 1;
172 guint animate : 1;
173 guint buttons_enabled : 1;
174 guint arrows_enabled : 1;
175
176 /* The co-ordinates are relative to center screen */
177 guint x_centered : 1;
178 guint y_centered : 1;
179
180 /* The panel is not lined up with th screen edge */
181 guint floating : 1;
182
183 /* We are currently animating a hide/show */
184 guint animating : 1;
185
186 /* This is a keyboard initiated grab operation */
187 guint grab_is_keyboard : 1;
188
189 /* The x-y co-ordinates temporarily specify the panel center.
190 * This is used when the panel is rotating, because the width/height
191 * of the toplevel might change, so we need to compute new values for
192 * those. */
193 guint position_centered : 1;
194
195 /* The toplevel is "attached" to another widget */
196 guint attached : 1;
197
198 /* Hidden temporarily because the attach_toplevel was hidden */
199 guint attach_hidden : 1;
200
201 /* More saved grab op state */
202 guint orig_x_centered : 1;
203 guint orig_y_centered : 1;
204
205 /* flag to see if we have already done geometry updating,
206 if not then we're still loading and can ignore many things */
207 guint updated_geometry_initial : 1;
208 /* flag to see if we have done the initial animation */
209 guint initial_animation_done : 1;
210};
211
212enum {
213 HIDE_SIGNAL,
214 UNHIDE_SIGNAL,
215 POPUP_PANEL_MENU_SIGNAL,
216 TOGGLE_EXPAND_SIGNAL,
217 EXPAND_SIGNAL,
218 UNEXPAND_SIGNAL,
219 TOGGLE_HIDDEN_SIGNAL,
220 BEGIN_MOVE_SIGNAL,
221 BEGIN_RESIZE_SIGNAL,
222 LAST_SIGNAL
223};
224
225enum {
226 PROP_0,
227 PROP_NAME,
228 PROP_SETTINGS_PATH,
229 PROP_EXPAND,
230 PROP_ORIENTATION,
231 PROP_SIZE,
232 PROP_X,
233 PROP_X_RIGHT,
234 PROP_X_CENTERED,
235 PROP_Y,
236 PROP_Y_BOTTOM,
237 PROP_Y_CENTERED,
238 PROP_MONITOR,
239 PROP_AUTOHIDE,
240 PROP_HIDE_DELAY,
241 PROP_UNHIDE_DELAY,
242 PROP_AUTOHIDE_SIZE,
243 PROP_ANIMATE,
244 PROP_ANIMATION_SPEED,
245 PROP_BUTTONS_ENABLED,
246 PROP_ARROWS_ENABLED
247};
248
249G_DEFINE_TYPE_WITH_PRIVATE (PanelToplevel, panel_toplevel, GTK_TYPE_WINDOW)static void panel_toplevel_init (PanelToplevel *self); static
void panel_toplevel_class_init (PanelToplevelClass *klass); static
GType panel_toplevel_get_type_once (void); static gpointer panel_toplevel_parent_class
= ((void*)0); static gint PanelToplevel_private_offset; static
void panel_toplevel_class_intern_init (gpointer klass) { panel_toplevel_parent_class
= g_type_class_peek_parent (klass); if (PanelToplevel_private_offset
!= 0) g_type_class_adjust_private_offset (klass, &PanelToplevel_private_offset
); panel_toplevel_class_init ((PanelToplevelClass*) klass); }
__attribute__ ((__unused__)) static inline gpointer panel_toplevel_get_instance_private
(PanelToplevel *self) { return (((gpointer) ((guint8*) (self
) + (glong) (PanelToplevel_private_offset)))); } GType panel_toplevel_get_type
(void) { static GType static_g_define_type_id = 0; if ((__extension__
({ _Static_assert (sizeof *(&static_g_define_type_id) ==
sizeof (gpointer), "Expression evaluates to false"); (void) (
0 ? (gpointer) * (&static_g_define_type_id) : ((void*)0))
; (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter_pointer (
&static_g_define_type_id)); })) ) { GType g_define_type_id
= panel_toplevel_get_type_once (); (__extension__ ({ _Static_assert
(sizeof *(&static_g_define_type_id) == sizeof (gpointer)
, "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id
) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer
((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id
)); })) ; } return static_g_define_type_id; } __attribute__ (
(__noinline__)) static GType panel_toplevel_get_type_once (void
) { GType g_define_type_id = g_type_register_static_simple ((
gtk_window_get_type ()), g_intern_static_string ("PanelToplevel"
), sizeof (PanelToplevelClass), (GClassInitFunc)(void (*)(void
)) panel_toplevel_class_intern_init, sizeof (PanelToplevel), (
GInstanceInitFunc)(void (*)(void)) panel_toplevel_init, (GTypeFlags
) 0); { {{ PanelToplevel_private_offset = g_type_add_instance_private
(g_define_type_id, sizeof (PanelToplevelPrivate)); };} } return
g_define_type_id; }
250
251static guint toplevel_signals[LAST_SIGNAL] = {0};
252static GSList* toplevel_list = NULL((void*)0);
253
254static void panel_toplevel_calculate_animation_end_geometry(PanelToplevel *toplevel);
255
256static void panel_toplevel_update_monitor(PanelToplevel* toplevel);
257static void panel_toplevel_set_monitor_internal(PanelToplevel* toplevel, int monitor, gboolean force_resize);
258
259static void panel_toplevel_drag_threshold_changed (PanelToplevel *toplevel);
260
261static void
262update_style_classes (PanelToplevel *toplevel)
263{
264 GtkStyleContext *context;
265
266 context = gtk_widget_get_style_context (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
267
268 /*ensure the panel BG can always be themed*/
269 /*Without this gtk3.19/20 cannot set the BG color and resetting the bg to system is not immediately applied*/
270 gtk_style_context_add_class(context,"gnome-panel-menu-bar");
271 gtk_style_context_add_class(context,"mate-panel-menu-bar");
272
273 gtk_style_context_remove_class (context, GTK_STYLE_CLASS_HORIZONTAL"horizontal");
274 gtk_style_context_remove_class (context, GTK_STYLE_CLASS_VERTICAL"vertical");
275 gtk_style_context_remove_class (context, GTK_STYLE_CLASS_RIGHT"right");
276 gtk_style_context_remove_class (context, GTK_STYLE_CLASS_LEFT"left");
277 gtk_style_context_remove_class (context, GTK_STYLE_CLASS_TOP"top");
278 gtk_style_context_remove_class (context, GTK_STYLE_CLASS_BOTTOM"bottom");
279
280 switch (toplevel->priv->orientation) {
281 case PANEL_ORIENTATION_TOP:
282 gtk_style_context_add_class (context, GTK_STYLE_CLASS_HORIZONTAL"horizontal");
283 gtk_style_context_add_class (context, GTK_STYLE_CLASS_TOP"top");
284 break;
285
286 case PANEL_ORIENTATION_LEFT:
287 gtk_style_context_add_class (context, GTK_STYLE_CLASS_VERTICAL"vertical");
288 gtk_style_context_add_class (context, GTK_STYLE_CLASS_LEFT"left");
289 break;
290
291 case PANEL_ORIENTATION_BOTTOM:
292 gtk_style_context_add_class (context, GTK_STYLE_CLASS_HORIZONTAL"horizontal");
293 gtk_style_context_add_class (context, GTK_STYLE_CLASS_BOTTOM"bottom");
294 break;
295
296 case PANEL_ORIENTATION_RIGHT:
297 gtk_style_context_add_class (context, GTK_STYLE_CLASS_VERTICAL"vertical");
298 gtk_style_context_add_class (context, GTK_STYLE_CLASS_RIGHT"right");
299 break;
300
301 default:
302 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 302, ((const char*) (__func__)), ((void*)0)); } while (0)
;
303 break;
304 }
305}
306
307GSList* panel_toplevel_list_toplevels(void)
308{
309 return toplevel_list;
310}
311
312/* Is this the last un-attached toplevel? */
313gboolean panel_toplevel_is_last_unattached(PanelToplevel* toplevel)
314{
315 GSList* l;
316
317 if (panel_toplevel_get_is_attached(toplevel))
318 {
319 return FALSE(0);
320 }
321
322 for (l = toplevel_list; l; l = l->next)
323 {
324 PanelToplevel* t = l->data;
325
326 if (t != toplevel && !panel_toplevel_get_is_attached(t))
327 {
328 return FALSE(0);
329 }
330 }
331
332 return TRUE(!(0));
333}
334
335static void panel_toplevel_get_monitor_geometry(PanelToplevel* toplevel, GdkRectangle *geom)
336{
337 g_return_if_fail(PANEL_IS_TOPLEVEL(toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL(toplevel)"); return; } } while
(0)
;
338 g_return_if_fail(geom)do { if ((geom)) { } else { g_return_if_fail_warning (((gchar
*) 0), ((const char*) (__func__)), "geom"); return; } } while
(0)
;
339
340 geom->x = panel_multimonitor_x(toplevel->priv->monitor);
341 geom->y = panel_multimonitor_y(toplevel->priv->monitor);
342 geom->width = panel_multimonitor_width(toplevel->priv->monitor);
343 geom->height = panel_multimonitor_height(toplevel->priv->monitor);
344}
345
346static GdkCursorType panel_toplevel_grab_op_cursor(PanelToplevel* toplevel, PanelGrabOpType grab_op)
347{
348 GdkCursorType retval = -1;
349
350 switch (grab_op) {
351 case PANEL_GRAB_OP_MOVE:
352 case PANEL_GRAB_OP_RESIZE:
353 if (toplevel->priv->grab_is_keyboard)
354 retval = GDK_CROSS;
355 else
356 retval = GDK_FLEUR;
357 break;
358 case PANEL_GRAB_OP_RESIZE_UP:
359 retval = GDK_TOP_SIDE;
360 break;
361 case PANEL_GRAB_OP_RESIZE_DOWN:
362 retval = GDK_BOTTOM_SIDE;
363 break;
364 case PANEL_GRAB_OP_RESIZE_LEFT:
365 retval = GDK_LEFT_SIDE;
366 break;
367 case PANEL_GRAB_OP_RESIZE_RIGHT:
368 retval = GDK_RIGHT_SIDE;
369 break;
370 default:
371 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 371, ((const char*) (__func__)), ((void*)0)); } while (0)
;
372 break;
373 }
374
375 return retval;
376}
377
378#ifdef HAVE_X111
379static void panel_toplevel_init_resize_drag_offsets(PanelToplevel* toplevel, PanelGrabOpType grab_op)
380{
381 g_assert (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel))))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((gtk_widget_get_display (((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((toplevel)), ((gtk_widget_get_type ()))))
))))); GType __t = ((gdk_x11_display_get_type())); gboolean __r
; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))) ; else
g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c", 381
, ((const char*) (__func__)), "GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel)))"
); } while (0)
;
382
383 toplevel->priv->drag_offset_x = 0;
384 toplevel->priv->drag_offset_y = 0;
385
386 switch (grab_op) {
387 case PANEL_GRAB_OP_RESIZE_DOWN:
388 toplevel->priv->drag_offset_y = toplevel->priv->geometry.y;
389 break;
390 case PANEL_GRAB_OP_RESIZE_UP:
391 toplevel->priv->drag_offset_y =
392 toplevel->priv->geometry.y + toplevel->priv->geometry.height;
393 break;
394 case PANEL_GRAB_OP_RESIZE_RIGHT:
395 toplevel->priv->drag_offset_x = toplevel->priv->geometry.x;
396 break;
397 case PANEL_GRAB_OP_RESIZE_LEFT:
398 toplevel->priv->drag_offset_x =
399 toplevel->priv->geometry.x + toplevel->priv->geometry.width;
400 break;
401 default:
402 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 402, ((const char*) (__func__)), ((void*)0)); } while (0)
;
403 break;
404 }
405}
406
407static void panel_toplevel_warp_pointer(PanelToplevel* toplevel)
408{
409 GtkWidget *widget;
410 GdkRectangle geometry;
411 int x, y;
412
413 widget = GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
;
414 g_return_if_fail (GDK_IS_X11_DISPLAY (gtk_widget_get_display (widget)))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((gtk_widget_get_display (widget))); GType __t = ((gdk_x11_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0
), ((const char*) (__func__)), "GDK_IS_X11_DISPLAY (gtk_widget_get_display (widget))"
); return; } } while (0)
;
415
416 geometry = toplevel->priv->geometry;
417
418 x = y = 0;
419
420 switch (toplevel->priv->grab_op) {
421 case PANEL_GRAB_OP_MOVE:
422 case PANEL_GRAB_OP_RESIZE:
423 x = (geometry.width / 2);
424 y = (geometry.height / 2);
425 break;
426 case PANEL_GRAB_OP_RESIZE_UP:
427 x = (geometry.width / 2);
428 break;
429 case PANEL_GRAB_OP_RESIZE_DOWN:
430 x = (geometry.width / 2);
431 y = geometry.height;
432 break;
433 case PANEL_GRAB_OP_RESIZE_LEFT:
434 y = (geometry.height / 2);
435 break;
436 case PANEL_GRAB_OP_RESIZE_RIGHT:
437 x = geometry.width;
438 y = (geometry.height / 2);
439 break;
440 default:
441 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 441, ((const char*) (__func__)), ((void*)0)); } while (0)
;
442 break;
443 }
444
445 if (toplevel->priv->grab_op == PANEL_GRAB_OP_MOVE ||
446 toplevel->priv->grab_op == PANEL_GRAB_OP_RESIZE) {
447 toplevel->priv->drag_offset_x = x;
448 toplevel->priv->drag_offset_y = y;
449 } else
450 panel_toplevel_init_resize_drag_offsets (toplevel, toplevel->priv->grab_op);
451
452 panel_warp_pointer (gtk_widget_get_window (widget), x, y);
453}
454#endif /* HAVE_X11 */
455
456static void panel_toplevel_begin_attached_move(PanelToplevel* toplevel, gboolean is_keyboard, guint32 time_)
457{
458 PanelWidget *attached_panel_widget;
459
460 attached_panel_widget = panel_toplevel_get_panel_widget (toplevel->priv->attach_toplevel);
461
462 panel_widget_applet_drag_start (attached_panel_widget,
463 toplevel->priv->attach_widget,
464 is_keyboard ? PW_DRAG_OFF_CENTER-2 : PW_DRAG_OFF_CURSOR-1,
465 time_);
466}
467
468static void panel_toplevel_begin_grab_op(PanelToplevel* toplevel, PanelGrabOpType op_type, gboolean grab_keyboard, guint32 time_)
469{
470 GtkWidget *widget;
471 GdkWindow *window;
472 GdkCursorType cursor_type;
473 GdkCursor *cursor;
474 GdkDisplay *display;
475 GdkSeat *seat;
476 GdkSeatCapabilities capabilities;
477
478 if (toplevel->priv->state != PANEL_STATE_NORMAL ||
479 toplevel->priv->grab_op != PANEL_GRAB_OP_NONE)
480 return;
481
482 if (panel_lockdown_get_locked_down ())
483 return;
484
485 /* If any of the position/orientation are not writable,
486 then we can't really move freely */
487 if (op_type == PANEL_GRAB_OP_MOVE &&
488 ! panel_profile_can_be_moved_freely (toplevel))
489 return;
490
491 /* If size is not writable, then we can't resize */
492 if ((op_type == PANEL_GRAB_OP_RESIZE ||
493 op_type == PANEL_GRAB_OP_RESIZE_UP ||
494 op_type == PANEL_GRAB_OP_RESIZE_DOWN ||
495 op_type == PANEL_GRAB_OP_RESIZE_LEFT ||
496 op_type == PANEL_GRAB_OP_RESIZE_RIGHT) &&
497 ! panel_profile_key_is_writable (toplevel, PANEL_TOPLEVEL_SIZE_KEY"size"))
498 return;
499
500 if (toplevel->priv->attached && op_type == PANEL_GRAB_OP_MOVE) {
501 panel_toplevel_begin_attached_move (toplevel, grab_keyboard, time_);
502 return;
503 }
504
505 widget = GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
;
506 window = gtk_widget_get_window (widget);
507
508 toplevel->priv->grab_op = op_type;
509 toplevel->priv->grab_is_keyboard = (grab_keyboard != FALSE(0));
510
511 toplevel->priv->orig_monitor = toplevel->priv->monitor;
512 toplevel->priv->orig_x = toplevel->priv->x;
513 toplevel->priv->orig_x_right = toplevel->priv->x_right;
514 toplevel->priv->orig_x_centered = toplevel->priv->x_centered;
515 toplevel->priv->orig_y = toplevel->priv->y;
516 toplevel->priv->orig_y_bottom = toplevel->priv->y_bottom;
517 toplevel->priv->orig_y_centered = toplevel->priv->y_centered;
518 toplevel->priv->orig_size = toplevel->priv->size;
519 toplevel->priv->orig_orientation = toplevel->priv->orientation;
520
521 gtk_grab_add (widget);
522
523#ifdef HAVE_X111
524 if (GDK_IS_X11_DISPLAY (gtk_widget_get_display (widget))(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gtk_widget_get_display (widget))); GType __t = ((gdk_x11_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
&&
525 toplevel->priv->grab_is_keyboard) {
526 panel_toplevel_warp_pointer (toplevel);
527 }
528#endif /* HAVE_X11 */
529
530 cursor_type = panel_toplevel_grab_op_cursor (
531 toplevel, toplevel->priv->grab_op);
532
533 cursor = gdk_cursor_new_for_display (gdk_display_get_default (),
534 cursor_type);
535 display = gdk_window_get_display (window);
536 seat = gdk_display_get_default_seat (display);
537 capabilities = GDK_SEAT_CAPABILITY_POINTER;
538 if (grab_keyboard)
539 capabilities |= GDK_SEAT_CAPABILITY_KEYBOARD;
540
541 gdk_seat_grab (seat, window, capabilities, FALSE(0), cursor,
542 NULL((void*)0), NULL((void*)0), NULL((void*)0));
543
544 g_object_unref (cursor);
545}
546
547static void panel_toplevel_end_grab_op (PanelToplevel* toplevel, guint32 time_)
548{
549 GtkWidget *widget;
550 GdkDisplay *display;
551 GdkSeat *seat;
552
553 g_return_if_fail (toplevel->priv->grab_op != PANEL_GRAB_OP_NONE)do { if ((toplevel->priv->grab_op != PANEL_GRAB_OP_NONE
)) { } else { g_return_if_fail_warning (((gchar*) 0), ((const
char*) (__func__)), "toplevel->priv->grab_op != PANEL_GRAB_OP_NONE"
); return; } } while (0)
;
554
555 widget = GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
;
556
557 toplevel->priv->grab_op = PANEL_GRAB_OP_NONE;
558 toplevel->priv->grab_is_keyboard = FALSE(0);
559
560 gtk_grab_remove (widget);
561
562 display = gtk_widget_get_display (widget);
563 seat = gdk_display_get_default_seat (display);
564
565 gdk_seat_ungrab (seat);
566}
567
568static void panel_toplevel_cancel_grab_op(PanelToplevel* toplevel, guint32 time_)
569{
570 panel_toplevel_set_orientation (toplevel, toplevel->priv->orig_orientation);
571 panel_toplevel_set_monitor (toplevel, toplevel->priv->orig_monitor);
572 panel_toplevel_set_size (toplevel, toplevel->priv->orig_size);
573 panel_toplevel_set_x (toplevel,
574 toplevel->priv->orig_x,
575 toplevel->priv->orig_x_right,
576 toplevel->priv->orig_x_centered);
577 panel_toplevel_set_y (toplevel,
578 toplevel->priv->orig_y,
579 toplevel->priv->orig_y_bottom,
580 toplevel->priv->orig_y_centered);
581}
582
583static void panel_toplevel_resize_to_pointer(PanelToplevel* toplevel, int x, int y)
584{
585 int new_size;
586 int new_x, new_y;
587 int new_x_right, new_y_bottom;
588 int new_x_centered, new_y_centered;
589 GdkRectangle monitor_geom;
590
591 new_size = toplevel->priv->size;
592 new_x = toplevel->priv->x;
593 new_y = toplevel->priv->y;
594 new_x_right = toplevel->priv->x_right;
595 new_y_bottom = toplevel->priv->y_bottom;
596 new_x_centered = toplevel->priv->x_centered;
597 new_y_centered = toplevel->priv->y_centered;
598
599 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
600
601 switch (toplevel->priv->grab_op) {
602 case PANEL_GRAB_OP_RESIZE_UP:
603 new_size = toplevel->priv->drag_offset_y - y;
604 new_size = CLAMP (new_size, 0, monitor_geom.height / 4)(((new_size) > (monitor_geom.height / 4)) ? (monitor_geom.
height / 4) : (((new_size) < (0)) ? (0) : (new_size)))
;
605 new_y -= (new_size - toplevel->priv->size);
606 if (!toplevel->priv->y_centered && (new_y + new_size / 2) > monitor_geom.height / 2)
607 new_y_bottom = monitor_geom.height - (new_y + new_size);
608 else
609 new_y_bottom = -1;
610 break;
611 case PANEL_GRAB_OP_RESIZE_DOWN:
612 new_size = y - toplevel->priv->drag_offset_y;
613 new_size = CLAMP (new_size, 0, monitor_geom.height / 4)(((new_size) > (monitor_geom.height / 4)) ? (monitor_geom.
height / 4) : (((new_size) < (0)) ? (0) : (new_size)))
;
614 if (!toplevel->priv->y_centered && (new_y + new_size / 2) > monitor_geom.height / 2)
615 new_y_bottom = monitor_geom.height - (new_y + new_size);
616 else
617 new_y_bottom = -1;
618 break;
619 case PANEL_GRAB_OP_RESIZE_LEFT:
620 new_size = toplevel->priv->drag_offset_x - x;
621 new_size = CLAMP (new_size, 0, monitor_geom.width / 4)(((new_size) > (monitor_geom.width / 4)) ? (monitor_geom.width
/ 4) : (((new_size) < (0)) ? (0) : (new_size)))
;
622 new_x -= (new_size - toplevel->priv->size);
623 if (!toplevel->priv->x_centered && (new_x + new_size / 2) > monitor_geom.width / 2)
624 new_x_right = monitor_geom.width - (new_x + new_size);
625 else
626 new_x_right = -1;
627 break;
628 case PANEL_GRAB_OP_RESIZE_RIGHT:
629 new_size = x - toplevel->priv->drag_offset_x;
630 new_size = CLAMP (new_size, 0, monitor_geom.width / 4)(((new_size) > (monitor_geom.width / 4)) ? (monitor_geom.width
/ 4) : (((new_size) < (0)) ? (0) : (new_size)))
;
631 if (!toplevel->priv->x_centered && (new_x + new_size / 2) > monitor_geom.width / 2)
632 new_x_right = monitor_geom.width - (new_x + new_size);
633 else
634 new_x_right = -1;
635 break;
636 default:
637 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 637, ((const char*) (__func__)), ((void*)0)); } while (0)
;
638 break;
639 }
640
641 if (new_size == 0)
642 return;
643
644 panel_toplevel_set_x (toplevel, new_x, new_x_right, new_x_centered);
645 panel_toplevel_set_y (toplevel, new_y, new_y_bottom, new_y_centered);
646 panel_toplevel_set_size (toplevel, new_size);
647}
648
649/* this is called for expanded panels that are dragged around */
650static void panel_toplevel_calc_new_orientation(PanelToplevel* toplevel, int pointer_x, int pointer_y)
651{
652 PanelOrientation new_orientation;
653 int hborder, vborder;
654 int monitor;
655 int monitor_width, monitor_height;
656 int new_x, new_y;
657
658 monitor = panel_multimonitor_get_monitor_at_point (pointer_x, pointer_y);
659
660 if (toplevel->priv->geometry.height < toplevel->priv->geometry.width)
661 vborder = hborder = (3 * toplevel->priv->geometry.height) >> 1;
662 else
663 vborder = hborder = (3 * toplevel->priv->geometry.width) >> 1;
664
665 new_x = pointer_x - panel_multimonitor_x (monitor);
666 new_y = pointer_y - panel_multimonitor_y (monitor);
667 monitor_width = panel_multimonitor_width (monitor);
668 monitor_height = panel_multimonitor_height (monitor);
669
670 new_orientation = toplevel->priv->orientation;
671
672 switch (toplevel->priv->orientation) {
673 case PANEL_ORIENTATION_TOP:
674 if (new_y > (monitor_height - hborder))
675 new_orientation = PANEL_ORIENTATION_BOTTOM;
676
677 else if (new_y > hborder) {
678 if (new_x > (monitor_width - vborder))
679 new_orientation = PANEL_ORIENTATION_RIGHT;
680 else if (new_x < vborder)
681 new_orientation = PANEL_ORIENTATION_LEFT;
682 }
683 break;
684 case PANEL_ORIENTATION_BOTTOM:
685 if (new_y < hborder)
686 new_orientation = PANEL_ORIENTATION_TOP;
687
688 else if (new_y < (monitor_height - hborder)) {
689 if (new_x > (monitor_width - vborder))
690 new_orientation = PANEL_ORIENTATION_RIGHT;
691 else if (new_x < vborder)
692 new_orientation = PANEL_ORIENTATION_LEFT;
693 }
694 break;
695 case PANEL_ORIENTATION_LEFT:
696 if (new_x > (monitor_width - vborder))
697 new_orientation = PANEL_ORIENTATION_RIGHT;
698
699 else if (new_x > vborder) {
700 if (new_y > (monitor_height - hborder))
701 new_orientation = PANEL_ORIENTATION_BOTTOM;
702 else if (new_y < hborder)
703 new_orientation = PANEL_ORIENTATION_TOP;
704 }
705 break;
706 case PANEL_ORIENTATION_RIGHT:
707 if (new_x < vborder)
708 new_orientation = PANEL_ORIENTATION_LEFT;
709
710 else if (new_x < (monitor_width - vborder)) {
711 if (new_y > (monitor_height - hborder))
712 new_orientation = PANEL_ORIENTATION_BOTTOM;
713 else if (new_y < hborder)
714 new_orientation = PANEL_ORIENTATION_TOP;
715 }
716 break;
717 default:
718 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 718, ((const char*) (__func__)), ((void*)0)); } while (0)
;
719 break;
720 }
721
722 panel_toplevel_set_monitor (toplevel, monitor);
723 panel_toplevel_set_orientation (toplevel, new_orientation);
724}
725
726static void panel_toplevel_move_to(PanelToplevel* toplevel, int new_x, int new_y)
727{
728 PanelOrientation new_orientation;
729 gboolean x_centered, y_centered;
730 GdkPoint display_min, display_max;
731 GdkRectangle monitor_geom;
732 int width, height;
733 int new_monitor;
734 int x, y, x_right, y_bottom;
735 int snap_tolerance;
736
737 panel_multimonitor_get_bounds (&display_min, &display_max);
738
739 width = toplevel->priv->geometry.width;
740 height = toplevel->priv->geometry.height;
741
742 snap_tolerance = toplevel->priv->snap_tolerance;
743
744 new_x = CLAMP (new_x, 0, display_max.x - width)(((new_x) > (display_max.x - width)) ? (display_max.x - width
) : (((new_x) < (0)) ? (0) : (new_x)))
;
745 new_y = CLAMP (new_y, 0, display_max.y - height)(((new_y) > (display_max.y - height)) ? (display_max.y - height
) : (((new_y) < (0)) ? (0) : (new_y)))
;
746
747 new_orientation = toplevel->priv->orientation;
748
749 if (new_x <= (display_min.x + snap_tolerance) &&
750 toplevel->priv->orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT))
751 new_orientation = PANEL_ORIENTATION_LEFT;
752
753 else if ((new_x + width) >= (display_max.x - snap_tolerance) &&
754 toplevel->priv->orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT))
755 new_orientation = PANEL_ORIENTATION_RIGHT;
756
757 if (new_y <= (display_min.y + snap_tolerance) &&
758 toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM))
759 new_orientation = PANEL_ORIENTATION_TOP;
760
761 else if ((new_y + height) >= (display_max.y - snap_tolerance) &&
762 toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM))
763 new_orientation = PANEL_ORIENTATION_BOTTOM;
764
765 new_monitor = panel_multimonitor_get_monitor_at_point (new_x, new_y);
766
767 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
768
769 x_centered = toplevel->priv->x_centered;
770 y_centered = toplevel->priv->y_centered;
771
772 x = new_x - panel_multimonitor_x (new_monitor);
773 y = new_y - panel_multimonitor_y (new_monitor);
774
775 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)) {
776 if (new_y <= display_min.y + snap_tolerance ||
777 new_y + height >= display_max.y - snap_tolerance)
778 x_centered = abs (x - ((monitor_geom.width - width) / 2))
779 <= snap_tolerance;
780 else
781 x_centered = FALSE(0);
782 } else {
783 if (new_x <= display_min.x + snap_tolerance ||
784 new_x + width >= display_max.x - snap_tolerance)
785 y_centered = abs (y - ((monitor_geom.height - height) / 2))
786 <= snap_tolerance;
787 else
788 y_centered = FALSE(0);
789 }
790
791 if (x_centered)
792 x = (monitor_geom.width - width) / 2;
793 if (y_centered)
794 y = (monitor_geom.height - height) / 2;
795
796 if (!x_centered && (x + width / 2) > monitor_geom.width / 2)
797 x_right = monitor_geom.width - (x + width);
798 else
799 x_right = -1;
800
801 if (!y_centered && (y + height / 2) > monitor_geom.height / 2)
802 y_bottom = monitor_geom.height - (y + height);
803 else
804 y_bottom = -1;
805
806 panel_toplevel_set_monitor (toplevel, new_monitor);
807 panel_toplevel_set_orientation (toplevel, new_orientation);
808 panel_toplevel_set_x (toplevel, x, x_right, x_centered);
809 panel_toplevel_set_y (toplevel, y, y_bottom, y_centered);
810}
811
812static void panel_toplevel_move_to_pointer(PanelToplevel* toplevel, int pointer_x, int pointer_y)
813{
814 int new_x, new_y;
815
816 new_x = pointer_x - toplevel->priv->drag_offset_x;
817 new_y = pointer_y - toplevel->priv->drag_offset_y;
818
819 panel_toplevel_move_to (toplevel, new_x, new_y);
820}
821
822static void panel_toplevel_rotate_to_pointer(PanelToplevel* toplevel, int pointer_x, int pointer_y)
823{
824 int x_diff, y_diff;
825 int x, y;
826 int snap_tolerance;
827
828 x = toplevel->priv->geometry.x;
829 y = toplevel->priv->geometry.y;
830 snap_tolerance = toplevel->priv->snap_tolerance;
831
832 x_diff = pointer_x - (x + toplevel->priv->geometry.width / 2);
833 y_diff = pointer_y - (y + toplevel->priv->geometry.height / 2);
834
835 if (((-y_diff > x_diff + snap_tolerance) && x_diff > 0 && y_diff < 0) ||
836 (( y_diff < x_diff + snap_tolerance) && x_diff < 0 && y_diff < 0))
837 panel_toplevel_set_orientation (toplevel, PANEL_ORIENTATION_RIGHT);
838
839 else if (((-x_diff < y_diff - snap_tolerance) && x_diff > 0 && y_diff < 0) ||
840 (( x_diff > y_diff - snap_tolerance) && x_diff > 0 && y_diff > 0))
841 panel_toplevel_set_orientation (toplevel, PANEL_ORIENTATION_BOTTOM);
842
843 else if ((( y_diff > x_diff + snap_tolerance) && x_diff > 0 && y_diff > 0) ||
844 ((-y_diff < x_diff + snap_tolerance) && x_diff < 0 && y_diff > 0))
845 panel_toplevel_set_orientation (toplevel, PANEL_ORIENTATION_LEFT);
846
847 else if (((-x_diff > y_diff - snap_tolerance) && x_diff < 0 && y_diff > 0) ||
848 (( x_diff < y_diff - snap_tolerance) && x_diff < 0 && y_diff < 0))
849 panel_toplevel_set_orientation (toplevel, PANEL_ORIENTATION_TOP);
850}
851
852#ifdef HAVE_X111
853static gboolean panel_toplevel_warp_pointer_increment(PanelToplevel* toplevel, int keyval, int increment)
854{
855 GdkScreen *screen;
856 GdkWindow *root_window;
857 GdkDevice *device;
858 int new_x, new_y;
859
860 screen = gtk_window_get_screen (GTK_WINDOW (toplevel)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_window_get_type ()))))))
);
861 g_return_val_if_fail (GDK_IS_X11_SCREEN (screen), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((screen)); GType __t = ((gdk_x11_screen_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "GDK_IS_X11_SCREEN (screen)"); return ((0)); }
} while (0)
;
862 root_window = gdk_screen_get_root_window (screen);
863 device = gdk_seat_get_pointer (gdk_display_get_default_seat (gtk_widget_get_display (GTK_WIDGET(root_window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((root_window)), ((gtk_widget_get_type ()))))))
)));
864 gdk_window_get_device_position (gtk_widget_get_window (GTK_WIDGET (root_window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((root_window)), ((gtk_widget_get_type ()))))))
), device, &new_x, &new_y, NULL((void*)0));
865
866 switch (keyval) {
867 case GDK_KEY_Up0xff52:
868 case GDK_KEY_KP_Up0xff97:
869 new_y -= increment;
870 break;
871 case GDK_KEY_Left0xff51:
872 case GDK_KEY_KP_Left0xff96:
873 new_x -= increment;
874 break;
875 case GDK_KEY_Down0xff54:
876 case GDK_KEY_KP_Down0xff99:
877 new_y += increment;
878 break;
879 case GDK_KEY_Right0xff53:
880 case GDK_KEY_KP_Right0xff98:
881 new_x += increment;
882 break;
883 default:
884 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 884, ((const char*) (__func__)), ((void*)0)); } while (0)
;
885 return FALSE(0);
886 }
887
888 panel_warp_pointer (root_window, new_x, new_y);
889
890 return TRUE(!(0));
891}
892
893static gboolean panel_toplevel_move_keyboard_floating(PanelToplevel* toplevel, GdkEventKey* event)
894{
895#define SMALL_INCREMENT 1
896#define NORMAL_INCREMENT 10
897
898 int increment = NORMAL_INCREMENT;
899
900 if ((event->state & gtk_accelerator_get_default_mod_mask ()) == GDK_SHIFT_MASK)
901 increment = SMALL_INCREMENT;
902
903 return panel_toplevel_warp_pointer_increment (
904 toplevel, event->keyval, increment);
905
906#undef SMALL_INCREMENT
907#undef NORMAL_INCREMENT
908}
909
910#endif /* HAVE_X11 */
911
912static gboolean panel_toplevel_move_keyboard_expanded(PanelToplevel* toplevel, GdkEventKey* event)
913{
914 PanelOrientation new_orientation;
915
916 switch (event->keyval) {
917 case GDK_KEY_Up0xff52:
918 case GDK_KEY_KP_Up0xff97:
919 new_orientation = PANEL_ORIENTATION_TOP;
920 break;
921 case GDK_KEY_Left0xff51:
922 case GDK_KEY_KP_Left0xff96:
923 new_orientation = PANEL_ORIENTATION_LEFT;
924 break;
925 case GDK_KEY_Down0xff54:
926 case GDK_KEY_KP_Down0xff99:
927 new_orientation = PANEL_ORIENTATION_BOTTOM;
928 break;
929 case GDK_KEY_Right0xff53:
930 case GDK_KEY_KP_Right0xff98:
931 new_orientation = PANEL_ORIENTATION_RIGHT;
932 break;
933 default:
934 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 934, ((const char*) (__func__)), ((void*)0)); } while (0)
;
935 return FALSE(0);
936 }
937
938 panel_toplevel_set_orientation (toplevel, new_orientation);
939
940 return TRUE(!(0));
941}
942
943static gboolean panel_toplevel_initial_resize_keypress(PanelToplevel* toplevel, GdkEventKey* event)
944{
945 PanelGrabOpType grab_op;
946
947 switch (event->keyval) {
948 case GDK_KEY_Up0xff52:
949 case GDK_KEY_KP_Up0xff97:
950 if (!(toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)))
951 return FALSE(0);
952 grab_op = PANEL_GRAB_OP_RESIZE_UP;
953 break;
954 case GDK_KEY_Left0xff51:
955 case GDK_KEY_KP_Left0xff96:
956 if (!(toplevel->priv->orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT)))
957 return FALSE(0);
958 grab_op = PANEL_GRAB_OP_RESIZE_LEFT;
959 break;
960 case GDK_KEY_Down0xff54:
961 case GDK_KEY_KP_Down0xff99:
962 if (!(toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)))
963 return FALSE(0);
964 grab_op = PANEL_GRAB_OP_RESIZE_DOWN;
965 break;
966 case GDK_KEY_Right0xff53:
967 case GDK_KEY_KP_Right0xff98:
968 if (!(toplevel->priv->orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT)))
969 return FALSE(0);
970 grab_op = PANEL_GRAB_OP_RESIZE_RIGHT;
971 break;
972 default:
973 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 973, ((const char*) (__func__)), ((void*)0)); } while (0)
;
974 return FALSE(0);
975 }
976
977 panel_toplevel_end_grab_op (toplevel, event->time);
978 panel_toplevel_begin_grab_op (toplevel, grab_op, TRUE(!(0)), event->time);
979
980 return TRUE(!(0));
981}
982
983static gboolean panel_toplevel_handle_grab_op_key_event(PanelToplevel* toplevel, GdkEventKey* event)
984{
985 gboolean retval = FALSE(0);
986
987 switch (event->keyval) {
988 case GDK_KEY_Up0xff52:
989 case GDK_KEY_KP_Up0xff97:
990 case GDK_KEY_Left0xff51:
991 case GDK_KEY_KP_Left0xff96:
992 case GDK_KEY_Down0xff54:
993 case GDK_KEY_KP_Down0xff99:
994 case GDK_KEY_Right0xff53:
995 case GDK_KEY_KP_Right0xff98:
996 switch (toplevel->priv->grab_op) {
997 case PANEL_GRAB_OP_MOVE:
998 if (toplevel->priv->expand) {
999 retval = panel_toplevel_move_keyboard_expanded (
1000 toplevel, event);
1001 }
1002#ifdef HAVE_X111
1003 else if (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel)))(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gtk_widget_get_display (((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((toplevel)), ((gtk_widget_get_type ()))))
))))); GType __t = ((gdk_x11_display_get_type())); gboolean __r
; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
) {
1004 retval = panel_toplevel_move_keyboard_floating (
1005 toplevel, event);
1006 }
1007#endif /* HAVE_X11 */
1008 break;
1009 case PANEL_GRAB_OP_RESIZE:
1010 retval = panel_toplevel_initial_resize_keypress (toplevel, event);
1011 break;
1012 case PANEL_GRAB_OP_RESIZE_UP:
1013 case PANEL_GRAB_OP_RESIZE_DOWN:
1014 case PANEL_GRAB_OP_RESIZE_LEFT:
1015 case PANEL_GRAB_OP_RESIZE_RIGHT:
1016#ifdef HAVE_X111
1017 if (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel)))(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gtk_widget_get_display (((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((toplevel)), ((gtk_widget_get_type ()))))
))))); GType __t = ((gdk_x11_display_get_type())); gboolean __r
; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
)
1018 retval = panel_toplevel_warp_pointer_increment (toplevel, event->keyval, 1);
1019#endif /* HAVE_X11 */
1020 break;
1021 default:
1022 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 1022, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1023 break;
1024 }
1025 break;
1026 case GDK_KEY_Escape0xff1b:
1027 panel_toplevel_cancel_grab_op (toplevel, event->time);
1028 case GDK_KEY_Return0xff0d: /* drop through*/
1029 case GDK_KEY_KP_Enter0xff8d:
1030 case GDK_KEY_space0x020:
1031 case GDK_KEY_KP_Space0xff80:
1032 panel_toplevel_end_grab_op (toplevel, event->time);
1033 retval = TRUE(!(0));
1034 default: /* drop through*/
1035 break;
1036 }
1037
1038 return retval;
1039}
1040
1041static gboolean panel_toplevel_handle_grab_op_motion_event(PanelToplevel* toplevel, GdkEventMotion* event)
1042{
1043 switch (toplevel->priv->grab_op) {
1044 case PANEL_GRAB_OP_MOVE:
1045 if (toplevel->priv->expand)
1046 panel_toplevel_calc_new_orientation (
1047 toplevel, event->x_root, event->y_root);
1048
1049 else if ((event->state & gtk_accelerator_get_default_mod_mask ()) == GDK_CONTROL_MASK)
1050 panel_toplevel_rotate_to_pointer (
1051 toplevel, event->x_root, event->y_root);
1052
1053 else
1054 panel_toplevel_move_to_pointer (
1055 toplevel, event->x_root, event->y_root);
1056 return TRUE(!(0));
1057 case PANEL_GRAB_OP_RESIZE_UP:
1058 case PANEL_GRAB_OP_RESIZE_DOWN:
1059 case PANEL_GRAB_OP_RESIZE_LEFT:
1060 case PANEL_GRAB_OP_RESIZE_RIGHT:
1061 panel_toplevel_resize_to_pointer (toplevel, event->x_root, event->y_root);
1062 return TRUE(!(0));
1063 default:
1064 break;
1065 }
1066
1067 return FALSE(0);
1068}
1069
1070static void panel_toplevel_calc_floating(PanelToplevel* toplevel)
1071{
1072 GdkRectangle monitor_geom;
1073 GdkPoint position_on_monitor;
1074 int snap_tolerance;
1075
1076 if (toplevel->priv->expand) {
1077 toplevel->priv->floating = FALSE(0);
1078 return;
1079 }
1080
1081 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
1082
1083 if (toplevel->priv->x_right == -1)
1084 position_on_monitor.x = toplevel->priv->x;
1085 else
1086 position_on_monitor.x = monitor_geom.width - (toplevel->priv->x_right + toplevel->priv->geometry.width);
1087 if (toplevel->priv->y_bottom == -1)
1088 position_on_monitor.y = toplevel->priv->y;
1089 else
1090 position_on_monitor.y = monitor_geom.height - (toplevel->priv->y_bottom + toplevel->priv->geometry.height);
1091
1092 snap_tolerance = toplevel->priv->snap_tolerance;
1093
1094 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM))
1095 toplevel->priv->floating =
1096 (position_on_monitor.y > snap_tolerance) &&
1097 (position_on_monitor.y < (monitor_geom.height - toplevel->priv->geometry.height - snap_tolerance));
1098 else
1099 toplevel->priv->floating =
1100 (position_on_monitor.x > snap_tolerance) &&
1101 (position_on_monitor.x < (monitor_geom.width - toplevel->priv->geometry.width - snap_tolerance));
1102}
1103
1104void panel_toplevel_push_autohide_disabler(PanelToplevel* toplevel)
1105{
1106 g_return_if_fail (toplevel != NULL)do { if ((toplevel != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "toplevel != NULL"
); return; } } while (0)
;
1107
1108 if (!toplevel->priv->n_autohide_disablers++)
1109 panel_toplevel_queue_auto_hide (toplevel);
1110}
1111
1112void panel_toplevel_pop_autohide_disabler(PanelToplevel* toplevel)
1113{
1114 g_return_if_fail (toplevel != NULL)do { if ((toplevel != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "toplevel != NULL"
); return; } } while (0)
;
1115 g_return_if_fail (toplevel->priv->n_autohide_disablers > 0)do { if ((toplevel->priv->n_autohide_disablers > 0))
{ } else { g_return_if_fail_warning (((gchar*) 0), ((const char
*) (__func__)), "toplevel->priv->n_autohide_disablers > 0"
); return; } } while (0)
;
1116
1117 if (!--toplevel->priv->n_autohide_disablers)
1118 panel_toplevel_queue_auto_hide (toplevel);
1119}
1120
1121static gboolean panel_toplevel_get_autohide_disabled(PanelToplevel* toplevel)
1122{
1123 return toplevel->priv->n_autohide_disablers > 0 ? TRUE(!(0)) : FALSE(0);
1124}
1125
1126static gboolean panel_toplevel_hide_button_event(PanelToplevel* toplevel, GdkEventButton* event, GtkButton* button)
1127{
1128 if (event->button == 1)
1129 return FALSE(0);
1130
1131 return gtk_widget_event (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
, (GdkEvent *) event);
1132}
1133
1134static void panel_toplevel_hide_button_clicked(PanelToplevel* toplevel, GtkButton* button)
1135{
1136 GtkArrowType arrow_type;
1137 gboolean ltr;
1138
1139 if (toplevel->priv->animating ||
1140 toplevel->priv->state == PANEL_STATE_AUTO_HIDDEN)
1141 return;
1142
1143 ltr = gtk_widget_get_direction (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
) == GTK_TEXT_DIR_LTR;
1144 arrow_type = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button), "arrow-type"))((gint) (glong) (g_object_get_data (((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((button)), (((GType) ((20) << (2)))
))))), "arrow-type")))
;
1145
1146 if (toplevel->priv->state == PANEL_STATE_NORMAL) {
1147 GtkDirectionType direction;
1148
1149 switch (arrow_type) {
1150 case GTK_ARROW_UP:
1151 direction = GTK_DIR_UP;
1152 break;
1153 case GTK_ARROW_DOWN:
1154 direction = GTK_DIR_DOWN;
1155 break;
1156 case GTK_ARROW_LEFT:
1157 direction = ltr ? GTK_DIR_LEFT : GTK_DIR_RIGHT;
1158 break;
1159 case GTK_ARROW_RIGHT:
1160 direction = ltr ? GTK_DIR_RIGHT : GTK_DIR_LEFT;
1161 break;
1162 default:
1163 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 1163, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1164 break;
1165 }
1166
1167 panel_toplevel_hide (toplevel, FALSE(0), (gint) direction);
1168 } else
1169 panel_toplevel_unhide (toplevel);
1170}
1171
1172static void
1173set_arrow_type (GtkImage *image,
1174 GtkArrowType arrow_type)
1175{
1176 switch (arrow_type)
1177 {
1178 case GTK_ARROW_NONE:
1179 case GTK_ARROW_DOWN:
1180 gtk_image_set_from_icon_name (image, "pan-down-symbolic", GTK_ICON_SIZE_BUTTON);
1181 break;
1182 case GTK_ARROW_UP:
1183 gtk_image_set_from_icon_name (image, "pan-up-symbolic", GTK_ICON_SIZE_BUTTON);
1184 break;
1185 case GTK_ARROW_LEFT:
1186 gtk_image_set_from_icon_name (image, "pan-start-symbolic", GTK_ICON_SIZE_BUTTON);
1187 break;
1188 case GTK_ARROW_RIGHT:
1189 gtk_image_set_from_icon_name (image, "pan-end-symbolic", GTK_ICON_SIZE_BUTTON);
1190 break;
1191 }
1192}
1193
1194static GtkWidget *
1195panel_toplevel_add_hide_button (PanelToplevel *toplevel,
1196 GtkArrowType arrow_type,
1197 int left,
1198 int top)
1199{
1200
1201 GtkWidget *button;
1202 AtkObject *obj;
1203 GtkWidget *arrow;
1204
1205 button = gtk_button_new ();
1206 obj = gtk_widget_get_accessible (button);
1207 atk_object_set_name (obj, _("Hide Panel")gettext ("Hide Panel"));
1208 gtk_widget_set_can_default (button, FALSE(0));
1209
1210 arrow = gtk_image_new ();
1211 set_arrow_type (GTK_IMAGE (arrow)((((GtkImage*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((arrow)), ((gtk_image_get_type ()))))))
, arrow_type);
1212 gtk_container_add (GTK_CONTAINER (button)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), ((gtk_container_get_type ()))))))
, arrow);
1213 gtk_widget_show (arrow);
1214
1215 g_object_set_data (G_OBJECT (button)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), (((GType) ((20) << (2))))))))
,
1216 "arrow-type",
1217 GINT_TO_POINTER (arrow_type)((gpointer) (glong) (arrow_type)));
1218
1219 g_signal_connect_swapped (button, "clicked",g_signal_connect_data ((button), ("clicked"), (((GCallback) (
panel_toplevel_hide_button_clicked))), (toplevel), ((void*)0)
, G_CONNECT_SWAPPED)
1220 G_CALLBACK (panel_toplevel_hide_button_clicked), toplevel)g_signal_connect_data ((button), ("clicked"), (((GCallback) (
panel_toplevel_hide_button_clicked))), (toplevel), ((void*)0)
, G_CONNECT_SWAPPED)
;
1221 g_signal_connect_swapped (button, "button-press-event",g_signal_connect_data ((button), ("button-press-event"), (((GCallback
) (panel_toplevel_hide_button_event))), (toplevel), ((void*)0
), G_CONNECT_SWAPPED)
1222 G_CALLBACK (panel_toplevel_hide_button_event), toplevel)g_signal_connect_data ((button), ("button-press-event"), (((GCallback
) (panel_toplevel_hide_button_event))), (toplevel), ((void*)0
), G_CONNECT_SWAPPED)
;
1223 g_signal_connect_swapped (button, "button-release-event",g_signal_connect_data ((button), ("button-release-event"), ((
(GCallback) (panel_toplevel_hide_button_event))), (toplevel),
((void*)0), G_CONNECT_SWAPPED)
1224 G_CALLBACK (panel_toplevel_hide_button_event), toplevel)g_signal_connect_data ((button), ("button-release-event"), ((
(GCallback) (panel_toplevel_hide_button_event))), (toplevel),
((void*)0), G_CONNECT_SWAPPED)
;
1225
1226 gtk_grid_attach (GTK_GRID (toplevel->priv->grid)((((GtkGrid*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->grid)), ((gtk_grid_get_type ()))))
))
, button, left, top, 1, 1);
1227
1228 return button;
1229}
1230
1231static void panel_toplevel_update_buttons_showing(PanelToplevel* toplevel)
1232{
1233 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)) {
1234 gtk_widget_hide (toplevel->priv->hide_button_top);
1235 gtk_widget_hide (toplevel->priv->hide_button_bottom);
1236 gtk_widget_show (toplevel->priv->hide_button_left);
1237 gtk_widget_show (toplevel->priv->hide_button_right);
1238 } else {
1239 gtk_widget_show (toplevel->priv->hide_button_top);
1240 gtk_widget_show (toplevel->priv->hide_button_bottom);
1241 gtk_widget_hide (toplevel->priv->hide_button_left);
1242 gtk_widget_hide (toplevel->priv->hide_button_right);
1243 }
1244
1245 if (toplevel->priv->attached) {
1246 switch (panel_toplevel_get_orientation (toplevel->priv->attach_toplevel)) {
1247 case PANEL_ORIENTATION_TOP:
1248 gtk_widget_hide (toplevel->priv->hide_button_top);
1249 break;
1250 case PANEL_ORIENTATION_BOTTOM:
1251 gtk_widget_hide (toplevel->priv->hide_button_bottom);
1252 break;
1253 case PANEL_ORIENTATION_LEFT:
1254 gtk_widget_hide (toplevel->priv->hide_button_left);
1255 break;
1256 case PANEL_ORIENTATION_RIGHT:
1257 gtk_widget_hide (toplevel->priv->hide_button_right);
1258 break;
1259 default:
1260 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 1260, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1261 break;
1262 }
1263 }
1264}
1265
1266/* force set hide button size on panel size < 30px */
1267static void panel_toplevel_update_hide_buttons_size (GtkWidget *button, int panel_size)
1268{
1269 GtkCssProvider *css_provider;
1270 GtkStyleContext *context;
1271 GtkWidget *arrow;
1272 GtkSettings *settings;
1273 gchar *gtk_theme_name = NULL((void*)0);
1274
1275 context = gtk_widget_get_style_context (button);
1276 gtk_style_context_add_class (context, "panel-button");
1277
1278 /* get defaults from theme */
1279 settings = gtk_settings_get_default ();
1280 g_object_get (settings, "gtk-theme-name", &gtk_theme_name, NULL((void*)0));
1281 css_provider = gtk_css_provider_get_named (gtk_theme_name, NULL((void*)0));
1282 g_free (gtk_theme_name);
1283
1284 /* set custom css by adding our custom code to the default theme css
1285 *
1286 * NOTE that contriary to the documentation:
1287 * https://developer.gnome.org/gtk3/stable/GtkCssProvider.html#gtk-css-provider-load-from-data
1288 * the previously loaded theme is NOT cleared from the css_provider. (reason unknown)
1289 * In other words, this works exactly, how we need it here.
1290 * ALSO NOTE that using gtk_css_provider_to_string () to convert the theme css data into a string
1291 * and then adding the custom css, then adding this updated css to a css_provider
1292 * with the gtk_css_provider_load_from_data () also works,
1293 * however some themes can't be easily converted to strings, beacuse of the binary data
1294 * they contain. This causes a delay of minutes in loading the mate-panel,
1295 * and so this approach is not viable. */
1296 if (panel_size < 30) {
1297 gtk_css_provider_load_from_data (css_provider, ".panel-button {min-height: 13px; min-width: 13px; padding: 0px;}", -1, NULL((void*)0));
1298 }
1299
1300 gtk_style_context_add_provider (context, GTK_STYLE_PROVIDER (css_provider)((((GtkStyleProvider*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((css_provider)), ((gtk_style_provider_get_type
()))))))
, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION600);
1301
1302 /* get arrow image */
1303 arrow = gtk_bin_get_child (GTK_BIN (button)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), ((gtk_bin_get_type ()))))))
);
1304
1305 /* set image size */
1306 if (panel_size < 20) {
1307 gtk_image_set_pixel_size (GTK_IMAGE (arrow)((((GtkImage*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((arrow)), ((gtk_image_get_type ()))))))
, 12);
1308 } else if (panel_size < 40) {
1309 gtk_image_set_pixel_size (GTK_IMAGE (arrow)((((GtkImage*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((arrow)), ((gtk_image_get_type ()))))))
, 16);
1310 } else if (panel_size < 60) {
1311 gtk_image_set_pixel_size (GTK_IMAGE (arrow)((((GtkImage*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((arrow)), ((gtk_image_get_type ()))))))
, 22);
1312 } else {
1313 gtk_image_set_pixel_size (GTK_IMAGE (arrow)((((GtkImage*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((arrow)), ((gtk_image_get_type ()))))))
, 24);
1314 }
1315}
1316
1317static void panel_toplevel_update_hide_buttons(PanelToplevel* toplevel)
1318{
1319
1320 int panel_size = toplevel->priv->size;
1321
1322 if (toplevel->priv->buttons_enabled) {
1323 panel_toplevel_update_buttons_showing (toplevel);
1324
1325 panel_toplevel_update_hide_buttons_size (toplevel->priv->hide_button_top, panel_size);
1326 panel_toplevel_update_hide_buttons_size (toplevel->priv->hide_button_bottom, panel_size);
1327 panel_toplevel_update_hide_buttons_size (toplevel->priv->hide_button_left, panel_size);
1328 panel_toplevel_update_hide_buttons_size (toplevel->priv->hide_button_right, panel_size);
1329
1330 } else {
1331 g_object_set (
1332 G_OBJECT (toplevel->priv->hide_button_top)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->hide_button_top)), (((GType) ((20)
<< (2))))))))
,
1333 "visible", toplevel->priv->state == PANEL_STATE_HIDDEN_DOWN,
1334 NULL((void*)0));
1335 g_object_set (
1336 G_OBJECT (toplevel->priv->hide_button_bottom)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->hide_button_bottom)), (((GType) ((
20) << (2))))))))
,
1337 "visible", toplevel->priv->state == PANEL_STATE_HIDDEN_UP,
1338 NULL((void*)0));
1339 g_object_set (
1340 G_OBJECT (toplevel->priv->hide_button_left)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->hide_button_left)), (((GType) ((20
) << (2))))))))
,
1341 "visible", toplevel->priv->state == PANEL_STATE_HIDDEN_RIGHT,
1342 NULL((void*)0));
1343 g_object_set (
1344 G_OBJECT (toplevel->priv->hide_button_right)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->hide_button_right)), (((GType) ((20
) << (2))))))))
,
1345 "visible", toplevel->priv->state == PANEL_STATE_HIDDEN_LEFT,
1346 NULL((void*)0));
1347 }
1348
1349 if (toplevel->priv->arrows_enabled) {
1350
1351 gtk_widget_show (gtk_bin_get_child (GTK_BIN (toplevel->priv->hide_button_top)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->hide_button_top)), ((gtk_bin_get_type
()))))))
));
1352 gtk_widget_show (gtk_bin_get_child (GTK_BIN (toplevel->priv->hide_button_bottom)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->hide_button_bottom)), ((gtk_bin_get_type
()))))))
));
1353 gtk_widget_show (gtk_bin_get_child (GTK_BIN (toplevel->priv->hide_button_left)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->hide_button_left)), ((gtk_bin_get_type
()))))))
));
1354 gtk_widget_show (gtk_bin_get_child (GTK_BIN (toplevel->priv->hide_button_right)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->hide_button_right)), ((gtk_bin_get_type
()))))))
));
1355
1356 } else {
1357
1358 gtk_widget_hide (gtk_bin_get_child (GTK_BIN (toplevel->priv->hide_button_top)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->hide_button_top)), ((gtk_bin_get_type
()))))))
));
1359 gtk_widget_hide (gtk_bin_get_child (GTK_BIN (toplevel->priv->hide_button_bottom)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->hide_button_bottom)), ((gtk_bin_get_type
()))))))
));
1360 gtk_widget_hide (gtk_bin_get_child (GTK_BIN (toplevel->priv->hide_button_left)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->hide_button_left)), ((gtk_bin_get_type
()))))))
));
1361 gtk_widget_hide (gtk_bin_get_child (GTK_BIN (toplevel->priv->hide_button_right)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->hide_button_right)), ((gtk_bin_get_type
()))))))
));
1362 }
1363
1364 /* set size after setting the arrow */
1365 if (toplevel->priv->buttons_enabled) {
1366 int hb_size;
1367
1368 if (panel_size < 20)
1369 hb_size = 16;
1370 else if (panel_size < 40)
1371 hb_size = 20;
1372 else if (panel_size < 60)
1373 hb_size = 26;
1374 else
1375 hb_size = 30;
1376
1377 gtk_widget_set_size_request (toplevel->priv->hide_button_top, panel_size, hb_size);
1378 gtk_widget_set_size_request (toplevel->priv->hide_button_bottom, panel_size, hb_size);
1379 gtk_widget_set_size_request (toplevel->priv->hide_button_left, hb_size, panel_size);
1380 gtk_widget_set_size_request (toplevel->priv->hide_button_right, hb_size, panel_size);
1381 }
1382}
1383
1384static gboolean panel_toplevel_contains_pointer(PanelToplevel* toplevel)
1385{
1386 GdkDisplay *display;
1387 GdkScreen *screen;
1388 GtkWidget *widget;
1389 GdkSeat *seat;
1390 GdkDevice *pointer;
1391 int x, y;
1392
1393 display = gdk_display_get_default ();
1394 seat = gdk_display_get_default_seat (display);
1395 pointer = gdk_seat_get_pointer (seat);
1396 widget = GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
;
1397
1398 if (!gtk_widget_get_realized (widget))
1399 return FALSE(0);
1400
1401 screen = NULL((void*)0);
1402 x = y = -1;
1403 gdk_device_get_position (pointer, &screen, &x, &y);
1404
1405 if (screen != gtk_window_get_screen (GTK_WINDOW (toplevel)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_window_get_type ()))))))
))
1406 return FALSE(0);
1407
1408 if (x == -1 || y == -1)
1409 return FALSE(0);
1410
1411 if (x < toplevel->priv->geometry.x || x >= (toplevel->priv->geometry.x + toplevel->priv->geometry.width) ||
1412 y < toplevel->priv->geometry.y || y >= (toplevel->priv->geometry.y + toplevel->priv->geometry.height))
1413 return FALSE(0);
1414
1415 return TRUE(!(0));
1416}
1417
1418static inline int panel_toplevel_get_effective_auto_hide_size(PanelToplevel* toplevel)
1419{
1420 int size;
1421
1422 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM))
1423 size = CLAMP (toplevel->priv->auto_hide_size,(((toplevel->priv->auto_hide_size) > (toplevel->priv
->original_height / 2)) ? (toplevel->priv->original_height
/ 2) : (((toplevel->priv->auto_hide_size) < (1)) ? (
1) : (toplevel->priv->auto_hide_size)))
1424 1, toplevel->priv->original_height / 2)(((toplevel->priv->auto_hide_size) > (toplevel->priv
->original_height / 2)) ? (toplevel->priv->original_height
/ 2) : (((toplevel->priv->auto_hide_size) < (1)) ? (
1) : (toplevel->priv->auto_hide_size)))
;
1425 else
1426 size = CLAMP (toplevel->priv->auto_hide_size,(((toplevel->priv->auto_hide_size) > (toplevel->priv
->original_width / 2)) ? (toplevel->priv->original_width
/ 2) : (((toplevel->priv->auto_hide_size) < (1)) ? (
1) : (toplevel->priv->auto_hide_size)))
1427 1, toplevel->priv->original_width / 2)(((toplevel->priv->auto_hide_size) > (toplevel->priv
->original_width / 2)) ? (toplevel->priv->original_width
/ 2) : (((toplevel->priv->auto_hide_size) < (1)) ? (
1) : (toplevel->priv->auto_hide_size)))
;
1428
1429 /* paranoia */
1430 return (size <= 0) ? DEFAULT_AUTO_HIDE_SIZE1 : size;
1431}
1432
1433static gboolean panel_toplevel_update_struts(PanelToplevel* toplevel, gboolean end_of_animation)
1434{
1435 PanelOrientation orientation;
1436 gboolean geometry_changed = FALSE(0);
1437 int strut, strut_start, strut_end;
1438 int x, y, width, height;
1439 GdkRectangle monitor_geom;
1440
1441 if (!toplevel->priv->updated_geometry_initial)
1442 return FALSE(0);
1443
1444#ifdef HAVE_X111
1445 if (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel)))(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gtk_widget_get_display (((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((toplevel)), ((gtk_widget_get_type ()))))
))))); GType __t = ((gdk_x11_display_get_type())); gboolean __r
; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
&& toplevel->priv->attached) {
1446 panel_struts_unregister_strut (toplevel);
1447 panel_struts_set_window_hint (toplevel);
1448 return FALSE(0);
1449 }
1450#endif /* HAVE_X11 */
1451
1452 /* In the case of the initial animation, we really want the struts to
1453 * represent what is at the end of the animation, to avoid desktop
1454 * icons jumping around. */
1455 if (!toplevel->priv->initial_animation_done) {
1456 end_of_animation = TRUE(!(0));
1457
1458 /* We've not started the animation yet, so we have to compute
1459 * where we want to end. Note that we don't want to compute
1460 * this everytime, since the struts conflict resolution will be
1461 * overridden if we do so */
1462 if (!toplevel->priv->animating)
1463 panel_toplevel_calculate_animation_end_geometry (toplevel);
1464 }
1465
1466 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
1467
1468 if (end_of_animation) {
1469 x = toplevel->priv->animation_end_x;
1470 y = toplevel->priv->animation_end_y;
1471 x += panel_multimonitor_x (toplevel->priv->monitor);
1472 y += panel_multimonitor_y (toplevel->priv->monitor);
1473 if (toplevel->priv->animation_end_width != -1)
1474 width = toplevel->priv->animation_end_width;
1475 else
1476 width = toplevel->priv->geometry.width;
1477 if (toplevel->priv->animation_end_height != -1)
1478 height = toplevel->priv->animation_end_height;
1479 else
1480 height = toplevel->priv->geometry.height;
1481 } else {
1482 x = toplevel->priv->geometry.x;
1483 y = toplevel->priv->geometry.y;
1484 width = toplevel->priv->geometry.width;
1485 height = toplevel->priv->geometry.height;
1486 }
1487
1488 orientation = toplevel->priv->orientation;
1489
1490 strut = strut_start = strut_end = 0;
1491
1492 if (orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)) {
1493 if (y <= monitor_geom.y) {
1494 orientation = PANEL_ORIENTATION_TOP;
1495 strut = y + height - monitor_geom.y;
1496 } else if (y >= monitor_geom.y + monitor_geom.height - height) {
1497 orientation = PANEL_ORIENTATION_BOTTOM;
1498 strut = monitor_geom.y + monitor_geom.height - y;
1499 }
1500
1501 if (strut > 0) {
1502 strut_start = MAX (x, monitor_geom.x)(((x) > (monitor_geom.x)) ? (x) : (monitor_geom.x));
1503 strut_end = MIN (x + width, monitor_geom.x + monitor_geom.width)(((x + width) < (monitor_geom.x + monitor_geom.width)) ? (
x + width) : (monitor_geom.x + monitor_geom.width))
- 1;
1504 }
1505 } else {
1506 if (x <= monitor_geom.x) {
1507 orientation = PANEL_ORIENTATION_LEFT;
1508 strut = x + width - monitor_geom.x;
1509 } else if (x >= monitor_geom.x + monitor_geom.width - width) {
1510 orientation = PANEL_ORIENTATION_RIGHT;
1511 strut = monitor_geom.x + monitor_geom.width - x;
1512 }
1513
1514 if (strut > 0) {
1515 strut_start = MAX (y, monitor_geom.y)(((y) > (monitor_geom.y)) ? (y) : (monitor_geom.y));
1516 strut_end = MIN (y + height, monitor_geom.y + monitor_geom.height)(((y + height) < (monitor_geom.y + monitor_geom.height)) ?
(y + height) : (monitor_geom.y + monitor_geom.height))
- 1;
1517 }
1518 }
1519
1520 if (orientation != toplevel->priv->orientation) {
1521 toplevel->priv->orientation = orientation;
1522 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "orientation");
1523 }
1524
1525 if (toplevel->priv->auto_hide && strut > 0)
1526 strut = panel_toplevel_get_effective_auto_hide_size (toplevel);
1527
1528#ifdef HAVE_X111
1529 if (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel)))(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gtk_widget_get_display (((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((toplevel)), ((gtk_widget_get_type ()))))
))))); GType __t = ((gdk_x11_display_get_type())); gboolean __r
; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
) {
1530 if (strut > 0) {
1531 GdkScreen *screen;
1532 screen = gtk_widget_get_screen (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
1533 geometry_changed = panel_struts_register_strut (toplevel,
1534 screen,
1535 toplevel->priv->monitor,
1536 orientation,
1537 strut,
1538 strut_start,
1539 strut_end);
1540 }
1541 else {
1542 panel_struts_unregister_strut (toplevel);
1543 }
1544
1545 if (toplevel->priv->state == PANEL_STATE_NORMAL ||
1546 toplevel->priv->state == PANEL_STATE_AUTO_HIDDEN ||
1547 toplevel->priv->animating)
1548 panel_struts_set_window_hint (toplevel);
1549 else
1550 panel_struts_unset_window_hint (toplevel);
1551 }
1552#endif /* HAVE_X11 */
1553
1554#ifdef HAVE_WAYLAND1
1555 if (GDK_IS_WAYLAND_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel)))(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gtk_widget_get_display (((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((toplevel)), ((gtk_widget_get_type ()))))
))))); GType __t = ((gdk_wayland_display_get_type())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
) {
1556 wayland_panel_toplevel_update_placement (toplevel);
1557 }
1558#endif /* HAVE_WAYLAND */
1559 return geometry_changed;
1560}
1561
1562void panel_toplevel_update_edges(PanelToplevel* toplevel)
1563{
1564 GtkWidget *widget;
1565 PanelFrameEdge edges;
1566 PanelFrameEdge inner_edges;
1567 PanelFrameEdge outer_edges;
1568 GdkRectangle monitor_geom;
1569 int width, height;
1570 gboolean inner_frame = FALSE(0);
1571
1572 widget = GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
;
1573
1574 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
1575
1576 width = toplevel->priv->geometry.width;
1577 height = toplevel->priv->geometry.height;
1578
1579 edges = PANEL_EDGE_NONE;
1580
1581 /* We don't want any bevels with a color/image background */
1582 if (toplevel->priv->geometry.y > 0)
1583 edges |= PANEL_EDGE_TOP;
1584
1585 if (toplevel->priv->geometry.x > 0)
1586 edges |= PANEL_EDGE_LEFT;
1587
1588 if (toplevel->priv->geometry.y < (monitor_geom.height - height))
1589 edges |= PANEL_EDGE_BOTTOM;
1590
1591 if (toplevel->priv->geometry.x < (monitor_geom.width - width))
1592 edges |= PANEL_EDGE_RIGHT;
1593
1594 /* There is a conflict in the position algorithm when a
1595 * non-expanded centered panel is nearly the size of the
1596 * screen. This is similar to the one we have in
1597 * panel_toplevel_update_position(). A simple solution is
1598 * to keep the bevels in this case. */
1599 if (!toplevel->priv->expand &&
1600 toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM) &&
1601 toplevel->priv->x_centered)
1602 edges |= PANEL_EDGE_LEFT | PANEL_EDGE_RIGHT;
1603
1604 if (!toplevel->priv->expand &&
1605 toplevel->priv->orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT) &&
1606 toplevel->priv->y_centered)
1607 edges |= PANEL_EDGE_TOP | PANEL_EDGE_BOTTOM;
1608
1609 if (gtk_widget_get_visible (toplevel->priv->hide_button_left) ||
1610 gtk_widget_get_visible (toplevel->priv->hide_button_right)) {
1611 inner_frame = TRUE(!(0));
1612 edges |= PANEL_EDGE_LEFT | PANEL_EDGE_RIGHT;
1613 }
1614
1615 if (gtk_widget_get_visible (toplevel->priv->hide_button_top) ||
1616 gtk_widget_get_visible (toplevel->priv->hide_button_bottom)) {
1617 inner_frame = TRUE(!(0));
1618 edges |= PANEL_EDGE_TOP | PANEL_EDGE_BOTTOM;
1619 }
1620
1621 if (!inner_frame) {
1622 inner_edges = PANEL_EDGE_NONE;
1623 outer_edges = edges;
1624 } else {
1625 inner_edges = edges;
1626 outer_edges = PANEL_EDGE_NONE;
1627 }
1628
1629 panel_frame_set_edges (toplevel->priv->inner_frame, inner_edges);
1630
1631 if (toplevel->priv->edges != outer_edges) {
1632 toplevel->priv->edges = outer_edges;
1633 gtk_widget_queue_resize (widget);
1634 }
1635}
1636
1637static const char* panel_toplevel_construct_description(PanelToplevel *toplevel)
1638{
1639 if (toplevel->priv->attached)
1640 return _("Drawer")gettext ("Drawer");
1641
1642 switch (toplevel->priv->orientation) {
1643 case PANEL_ORIENTATION_TOP:
1644 /* translators: these string will be shown in MetaCity's switch window
1645 * popup when you pass the focus to a panel */
1646 return _("Top Panel")gettext ("Top Panel");
1647 case PANEL_ORIENTATION_BOTTOM:
1648 return _("Bottom Panel")gettext ("Bottom Panel");
1649 case PANEL_ORIENTATION_LEFT:
1650 return _("Left Panel")gettext ("Left Panel");
1651 case PANEL_ORIENTATION_RIGHT:
1652 return _("Right Panel")gettext ("Right Panel");
1653 }
1654
1655 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 1655, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1656 return _("Top Panel")gettext ("Top Panel");
1657}
1658
1659static void panel_toplevel_update_description(PanelToplevel* toplevel)
1660{
1661 const char *description;
1662
1663 description = panel_toplevel_construct_description (toplevel);
1664
1665 if (toplevel->priv->description &&
1666 !strcmp (toplevel->priv->description, description))
1667 return;
1668
1669 if (toplevel->priv->description)
1670 g_free (toplevel->priv->description);
1671 toplevel->priv->description = g_strdup (description)g_strdup_inline (description);
1672
1673 if (!toplevel->priv->name)
1674 gtk_window_set_title (GTK_WINDOW (toplevel)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_window_get_type ()))))))
,
1675 toplevel->priv->description);
1676
1677 panel_a11y_set_atk_name_desc (
1678 GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
,
1679 toplevel->priv->name ? toplevel->priv->name :
1680 toplevel->priv->description,
1681 toplevel->priv->description);
1682}
1683
1684static void panel_toplevel_update_attached_position(PanelToplevel* toplevel, gboolean hidden, int* x, int* y, int* w, int* h)
1685{
1686 GtkAllocation attach_allocation;
1687 PanelOrientation attach_orientation;
1688 GdkRectangle toplevel_box;
1689 GdkRectangle parent_box;
1690 GdkRectangle attach_box;
1691 int x_origin = 0, y_origin = 0;
1692 GdkRectangle monitor_geom;
1693
1694 if (!gtk_widget_get_realized (GTK_WIDGET (toplevel->priv->attach_toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->attach_toplevel)), ((gtk_widget_get_type
()))))))
) ||
1695 !gtk_widget_get_realized (toplevel->priv->attach_widget))
1696 return;
1697
1698 gtk_widget_get_allocation (GTK_WIDGET (toplevel->priv->attach_widget)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->attach_widget)), ((gtk_widget_get_type
()))))))
, &attach_allocation);
1699
1700 toplevel_box = toplevel->priv->geometry;
1701 parent_box = toplevel->priv->attach_toplevel->priv->geometry;
1702 attach_box = attach_allocation;
1703
1704 if (attach_box.x != -1) {
1705 gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (toplevel->priv->attach_widget)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->attach_widget)), ((gtk_widget_get_type
()))))))
),
1706 &x_origin, &y_origin);
1707
1708 attach_box.x += x_origin;
1709 attach_box.y += y_origin;
1710 } else {
1711 /* attach_widget isn't allocated. Put the toplevel
1712 * off screen.
1713 */
1714 attach_box.x = -toplevel_box.width;
1715 attach_box.y = -toplevel_box.height;
1716 }
1717
1718 attach_orientation = panel_toplevel_get_orientation (
1719 toplevel->priv->attach_toplevel);
1720
1721 if (attach_orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM))
1722 *x = attach_box.x + attach_box.width / 2 - toplevel_box.width / 2;
1723 else
1724 *y = attach_box.y + attach_box.height / 2 - toplevel_box.height / 2;
1725
1726 switch (attach_orientation) {
1727 case PANEL_ORIENTATION_TOP:
1728 *y = parent_box.y;
1729 if (!hidden)
1730 *y += parent_box.height;
1731 else
1732 *h = parent_box.height;
1733 break;
1734 case PANEL_ORIENTATION_BOTTOM:
1735 *y = parent_box.y;
1736 if (!hidden)
1737 *y -= toplevel_box.height;
1738 else
1739 *h = parent_box.height;
1740 break;
1741 case PANEL_ORIENTATION_LEFT:
1742 *x = parent_box.x;
1743 if (!hidden)
1744 *x += parent_box.width;
1745 else
1746 *w = parent_box.width;
1747 break;
1748 case PANEL_ORIENTATION_RIGHT:
1749 *x = parent_box.x;
1750 if (!hidden)
1751 *x -= toplevel_box.width;
1752 else
1753 *w = parent_box.width;
1754 break;
1755 default:
1756 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 1756, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1757 break;
1758 }
1759
1760 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
1761
1762 *x -= monitor_geom.x;
1763 *y -= monitor_geom.y;
1764
1765 if (toplevel->priv->orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT))
1766 *x = CLAMP (*x, 0, monitor_geom.width - toplevel->priv->original_width)(((*x) > (monitor_geom.width - toplevel->priv->original_width
)) ? (monitor_geom.width - toplevel->priv->original_width
) : (((*x) < (0)) ? (0) : (*x)))
;
1767 else
1768 *y = CLAMP (*y, 0, monitor_geom.height - toplevel->priv->original_height)(((*y) > (monitor_geom.height - toplevel->priv->original_height
)) ? (monitor_geom.height - toplevel->priv->original_height
) : (((*y) < (0)) ? (0) : (*y)))
;
1769}
1770
1771static void panel_toplevel_update_normal_position(PanelToplevel* toplevel, int* x, int* y, int* w, int* h)
1772{
1773 GdkRectangle monitor_geom;
1774 int width, height;
1775 int snap_tolerance;
1776
1777 g_assert (x != NULL && y != NULL)do { if (x != ((void*)0) && y != ((void*)0)) ; else g_assertion_message_expr
(((gchar*) 0), "panel-toplevel.c", 1777, ((const char*) (__func__
)), "x != NULL && y != NULL"); } while (0)
;
1778
1779 if (toplevel->priv->attached) {
1780 panel_toplevel_update_attached_position (toplevel, FALSE(0), x, y, w, h);
1781 return;
1782 }
1783
1784 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
1785
1786 width = toplevel->priv->original_width;
1787 height = toplevel->priv->original_height;
1788 snap_tolerance = toplevel->priv->snap_tolerance;
1789
1790 *x = CLAMP (*x, 0, monitor_geom.width - width)(((*x) > (monitor_geom.width - width)) ? (monitor_geom.width
- width) : (((*x) < (0)) ? (0) : (*x)))
;
1791 *y = CLAMP (*y, 0, monitor_geom.height - height)(((*y) > (monitor_geom.height - height)) ? (monitor_geom.height
- height) : (((*y) < (0)) ? (0) : (*y)))
;
1792
1793 if (toplevel->priv->x <= snap_tolerance &&
1794 toplevel->priv->x_right == -1 &&
1795 !toplevel->priv->x_centered)
1796 *x = 0;
1797 else if (toplevel->priv->x_right != -1 &&
1798 toplevel->priv->x_right <= snap_tolerance &&
1799 !toplevel->priv->x_centered)
1800 *x = monitor_geom.width - width;
1801
1802 if (toplevel->priv->y <= snap_tolerance &&
1803 toplevel->priv->y_bottom == -1 &&
1804 !toplevel->priv->y_centered)
1805 *y = 0;
1806 else if (toplevel->priv->y_bottom != -1 &&
1807 toplevel->priv->y_bottom <= snap_tolerance &&
1808 !toplevel->priv->y_centered)
1809 *y = monitor_geom.height - height;
1810}
1811
1812static void
1813panel_toplevel_update_auto_hide_position (PanelToplevel *toplevel,
1814 int *x,
1815 int *y,
1816 int *w,
1817 int *h,
1818 gboolean for_end_position)
1819{
1820 int width, height;
1821 GdkRectangle monitor_geom;
1822 int auto_hide_size;
1823 int snap_tolerance;
1824
1825 g_assert (x != NULL && y != NULL)do { if (x != ((void*)0) && y != ((void*)0)) ; else g_assertion_message_expr
(((gchar*) 0), "panel-toplevel.c", 1825, ((const char*) (__func__
)), "x != NULL && y != NULL"); } while (0)
;
1826
1827 if (toplevel->priv->floating) {
1828 panel_toplevel_update_normal_position (toplevel, x, y, w, h);
1829 return;
1830 }
1831
1832 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
1833
1834 width = toplevel->priv->original_width;
1835 height = toplevel->priv->original_height;
1836 snap_tolerance = toplevel->priv->snap_tolerance;
1837
1838 /* For the initial animation, we animate from outside the screen, and
1839 * so we don't want the toplevel to be visible at all. But when the
1840 * request is for the end position, then we give the real result (it's
1841 * useful for struts) */
1842 if (for_end_position || toplevel->priv->initial_animation_done) {
1843 auto_hide_size = panel_toplevel_get_effective_auto_hide_size (toplevel);
1844 } else {
1845 auto_hide_size = 0;
1846 }
1847
1848 switch (toplevel->priv->orientation) {
1849 case PANEL_ORIENTATION_TOP:
1850 *y = - (height - auto_hide_size);
1851 break;
1852 case PANEL_ORIENTATION_BOTTOM:
1853 *y = monitor_geom.height - auto_hide_size;
1854 break;
1855 case PANEL_ORIENTATION_LEFT:
1856 *x = - (width - auto_hide_size);
1857 break;
1858 case PANEL_ORIENTATION_RIGHT:
1859 *x = monitor_geom.width - auto_hide_size;
1860 break;
1861 default:
1862 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 1862, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1863 break;
1864 }
1865
1866 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)) {
1867 if (toplevel->priv->x <= snap_tolerance &&
1868 toplevel->priv->x_right == -1 &&
1869 !toplevel->priv->x_centered)
1870 *x = 0;
1871 else if (toplevel->priv->x_right != -1 &&
1872 toplevel->priv->x_right <= snap_tolerance &&
1873 !toplevel->priv->x_centered)
1874 *x = monitor_geom.width - width;
1875 } else /* if (toplevel->priv->orientation & PANEL_VERTICAL_MASK) */ {
1876 if (toplevel->priv->y <= snap_tolerance &&
1877 toplevel->priv->y_bottom == -1 &&
1878 !toplevel->priv->y_centered)
1879 *y = 0;
1880 else if (toplevel->priv->y_bottom != -1 &&
1881 toplevel->priv->y_bottom <= snap_tolerance &&
1882 !toplevel->priv->y_centered)
1883 *y = monitor_geom.height - height;
1884 }
1885}
1886
1887/* FIXME: this is wrong for Xinerama. In the Xinerama case
1888 * I think if hiding it requires it to go onto the
1889 * next monitor then it should just move it on to
1890 * the next monitor and set its state back to normal
1891 */
1892static void
1893panel_toplevel_update_hidden_position (PanelToplevel *toplevel,
1894 int *x,
1895 int *y,
1896 int *w,
1897 int *h)
1898{
1899 int width, height;
1900 int min_hide_size;
1901 GdkRectangle monitor_geom;
1902 GtkAllocation hide_allocation;
1903
1904 g_assert (x != NULL && y != NULL)do { if (x != ((void*)0) && y != ((void*)0)) ; else g_assertion_message_expr
(((gchar*) 0), "panel-toplevel.c", 1904, ((const char*) (__func__
)), "x != NULL && y != NULL"); } while (0)
;
1905
1906 g_assert (toplevel->priv->state == PANEL_STATE_HIDDEN_UP ||do { if (toplevel->priv->state == PANEL_STATE_HIDDEN_UP
|| toplevel->priv->state == PANEL_STATE_HIDDEN_DOWN ||
toplevel->priv->state == PANEL_STATE_HIDDEN_LEFT || toplevel
->priv->state == PANEL_STATE_HIDDEN_RIGHT) ; else g_assertion_message_expr
(((gchar*) 0), "panel-toplevel.c", 1909, ((const char*) (__func__
)), "toplevel->priv->state == PANEL_STATE_HIDDEN_UP || toplevel->priv->state == PANEL_STATE_HIDDEN_DOWN || toplevel->priv->state == PANEL_STATE_HIDDEN_LEFT || toplevel->priv->state == PANEL_STATE_HIDDEN_RIGHT"
); } while (0)
1907 toplevel->priv->state == PANEL_STATE_HIDDEN_DOWN ||do { if (toplevel->priv->state == PANEL_STATE_HIDDEN_UP
|| toplevel->priv->state == PANEL_STATE_HIDDEN_DOWN ||
toplevel->priv->state == PANEL_STATE_HIDDEN_LEFT || toplevel
->priv->state == PANEL_STATE_HIDDEN_RIGHT) ; else g_assertion_message_expr
(((gchar*) 0), "panel-toplevel.c", 1909, ((const char*) (__func__
)), "toplevel->priv->state == PANEL_STATE_HIDDEN_UP || toplevel->priv->state == PANEL_STATE_HIDDEN_DOWN || toplevel->priv->state == PANEL_STATE_HIDDEN_LEFT || toplevel->priv->state == PANEL_STATE_HIDDEN_RIGHT"
); } while (0)
1908 toplevel->priv->state == PANEL_STATE_HIDDEN_LEFT ||do { if (toplevel->priv->state == PANEL_STATE_HIDDEN_UP
|| toplevel->priv->state == PANEL_STATE_HIDDEN_DOWN ||
toplevel->priv->state == PANEL_STATE_HIDDEN_LEFT || toplevel
->priv->state == PANEL_STATE_HIDDEN_RIGHT) ; else g_assertion_message_expr
(((gchar*) 0), "panel-toplevel.c", 1909, ((const char*) (__func__
)), "toplevel->priv->state == PANEL_STATE_HIDDEN_UP || toplevel->priv->state == PANEL_STATE_HIDDEN_DOWN || toplevel->priv->state == PANEL_STATE_HIDDEN_LEFT || toplevel->priv->state == PANEL_STATE_HIDDEN_RIGHT"
); } while (0)
1909 toplevel->priv->state == PANEL_STATE_HIDDEN_RIGHT)do { if (toplevel->priv->state == PANEL_STATE_HIDDEN_UP
|| toplevel->priv->state == PANEL_STATE_HIDDEN_DOWN ||
toplevel->priv->state == PANEL_STATE_HIDDEN_LEFT || toplevel
->priv->state == PANEL_STATE_HIDDEN_RIGHT) ; else g_assertion_message_expr
(((gchar*) 0), "panel-toplevel.c", 1909, ((const char*) (__func__
)), "toplevel->priv->state == PANEL_STATE_HIDDEN_UP || toplevel->priv->state == PANEL_STATE_HIDDEN_DOWN || toplevel->priv->state == PANEL_STATE_HIDDEN_LEFT || toplevel->priv->state == PANEL_STATE_HIDDEN_RIGHT"
); } while (0)
;
1910
1911 if (toplevel->priv->attached) {
1912 panel_toplevel_update_attached_position (toplevel, TRUE(!(0)), x, y, w, h);
1913 return;
1914 }
1915
1916 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
1917
1918 width = toplevel->priv->original_width;
1919 height = toplevel->priv->original_height;
1920
1921 /* FIXME should find a better default */
1922 min_hide_size = DEFAULT_AUTO_HIDE_SIZE1;
1923
1924 switch (toplevel->priv->state) {
1925 case PANEL_STATE_HIDDEN_UP:
1926 gtk_widget_get_allocation (toplevel->priv->hide_button_bottom,
1927 &hide_allocation);
1928 *y = - (height - MAX (hide_allocation.height, min_hide_size)(((hide_allocation.height) > (min_hide_size)) ? (hide_allocation
.height) : (min_hide_size))
);
1929 break;
1930 case PANEL_STATE_HIDDEN_DOWN:
1931 gtk_widget_get_allocation (toplevel->priv->hide_button_top,
1932 &hide_allocation);
1933 *y = monitor_geom.height - MAX (hide_allocation.height, min_hide_size)(((hide_allocation.height) > (min_hide_size)) ? (hide_allocation
.height) : (min_hide_size))
;
1934 break;
1935 case PANEL_STATE_HIDDEN_LEFT:
1936 gtk_widget_get_allocation (toplevel->priv->hide_button_right,
1937 &hide_allocation);
1938 *x = - (width - MAX (hide_allocation.width, min_hide_size)(((hide_allocation.width) > (min_hide_size)) ? (hide_allocation
.width) : (min_hide_size))
);
1939 break;
1940 case PANEL_STATE_HIDDEN_RIGHT:
1941 gtk_widget_get_allocation (toplevel->priv->hide_button_left,
1942 &hide_allocation);
1943 *x = monitor_geom.width - MAX (hide_allocation.width, min_hide_size)(((hide_allocation.width) > (min_hide_size)) ? (hide_allocation
.width) : (min_hide_size))
;
1944 break;
1945 default:
1946 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 1946, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1947 break;
1948 }
1949}
1950
1951/*
1952 * This is "almost" like the double sine movement
1953 * from the original panel except that it uses
1954 * a cubic (twice again). I suppose it looks less
1955 * mathematical now :) -- _v_
1956 */
1957static int
1958get_delta (int src,
1959 int dest,
1960 GTimeSpan elapsed_time,
1961 GTimeSpan duration_time)
1962{
1963 double x, percentage;
1964
1965 if (abs (dest - src) <= 1 || elapsed_time >= duration_time)
1966 return dest - src;
1967
1968 /* The cubic is: p(x) = (-2) x^2 (x-1.5) */
1969 /* running p(p(x)) to make it more "pronounced",
1970 * effectively making it a ninth-degree polynomial */
1971
1972 x = (double)elapsed_time/duration_time;
1973 x = -2 * (x*x) * (x-1.5);
1974 /* run it again */
1975 percentage = -2 * (x*x) * (x-1.5);
1976
1977 percentage = CLAMP (percentage, 0.0, 1.0)(((percentage) > (1.0)) ? (1.0) : (((percentage) < (0.0
)) ? (0.0) : (percentage)))
;
1978
1979 return ((dest - src) * percentage);
1980}
1981
1982static void
1983panel_toplevel_update_animating_position (PanelToplevel *toplevel)
1984{
1985 GTimeSpan animation_elapsed_time;
1986 int deltax, deltay, deltaw = 0, deltah = 0;
1987 int monitor_offset_x, monitor_offset_y;
1988
1989 if ((toplevel->priv->animation_start_time <= 0) ||
1990 (toplevel->priv->animation_duration_time <= 0))
1991 return;
1992
1993 animation_elapsed_time = g_get_monotonic_time () - toplevel->priv->animation_start_time;
1994
1995 monitor_offset_x = panel_multimonitor_x (toplevel->priv->monitor);
1996 monitor_offset_y = panel_multimonitor_y (toplevel->priv->monitor);
1997
1998 if (toplevel->priv->animation_end_width != -1)
1999 deltaw = get_delta (toplevel->priv->geometry.width,
2000 toplevel->priv->animation_end_width,
2001 animation_elapsed_time,
2002 toplevel->priv->animation_duration_time);
2003
2004 if (toplevel->priv->animation_end_height != -1)
2005 deltah = get_delta (toplevel->priv->geometry.height,
2006 toplevel->priv->animation_end_height,
2007 animation_elapsed_time,
2008 toplevel->priv->animation_duration_time);
2009
2010 deltax = get_delta (toplevel->priv->geometry.x - monitor_offset_x,
2011 toplevel->priv->animation_end_x,
2012 animation_elapsed_time,
2013 toplevel->priv->animation_duration_time);
2014
2015 deltay = get_delta (toplevel->priv->geometry.y - monitor_offset_y,
2016 toplevel->priv->animation_end_y,
2017 animation_elapsed_time,
2018 toplevel->priv->animation_duration_time);
2019
2020 if (deltaw != 0 && abs (deltaw) > abs (deltax))
2021 deltax = deltaw;
2022 if (deltah != 0 && abs (deltah) > abs (deltay))
2023 deltay = deltah;
2024
2025 toplevel->priv->geometry.x += deltax;
2026 toplevel->priv->geometry.y += deltay;
2027
2028 toplevel->priv->geometry.width += deltaw;
2029 toplevel->priv->geometry.height += deltah;
2030
2031 if (toplevel->priv->geometry.x - monitor_offset_x == toplevel->priv->animation_end_x &&
2032 toplevel->priv->geometry.y - monitor_offset_y == toplevel->priv->animation_end_y) {
2033 toplevel->priv->animating = FALSE(0);
2034 /* Note: it's important to set initial_animation_done to TRUE
2035 * as soon as possible (hence, here) since we don't want to
2036 * have a wrong value in a size request event */
2037 toplevel->priv->initial_animation_done = TRUE(!(0));
2038
2039 if (toplevel->priv->attached && panel_toplevel_get_is_hidden (toplevel))
2040 gtk_widget_unmap (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
2041 else
2042 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
2043
2044 if (toplevel->priv->state == PANEL_STATE_NORMAL)
2045 g_signal_emit (toplevel, toplevel_signals [UNHIDE_SIGNAL], 0);
2046 }
2047}
2048
2049static void
2050panel_toplevel_update_expanded_position (PanelToplevel *toplevel)
2051{
2052 GdkRectangle monitor_geom;
2053 int x, y;
2054 int x_right, y_bottom;
2055 int monitor;
2056
2057 if (!toplevel->priv->expand)
2058 return;
2059
2060 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
2061
2062 x = -1;
2063 y = -1;
2064 x_right = -1;
2065 y_bottom = -1;
2066
2067 switch (toplevel->priv->orientation) {
2068 case PANEL_ORIENTATION_TOP:
2069 x = monitor_geom.x;
2070 y = monitor_geom.y;
2071 break;
2072 case PANEL_ORIENTATION_LEFT:
2073 x = monitor_geom.x;
2074 y = monitor_geom.y;
2075 break;
2076 case PANEL_ORIENTATION_BOTTOM:
2077 x = monitor_geom.x;
2078 y = monitor_geom.y + monitor_geom.height - toplevel->priv->geometry.height;
2079 y_bottom = 0;
2080 break;
2081 case PANEL_ORIENTATION_RIGHT:
2082 x = monitor_geom.x + monitor_geom.width - toplevel->priv->geometry.width;
2083 y = monitor_geom.y;
2084 x_right = 0;
2085 break;
2086 default:
2087 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 2087, ((const char*) (__func__)), ((void*)0)); } while (0)
;
2088 break;
2089 }
2090
2091 monitor = panel_multimonitor_get_monitor_at_point (x, y);
2092
2093 panel_toplevel_set_monitor_internal (toplevel, monitor, TRUE(!(0)));
2094
2095 x -= panel_multimonitor_x (monitor);
2096 y -= panel_multimonitor_y (monitor);
2097
2098 g_object_freeze_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
);
2099
2100 if (toplevel->priv->x != x) {
2101 toplevel->priv->x = x;
2102 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "x");
2103 }
2104
2105 if (toplevel->priv->y != y) {
2106 toplevel->priv->y = y;
2107 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "y");
2108 }
2109
2110 if (toplevel->priv->x_right != x_right) {
2111 toplevel->priv->x_right = x_right;
2112 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "x_right");
2113 }
2114
2115 if (toplevel->priv->y_bottom != y_bottom) {
2116 toplevel->priv->y_bottom = y_bottom;
2117 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "y_bottom");
2118 }
2119
2120 g_object_thaw_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
);
2121}
2122
2123static void
2124panel_toplevel_update_position (PanelToplevel *toplevel)
2125{
2126 PanelBackground *background;
2127 int x, y;
2128 int w, h;
2129 GdkRectangle monitor_geom;
2130
2131 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
2132
2133 if (toplevel->priv->animating) {
2134 panel_toplevel_update_animating_position (toplevel);
2135 return;
2136 }
2137
2138 if (toplevel->priv->position_centered) {
2139 toplevel->priv->position_centered = FALSE(0);
2140
2141 g_object_freeze_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
);
2142
2143 if (!toplevel->priv->x_centered) {
2144 int x_right;
2145
2146 toplevel->priv->x -= toplevel->priv->geometry.width / 2;
2147 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "x");
2148
2149 if ((toplevel->priv->x + toplevel->priv->geometry.width / 2) > monitor_geom.width / 2)
2150 x_right = monitor_geom.width - (toplevel->priv->x + toplevel->priv->geometry.width);
2151 else
2152 x_right = -1;
2153 if (toplevel->priv->x_right != x_right) {
2154 toplevel->priv->x_right = x_right;
2155 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
,
2156 "x-right");
2157 }
2158 }
2159
2160 if (!toplevel->priv->y_centered) {
2161 int y_bottom;
2162
2163 toplevel->priv->y -= toplevel->priv->geometry.height / 2;
2164 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "y");
2165
2166 if ((toplevel->priv->y + toplevel->priv->geometry.height / 2) > monitor_geom.height / 2)
2167 y_bottom = monitor_geom.height - (toplevel->priv->y + toplevel->priv->geometry.height);
2168 else
2169 y_bottom = -1;
2170 if (toplevel->priv->y_bottom != y_bottom) {
2171 toplevel->priv->y_bottom = y_bottom;
2172 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
,
2173 "y-bottom");
2174 }
2175 }
2176
2177 g_object_thaw_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
);
2178 }
2179
2180 panel_toplevel_update_expanded_position (toplevel);
2181 panel_toplevel_calc_floating (toplevel); /* FIXME should probably be done after panel_toplevel_update_normal_position() too */
2182
2183 if (toplevel->priv->x_right == -1)
2184 x = toplevel->priv->x;
2185 else
2186 x = monitor_geom.width - (toplevel->priv->x_right + toplevel->priv->geometry.width);
2187 if (toplevel->priv->y_bottom == -1)
2188 y = toplevel->priv->y;
2189 else
2190 y = monitor_geom.height - (toplevel->priv->y_bottom + toplevel->priv->geometry.height);
2191
2192 if (!toplevel->priv->expand) {
2193 if (toplevel->priv->x_centered)
2194 x = (monitor_geom.width - toplevel->priv->geometry.width) / 2;
2195 if (toplevel->priv->y_centered)
2196 y = (monitor_geom.height - toplevel->priv->geometry.height) / 2;
2197 }
2198
2199 w = h = -1;
2200
2201 if (toplevel->priv->state == PANEL_STATE_NORMAL)
2202 panel_toplevel_update_normal_position (toplevel, &x, &y, &w, &h);
2203
2204 else if (toplevel->priv->state == PANEL_STATE_AUTO_HIDDEN)
2205 panel_toplevel_update_auto_hide_position (toplevel, &x, &y, &w, &h, FALSE(0));
2206
2207 else
2208 panel_toplevel_update_hidden_position (toplevel, &x, &y, &w, &h);
2209
2210 if (w != -1)
2211 toplevel->priv->geometry.width = w;
2212 if (h != -1)
2213 toplevel->priv->geometry.height = h;
2214
2215 /* This is some kind of snap: there's a possibility of an infinite loop
2216 * because of the bevels of the frame that are set in
2217 * panel_toplevel_update_edges(). The bevels change the width/height of
2218 * the toplevel. The typical loop is:
2219 * x = 1 => outer bevel => x = 0 => no outer bevel = > x = 1 => ...
2220 * FIXME: maybe the real bug is that we enter into this loop (see bug
2221 * #160748 to learn how to reproduce.) */
2222 background = &toplevel->background;
2223
2224 /* There's no bevels with a color/image background */
2225 if (panel_background_effective_type (background) == PANEL_BACK_NONE) {
2226 GtkStyleContext *context;
2227 GtkStateFlags state;
2228 GdkRectangle *geometry;
2229 GtkBorder padding;
2230 int max_size;
2231
2232 state = gtk_widget_get_state_flags (GTK_WIDGET (toplevel->priv->inner_frame)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->inner_frame)), ((gtk_widget_get_type
()))))))
);
2233 context = gtk_widget_get_style_context (GTK_WIDGET (toplevel->priv->inner_frame)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->inner_frame)), ((gtk_widget_get_type
()))))))
);
2234 gtk_style_context_get_padding (context, state, &padding);
2235 geometry = &toplevel->priv->geometry;
2236
2237 if (x <= padding.left && x > 0 &&
2238 !toplevel->priv->x_centered)
2239 x = 0;
2240
2241 if (y <= padding.top && y > 0 &&
2242 !toplevel->priv->y_centered)
2243 y = 0;
2244
2245 max_size = monitor_geom.width - geometry->width - padding.right;
2246 if (x + padding.left >= max_size && x < max_size &&
2247 !toplevel->priv->x_centered)
2248 x = max_size;
2249
2250 max_size = monitor_geom.height - geometry->height - padding.bottom;
2251 if (y + padding.top >= max_size && y < max_size &&
2252 !toplevel->priv->y_centered)
2253 y = max_size;
2254 }
2255
2256 x += panel_multimonitor_x (toplevel->priv->monitor);
2257 y += panel_multimonitor_y (toplevel->priv->monitor);
2258
2259 toplevel->priv->geometry.x = x;
2260 toplevel->priv->geometry.y = y;
2261}
2262
2263static int
2264calculate_minimum_height (GtkWidget *widget,
2265 PanelOrientation orientation)
2266{
2267 GtkStateFlags state;
2268 GtkStyleContext *style_context;
2269 PangoFontDescription *font_desc;
2270 GtkBorder padding;
2271 PangoContext *pango_context;
2272 PangoFontMetrics *metrics;
2273 int ascent;
2274 int descent;
2275 int thickness;
2276
2277 state = gtk_widget_get_state_flags (widget);
2278 style_context = gtk_widget_get_style_context (widget);
2279 gtk_style_context_get(style_context, state, GTK_STYLE_PROPERTY_FONT"font", &font_desc, NULL((void*)0));
2280
2281 pango_context = gtk_widget_get_pango_context (widget);
2282 metrics = pango_context_get_metrics (pango_context,
2283 font_desc,
2284 pango_context_get_language (pango_context));
2285 gtk_style_context_get_padding (style_context, state, &padding);
2286
2287 ascent = pango_font_metrics_get_ascent (metrics);
2288 descent = pango_font_metrics_get_descent (metrics);
2289
2290 pango_font_description_free (font_desc);
2291 pango_font_metrics_unref (metrics);
2292
2293 thickness = (orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)) ?
2294 padding.top + padding.bottom :
2295 padding.left + padding.right;
2296
2297 return PANGO_PIXELS (ascent + descent)(((int)(ascent + descent) + 512) >> 10) + thickness;
2298}
2299
2300static int
2301panel_toplevel_update_size_from_hints (PanelToplevel *toplevel,
2302 int requisition_size,
2303 int monitor_size,
2304 int non_panel_widget_size)
2305{
2306 int nb_size_hints;
2307 AppletSizeHints *applets_hints;
2308 AppletSizeHintsAlloc *using_hint;
2309
2310 int i;
2311 int total_size;
2312 int full_hints;
2313
2314 /* Scale down the size so that the panel only takes what it needs for the applets it has. */
2315 total_size = non_panel_widget_size + (requisition_size / toplevel->priv->scale);
2316
2317 nb_size_hints = toplevel->priv->panel_widget->nb_applets_size_hints;
2318 if (nb_size_hints <= 0)
2319 return total_size;
2320
2321 applets_hints = toplevel->priv->panel_widget->applets_hints;
2322 using_hint = toplevel->priv->panel_widget->applets_using_hint;
2323
2324 for (i = 0; i < nb_size_hints; i++) {
2325 using_hint[i].index = applets_hints[i].len - 2;
2326 using_hint[i].size = applets_hints[i].hints[applets_hints[i].len - 1];
2327 total_size += using_hint[i].size;
2328 }
2329
2330 if (total_size > monitor_size)
2331 return monitor_size;
2332
2333 full_hints = 0;
2334 while (full_hints != nb_size_hints && total_size < monitor_size) {
2335 int bonus;
2336 int extra_bonus;
2337
2338 bonus = (monitor_size - total_size)
2339 / (nb_size_hints - full_hints);
2340 extra_bonus = (monitor_size - total_size)
2341 % (nb_size_hints - full_hints);
2342 full_hints = 0;
2343
2344 for (i = 0; i < nb_size_hints; i++) {
2345 int new_size;
2346 int current_bonus;
2347
2348 current_bonus = bonus;
2349
2350 while (using_hint[i].index > 0 && applets_hints[i].hints[using_hint[i].index - 1] < using_hint[i].size + current_bonus) {
2351 new_size = applets_hints[i].hints[using_hint[i].index - 1];
2352 current_bonus = using_hint[i].size
2353 + current_bonus - new_size;
2354 total_size = total_size - using_hint[i].size
2355 + new_size;
2356
2357 using_hint[i].index -= 2;
2358 using_hint[i].size = new_size;
2359 }
2360
2361 new_size = MIN (applets_hints[i].hints[using_hint[i].index],(((applets_hints[i].hints[using_hint[i].index]) < (using_hint
[i].size + current_bonus)) ? (applets_hints[i].hints[using_hint
[i].index]) : (using_hint[i].size + current_bonus))
2362 using_hint[i].size + current_bonus)(((applets_hints[i].hints[using_hint[i].index]) < (using_hint
[i].size + current_bonus)) ? (applets_hints[i].hints[using_hint
[i].index]) : (using_hint[i].size + current_bonus))
;
2363 if (new_size > using_hint[i].size) {
2364 total_size += (new_size - using_hint[i].size);
2365 using_hint[i].size = new_size;
2366 }
2367
2368 if (extra_bonus > 0) {
2369 new_size = MIN (applets_hints[i].hints[using_hint[i].index],(((applets_hints[i].hints[using_hint[i].index]) < (using_hint
[i].size + extra_bonus)) ? (applets_hints[i].hints[using_hint
[i].index]) : (using_hint[i].size + extra_bonus))
2370 using_hint[i].size + extra_bonus)(((applets_hints[i].hints[using_hint[i].index]) < (using_hint
[i].size + extra_bonus)) ? (applets_hints[i].hints[using_hint
[i].index]) : (using_hint[i].size + extra_bonus))
;
2371 if (new_size > using_hint[i].size) {
2372 total_size += (new_size
2373 - using_hint[i].size);
2374 extra_bonus -= (new_size
2375 - using_hint[i].size);
2376 using_hint[i].size = new_size;
2377 }
2378 }
2379
2380 if (using_hint[i].size == applets_hints[i].hints[using_hint[i].index])
2381 full_hints++;
2382 }
2383 }
2384
2385 return total_size;
2386}
2387
2388static void
2389panel_toplevel_update_size (PanelToplevel *toplevel,
2390 GtkRequisition *requisition)
2391{
2392 GtkWidget *widget;
2393 GtkStyleContext *context;
2394 GtkStateFlags state;
2395 GtkBorder padding;
2396 GdkRectangle monitor_geom;
2397 int width, height;
2398 int minimum_height;
2399 int non_panel_widget_size;
2400
2401 if (toplevel->priv->animating)
5
Assuming field 'animating' is 0
6
Taking false branch
2402 return;
2403
2404 widget = GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
;
2405 context = gtk_widget_get_style_context (widget);
2406 state = gtk_widget_get_state_flags (widget);
2407 gtk_style_context_get_padding (context, state, &padding);
2408
2409 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
2410
2411 width = requisition->width;
7
Assigned value is garbage or undefined
2412 height = requisition->height;
2413
2414 if (!toplevel->priv->expand &&
2415 !toplevel->priv->buttons_enabled && !toplevel->priv->attached)
2416 non_panel_widget_size = 2 * HANDLE_SIZE10;
2417 else
2418 non_panel_widget_size = 0;
2419
2420 minimum_height = calculate_minimum_height (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
,
2421 toplevel->priv->orientation);
2422
2423 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)) {
2424
2425 height = MAX (MIN (MAX (height, toplevel->priv->size),(((((((((height) > (toplevel->priv->size)) ? (height
) : (toplevel->priv->size))) < (panel_toplevel_get_maximum_size
(toplevel))) ? ((((height) > (toplevel->priv->size)
) ? (height) : (toplevel->priv->size))) : (panel_toplevel_get_maximum_size
(toplevel)))) > (minimum_height)) ? (((((((height) > (
toplevel->priv->size)) ? (height) : (toplevel->priv->
size))) < (panel_toplevel_get_maximum_size (toplevel))) ? (
(((height) > (toplevel->priv->size)) ? (height) : (toplevel
->priv->size))) : (panel_toplevel_get_maximum_size (toplevel
)))) : (minimum_height))
2426 panel_toplevel_get_maximum_size (toplevel)),(((((((((height) > (toplevel->priv->size)) ? (height
) : (toplevel->priv->size))) < (panel_toplevel_get_maximum_size
(toplevel))) ? ((((height) > (toplevel->priv->size)
) ? (height) : (toplevel->priv->size))) : (panel_toplevel_get_maximum_size
(toplevel)))) > (minimum_height)) ? (((((((height) > (
toplevel->priv->size)) ? (height) : (toplevel->priv->
size))) < (panel_toplevel_get_maximum_size (toplevel))) ? (
(((height) > (toplevel->priv->size)) ? (height) : (toplevel
->priv->size))) : (panel_toplevel_get_maximum_size (toplevel
)))) : (minimum_height))
2427 minimum_height)(((((((((height) > (toplevel->priv->size)) ? (height
) : (toplevel->priv->size))) < (panel_toplevel_get_maximum_size
(toplevel))) ? ((((height) > (toplevel->priv->size)
) ? (height) : (toplevel->priv->size))) : (panel_toplevel_get_maximum_size
(toplevel)))) > (minimum_height)) ? (((((((height) > (
toplevel->priv->size)) ? (height) : (toplevel->priv->
size))) < (panel_toplevel_get_maximum_size (toplevel))) ? (
(((height) > (toplevel->priv->size)) ? (height) : (toplevel
->priv->size))) : (panel_toplevel_get_maximum_size (toplevel
)))) : (minimum_height))
;
2428
2429 if (toplevel->priv->expand)
2430 width = monitor_geom.width;
2431 else {
2432 int max_width;
2433
2434 if (!toplevel->priv->attached)
2435 max_width = monitor_geom.width;
2436 else {
2437 if (panel_toplevel_get_orientation (toplevel->priv->attach_toplevel) == PANEL_ORIENTATION_LEFT)
2438 max_width = monitor_geom.width
2439 - toplevel->priv->geometry.x;
2440 else
2441 max_width = toplevel->priv->geometry.x +
2442 toplevel->priv->geometry.width;
2443 }
2444
2445 width = panel_toplevel_update_size_from_hints (
2446 toplevel,
2447 requisition->width,
2448 max_width,
2449 non_panel_widget_size);
2450 }
2451
2452 width = MAX (MINIMUM_WIDTH, width)(((100) > (width)) ? (100) : (width));
2453 } else {
2454 width = MAX (MIN (MAX (width, toplevel->priv->size),(((((((((width) > (toplevel->priv->size)) ? (width) :
(toplevel->priv->size))) < (panel_toplevel_get_maximum_size
(toplevel))) ? ((((width) > (toplevel->priv->size))
? (width) : (toplevel->priv->size))) : (panel_toplevel_get_maximum_size
(toplevel)))) > (minimum_height)) ? (((((((width) > (toplevel
->priv->size)) ? (width) : (toplevel->priv->size)
)) < (panel_toplevel_get_maximum_size (toplevel))) ? ((((width
) > (toplevel->priv->size)) ? (width) : (toplevel->
priv->size))) : (panel_toplevel_get_maximum_size (toplevel
)))) : (minimum_height))
2455 panel_toplevel_get_maximum_size (toplevel)),(((((((((width) > (toplevel->priv->size)) ? (width) :
(toplevel->priv->size))) < (panel_toplevel_get_maximum_size
(toplevel))) ? ((((width) > (toplevel->priv->size))
? (width) : (toplevel->priv->size))) : (panel_toplevel_get_maximum_size
(toplevel)))) > (minimum_height)) ? (((((((width) > (toplevel
->priv->size)) ? (width) : (toplevel->priv->size)
)) < (panel_toplevel_get_maximum_size (toplevel))) ? ((((width
) > (toplevel->priv->size)) ? (width) : (toplevel->
priv->size))) : (panel_toplevel_get_maximum_size (toplevel
)))) : (minimum_height))
2456 minimum_height)(((((((((width) > (toplevel->priv->size)) ? (width) :
(toplevel->priv->size))) < (panel_toplevel_get_maximum_size
(toplevel))) ? ((((width) > (toplevel->priv->size))
? (width) : (toplevel->priv->size))) : (panel_toplevel_get_maximum_size
(toplevel)))) > (minimum_height)) ? (((((((width) > (toplevel
->priv->size)) ? (width) : (toplevel->priv->size)
)) < (panel_toplevel_get_maximum_size (toplevel))) ? ((((width
) > (toplevel->priv->size)) ? (width) : (toplevel->
priv->size))) : (panel_toplevel_get_maximum_size (toplevel
)))) : (minimum_height))
;
2457
2458 if (toplevel->priv->expand)
2459 height = monitor_geom.height;
2460 else {
2461 int max_height;
2462
2463 if (!toplevel->priv->attached)
2464 max_height = monitor_geom.height;
2465 else {
2466 if (panel_toplevel_get_orientation (toplevel->priv->attach_toplevel) == PANEL_ORIENTATION_TOP)
2467 max_height = monitor_geom.height
2468 - toplevel->priv->geometry.y;
2469 else
2470 max_height = toplevel->priv->geometry.y +
2471 toplevel->priv->geometry.height;
2472 }
2473
2474 height = panel_toplevel_update_size_from_hints (
2475 toplevel,
2476 requisition->height,
2477 max_height,
2478 non_panel_widget_size);
2479 }
2480
2481 height = MAX (MINIMUM_WIDTH, height)(((100) > (height)) ? (100) : (height));
2482 }
2483
2484 if (toplevel->priv->edges & PANEL_EDGE_TOP)
2485 height += padding.top;
2486 if (toplevel->priv->edges & PANEL_EDGE_BOTTOM)
2487 height += padding.bottom;
2488 if (toplevel->priv->edges & PANEL_EDGE_LEFT)
2489 width += padding.left;
2490 if (toplevel->priv->edges & PANEL_EDGE_RIGHT)
2491 width += padding.right;
2492
2493 toplevel->priv->geometry.width = CLAMP (width, 0, monitor_geom.width)(((width) > (monitor_geom.width)) ? (monitor_geom.width) :
(((width) < (0)) ? (0) : (width)))
;
2494 toplevel->priv->geometry.height = CLAMP (height, 0, monitor_geom.height)(((height) > (monitor_geom.height)) ? (monitor_geom.height
) : (((height) < (0)) ? (0) : (height)))
;
2495 toplevel->priv->original_width = toplevel->priv->geometry.width;
2496 toplevel->priv->original_height = toplevel->priv->geometry.height;
2497}
2498
2499static void
2500panel_toplevel_update_geometry (PanelToplevel *toplevel,
2501 GtkRequisition *requisition)
2502{
2503 toplevel->priv->updated_geometry_initial = TRUE(!(0));
2504 panel_toplevel_update_size (toplevel, requisition);
4
Calling 'panel_toplevel_update_size'
2505 panel_toplevel_update_position (toplevel);
2506
2507 panel_toplevel_update_struts (toplevel, FALSE(0));
2508
2509#ifdef HAVE_X111
2510 if (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel)))(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gtk_widget_get_display (((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((toplevel)), ((gtk_widget_get_type ()))))
))))); GType __t = ((gdk_x11_display_get_type())); gboolean __r
; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
) {
2511 if (toplevel->priv->state == PANEL_STATE_NORMAL ||
2512 toplevel->priv->state != PANEL_STATE_AUTO_HIDDEN) {
2513 panel_struts_update_toplevel_geometry (toplevel,
2514 &toplevel->priv->geometry.x,
2515 &toplevel->priv->geometry.y,
2516 &toplevel->priv->geometry.width,
2517 &toplevel->priv->geometry.height);
2518 } else {
2519 panel_struts_update_toplevel_geometry (toplevel,
2520 &toplevel->priv->geometry.x,
2521 &toplevel->priv->geometry.y,
2522 NULL((void*)0), NULL((void*)0));
2523 }
2524 }
2525#endif /* HAVE_X11 */
2526
2527 panel_toplevel_update_edges (toplevel);
2528 panel_toplevel_update_description (toplevel);
2529}
2530
2531static void
2532panel_toplevel_attach_widget_destroyed (PanelToplevel *toplevel)
2533{
2534 panel_toplevel_detach (toplevel);
2535}
2536
2537static gboolean
2538panel_toplevel_attach_widget_configure (PanelToplevel *toplevel)
2539{
2540 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
2541
2542 return FALSE(0);
2543}
2544
2545static void
2546panel_toplevel_update_attach_orientation (PanelToplevel *toplevel)
2547{
2548 PanelOrientation attach_orientation;
2549 PanelOrientation orientation;
2550
2551 attach_orientation =
2552 panel_toplevel_get_orientation (toplevel->priv->attach_toplevel);
2553
2554 orientation = toplevel->priv->orientation;
2555
2556 switch (attach_orientation) {
2557 case PANEL_ORIENTATION_TOP:
2558 orientation = PANEL_ORIENTATION_LEFT;
2559 break;
2560 case PANEL_ORIENTATION_BOTTOM:
2561 orientation = PANEL_ORIENTATION_RIGHT;
2562 break;
2563 case PANEL_ORIENTATION_LEFT:
2564 orientation = PANEL_ORIENTATION_TOP;
2565 break;
2566 case PANEL_ORIENTATION_RIGHT:
2567 orientation = PANEL_ORIENTATION_BOTTOM;
2568 break;
2569 default:
2570 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 2570, ((const char*) (__func__)), ((void*)0)); } while (0)
;
2571 break;
2572 }
2573
2574 panel_toplevel_set_orientation (toplevel, orientation);
2575}
2576
2577static void
2578panel_toplevel_attach_widget_parent_set (PanelToplevel *toplevel,
2579 GtkWidget *previous_parent,
2580 GtkWidget *attach_widget)
2581{
2582 GtkWidget *panel_widget;
2583
2584 panel_widget = gtk_widget_get_parent (GTK_WIDGET (attach_widget)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((attach_widget)), ((gtk_widget_get_type ()))))))
);
2585 if (!panel_widget)
2586 return;
2587
2588 g_assert (PANEL_IS_WIDGET (panel_widget))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((panel_widget)); GType __t = ((panel_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_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 2588, ((const char*) (__func__)), "PANEL_IS_WIDGET (panel_widget)"
); } while (0)
;
2589
2590 toplevel->priv->attach_toplevel = PANEL_WIDGET (panel_widget)((((PanelWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((panel_widget)), ((panel_widget_get_type()))))))
->toplevel;
2591 panel_toplevel_update_attach_orientation (toplevel);
2592 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
2593}
2594
2595static void
2596panel_toplevel_attach_toplevel_hiding (PanelToplevel *toplevel)
2597{
2598 if (!panel_toplevel_get_is_hidden (toplevel)) {
2599 panel_toplevel_hide (toplevel, FALSE(0), -1);
2600
2601 toplevel->priv->attach_hidden = TRUE(!(0));
2602 }
2603}
2604
2605static void
2606panel_toplevel_attach_toplevel_unhiding (PanelToplevel *toplevel)
2607{
2608 if (!toplevel->priv->attach_hidden)
2609 return;
2610
2611 toplevel->priv->attach_hidden = FALSE(0);
2612
2613 panel_toplevel_unhide (toplevel);
2614}
2615
2616static void
2617panel_toplevel_reverse_arrow (PanelToplevel *toplevel,
2618 GtkWidget *button)
2619{
2620 GtkArrowType arrow_type;
2621
2622 arrow_type = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button), "arrow-type"))((gint) (glong) (g_object_get_data (((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((button)), (((GType) ((20) << (2)))
))))), "arrow-type")))
;
2623
2624 switch (arrow_type) {
2625 case GTK_ARROW_UP:
2626 arrow_type = GTK_ARROW_DOWN;
2627 break;
2628 case GTK_ARROW_DOWN:
2629 arrow_type = GTK_ARROW_UP;
2630 break;
2631 case GTK_ARROW_LEFT:
2632 arrow_type = GTK_ARROW_RIGHT;
2633 break;
2634 case GTK_ARROW_RIGHT:
2635 arrow_type = GTK_ARROW_LEFT;
2636 break;
2637 default:
2638 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 2638, ((const char*) (__func__)), ((void*)0)); } while (0)
;
2639 break;
2640 }
2641
2642 g_object_set_data (G_OBJECT (button)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), (((GType) ((20) << (2))))))))
, "arrow-type", GINT_TO_POINTER (arrow_type)((gpointer) (glong) (arrow_type)));
2643
2644 set_arrow_type (GTK_IMAGE (gtk_bin_get_child (GTK_BIN (button)))((((GtkImage*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_bin_get_child (((((GtkBin*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((button)), ((gtk_bin_get_type ())))))))))
, ((gtk_image_get_type ()))))))
, arrow_type);
2645}
2646
2647static void
2648panel_toplevel_reverse_arrows (PanelToplevel *toplevel)
2649{
2650 panel_toplevel_reverse_arrow (toplevel, toplevel->priv->hide_button_top);
2651 panel_toplevel_reverse_arrow (toplevel, toplevel->priv->hide_button_bottom);
2652 panel_toplevel_reverse_arrow (toplevel, toplevel->priv->hide_button_left);
2653 panel_toplevel_reverse_arrow (toplevel, toplevel->priv->hide_button_right);
2654}
2655
2656static void
2657panel_toplevel_disconnect_attached (PanelToplevel *toplevel)
2658{
2659 guint i;
2660
2661#if GLIB_CHECK_VERSION(2,62,0)(2 > (2) || (2 == (2) && 80 > (62)) || (2 == (2
) && 80 == (62) && 2 >= (0)))
2662 for (i = 0; i < N_ATTACH_TOPLEVEL_SIGNALS5; i++) {
2663 g_clear_signal_handler (&toplevel->priv->attach_toplevel_signals [i],do { gpointer const _instance = (toplevel->priv->attach_toplevel
); gulong *const _handler_id_ptr = (&toplevel->priv->
attach_toplevel_signals [i]); const gulong _handler_id = *_handler_id_ptr
; if (_handler_id > 0) { *_handler_id_ptr = 0; g_signal_handler_disconnect
(_instance, _handler_id); } } while (0)
2664 toplevel->priv->attach_toplevel)do { gpointer const _instance = (toplevel->priv->attach_toplevel
); gulong *const _handler_id_ptr = (&toplevel->priv->
attach_toplevel_signals [i]); const gulong _handler_id = *_handler_id_ptr
; if (_handler_id > 0) { *_handler_id_ptr = 0; g_signal_handler_disconnect
(_instance, _handler_id); } } while (0)
;
2665 }
2666
2667 for (i = 0; i < N_ATTACH_WIDGET_SIGNALS5; i++) {
2668 g_clear_signal_handler (&toplevel->priv->attach_widget_signals [i],do { gpointer const _instance = (toplevel->priv->attach_widget
); gulong *const _handler_id_ptr = (&toplevel->priv->
attach_widget_signals [i]); const gulong _handler_id = *_handler_id_ptr
; if (_handler_id > 0) { *_handler_id_ptr = 0; g_signal_handler_disconnect
(_instance, _handler_id); } } while (0)
2669 toplevel->priv->attach_widget)do { gpointer const _instance = (toplevel->priv->attach_widget
); gulong *const _handler_id_ptr = (&toplevel->priv->
attach_widget_signals [i]); const gulong _handler_id = *_handler_id_ptr
; if (_handler_id > 0) { *_handler_id_ptr = 0; g_signal_handler_disconnect
(_instance, _handler_id); } } while (0)
;
2670 }
2671#else
2672 for (i = 0; i < N_ATTACH_TOPLEVEL_SIGNALS5; i++) {
2673 if (toplevel->priv->attach_toplevel_signals [i] != 0) {
2674 g_signal_handler_disconnect (toplevel->priv->attach_toplevel,
2675 toplevel->priv->attach_toplevel_signals [i]);
2676 toplevel->priv->attach_toplevel_signals [i] = 0;
2677 }
2678 }
2679
2680 for (i = 0; i < N_ATTACH_WIDGET_SIGNALS5; i++) {
2681 if (toplevel->priv->attach_widget_signals [i] != 0) {
2682 g_signal_handler_disconnect (toplevel->priv->attach_widget,
2683 toplevel->priv->attach_widget_signals [i]);
2684 toplevel->priv->attach_widget_signals [i] = 0;
2685 }
2686 }
2687#endif
2688}
2689
2690static void
2691panel_toplevel_connect_attached (PanelToplevel *toplevel)
2692{
2693 gulong *signals;
2694 int i = 0;
2695
2696 signals = toplevel->priv->attach_toplevel_signals;
2697
2698 signals [i++] = g_signal_connect_swapped (g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("destroy"), (((GCallback) (panel_toplevel_attach_widget_destroyed
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2699 toplevel->priv->attach_toplevel, "destroy",g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("destroy"), (((GCallback) (panel_toplevel_attach_widget_destroyed
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2700 G_CALLBACK (panel_toplevel_attach_widget_destroyed), toplevel)g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("destroy"), (((GCallback) (panel_toplevel_attach_widget_destroyed
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
;
2701 signals [i++] = g_signal_connect_swapped (g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("notify::orientation"), (((GCallback) (panel_toplevel_update_attach_orientation
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2702 toplevel->priv->attach_toplevel, "notify::orientation",g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("notify::orientation"), (((GCallback) (panel_toplevel_update_attach_orientation
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2703 G_CALLBACK (panel_toplevel_update_attach_orientation), toplevel)g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("notify::orientation"), (((GCallback) (panel_toplevel_update_attach_orientation
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
;
2704 signals [i++] = g_signal_connect_swapped (g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("configure-event"), (((GCallback) (panel_toplevel_attach_widget_configure
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2705 toplevel->priv->attach_toplevel, "configure-event",g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("configure-event"), (((GCallback) (panel_toplevel_attach_widget_configure
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2706 G_CALLBACK (panel_toplevel_attach_widget_configure), toplevel)g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("configure-event"), (((GCallback) (panel_toplevel_attach_widget_configure
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
;
2707 signals [i++] = g_signal_connect_swapped (g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("hiding"), (((GCallback) (panel_toplevel_attach_toplevel_hiding
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2708 toplevel->priv->attach_toplevel, "hiding",g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("hiding"), (((GCallback) (panel_toplevel_attach_toplevel_hiding
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2709 G_CALLBACK (panel_toplevel_attach_toplevel_hiding), toplevel)g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("hiding"), (((GCallback) (panel_toplevel_attach_toplevel_hiding
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
;
2710 signals [i++] = g_signal_connect_swapped (g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("unhiding"), (((GCallback) (panel_toplevel_attach_toplevel_unhiding
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2711 toplevel->priv->attach_toplevel, "unhiding",g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("unhiding"), (((GCallback) (panel_toplevel_attach_toplevel_unhiding
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2712 G_CALLBACK (panel_toplevel_attach_toplevel_unhiding), toplevel)g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("unhiding"), (((GCallback) (panel_toplevel_attach_toplevel_unhiding
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
;
2713
2714 g_assert (i == N_ATTACH_TOPLEVEL_SIGNALS)do { if (i == 5) ; else g_assertion_message_expr (((gchar*) 0
), "panel-toplevel.c", 2714, ((const char*) (__func__)), "i == N_ATTACH_TOPLEVEL_SIGNALS"
); } while (0)
;
2715
2716 signals = toplevel->priv->attach_widget_signals;
2717 i = 0;
2718
2719 signals [i++] = g_signal_connect_swapped (g_signal_connect_data ((toplevel->priv->attach_widget),
("destroy"), (((GCallback) (panel_toplevel_attach_widget_destroyed
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2720 toplevel->priv->attach_widget, "destroy",g_signal_connect_data ((toplevel->priv->attach_widget),
("destroy"), (((GCallback) (panel_toplevel_attach_widget_destroyed
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2721 G_CALLBACK (panel_toplevel_attach_widget_destroyed), toplevel)g_signal_connect_data ((toplevel->priv->attach_widget),
("destroy"), (((GCallback) (panel_toplevel_attach_widget_destroyed
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
;
2722 signals [i++] = g_signal_connect_swapped (g_signal_connect_data ((toplevel->priv->attach_widget),
("configure-event"), (((GCallback) (panel_toplevel_attach_widget_configure
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2723 toplevel->priv->attach_widget, "configure-event",g_signal_connect_data ((toplevel->priv->attach_widget),
("configure-event"), (((GCallback) (panel_toplevel_attach_widget_configure
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2724 G_CALLBACK (panel_toplevel_attach_widget_configure), toplevel)g_signal_connect_data ((toplevel->priv->attach_widget),
("configure-event"), (((GCallback) (panel_toplevel_attach_widget_configure
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
;
2725 signals [i++] = g_signal_connect_swapped (g_signal_connect_data ((toplevel->priv->attach_widget),
("parent-set"), (((GCallback) (panel_toplevel_attach_widget_parent_set
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2726 toplevel->priv->attach_widget, "parent-set",g_signal_connect_data ((toplevel->priv->attach_widget),
("parent-set"), (((GCallback) (panel_toplevel_attach_widget_parent_set
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2727 G_CALLBACK (panel_toplevel_attach_widget_parent_set), toplevel)g_signal_connect_data ((toplevel->priv->attach_widget),
("parent-set"), (((GCallback) (panel_toplevel_attach_widget_parent_set
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
;
2728 signals [i++] = g_signal_connect_swapped (g_signal_connect_data ((toplevel->priv->attach_widget),
("show"), (((GCallback) (gtk_widget_show))), (toplevel), ((void
*)0), G_CONNECT_SWAPPED)
2729 toplevel->priv->attach_widget, "show",g_signal_connect_data ((toplevel->priv->attach_widget),
("show"), (((GCallback) (gtk_widget_show))), (toplevel), ((void
*)0), G_CONNECT_SWAPPED)
2730 G_CALLBACK (gtk_widget_show), toplevel)g_signal_connect_data ((toplevel->priv->attach_widget),
("show"), (((GCallback) (gtk_widget_show))), (toplevel), ((void
*)0), G_CONNECT_SWAPPED)
;
2731 signals [i++] = g_signal_connect_swapped (g_signal_connect_data ((toplevel->priv->attach_widget),
("hide"), (((GCallback) (gtk_widget_hide))), (toplevel), ((void
*)0), G_CONNECT_SWAPPED)
2732 toplevel->priv->attach_widget, "hide",g_signal_connect_data ((toplevel->priv->attach_widget),
("hide"), (((GCallback) (gtk_widget_hide))), (toplevel), ((void
*)0), G_CONNECT_SWAPPED)
2733 G_CALLBACK (gtk_widget_hide), toplevel)g_signal_connect_data ((toplevel->priv->attach_widget),
("hide"), (((GCallback) (gtk_widget_hide))), (toplevel), ((void
*)0), G_CONNECT_SWAPPED)
;
2734
2735 g_assert (i == N_ATTACH_WIDGET_SIGNALS)do { if (i == 5) ; else g_assertion_message_expr (((gchar*) 0
), "panel-toplevel.c", 2735, ((const char*) (__func__)), "i == N_ATTACH_WIDGET_SIGNALS"
); } while (0)
;
2736}
2737
2738void
2739panel_toplevel_attach_to_widget (PanelToplevel *toplevel,
2740 PanelToplevel *attach_toplevel,
2741 GtkWidget *attach_widget)
2742{
2743 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
2744 g_return_if_fail (PANEL_IS_TOPLEVEL (attach_toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((attach_toplevel)); GType __t = ((panel_toplevel_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0
), ((const char*) (__func__)), "PANEL_IS_TOPLEVEL (attach_toplevel)"
); return; } } while (0)
;
2745 g_return_if_fail (GTK_IS_WIDGET (attach_widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((attach_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 (((gchar*) 0), ((const
char*) (__func__)), "GTK_IS_WIDGET (attach_widget)"); return
; } } while (0)
;
2746
2747 if (toplevel->priv->attached)
2748 panel_toplevel_disconnect_attached (toplevel);
2749
2750 toplevel->priv->attached = TRUE(!(0));
2751
2752 /* Cancelling the initial animation for drawers in
2753 * panel_toplevel_initially_hide() is not enough, since this will
2754 * happen only when the toplevel is realized, which might be too late
2755 * for drawers (since it's realized when the drawer is clicked) */
2756 toplevel->priv->initial_animation_done = TRUE(!(0));
2757
2758 toplevel->priv->attach_toplevel = attach_toplevel;
2759 toplevel->priv->attach_widget = attach_widget;
2760
2761 panel_toplevel_connect_attached (toplevel);
2762
2763 panel_toplevel_reverse_arrows (toplevel);
2764 panel_toplevel_set_expand (toplevel, FALSE(0));
2765 panel_toplevel_update_attach_orientation (toplevel);
2766 panel_toplevel_update_hide_buttons (toplevel);
2767
2768 gtk_window_set_screen (GTK_WINDOW (toplevel)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_window_get_type ()))))))
,
2769 gtk_widget_get_screen (GTK_WIDGET (attach_toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((attach_toplevel)), ((gtk_widget_get_type ()))))))
));
2770 panel_toplevel_set_monitor (toplevel,
2771 panel_toplevel_get_monitor (attach_toplevel));
2772 if (toplevel->priv->state == PANEL_STATE_NORMAL)
2773 panel_toplevel_push_autohide_disabler (toplevel->priv->attach_toplevel);
2774
2775 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
2776}
2777
2778void
2779panel_toplevel_detach (PanelToplevel *toplevel)
2780{
2781 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
2782
2783 if (!toplevel->priv->attached)
2784 return;
2785
2786 if (toplevel->priv->state == PANEL_STATE_NORMAL)
2787 panel_toplevel_pop_autohide_disabler (toplevel->priv->attach_toplevel);
2788
2789 panel_toplevel_disconnect_attached (toplevel);
2790
2791 panel_toplevel_reverse_arrows (toplevel);
2792
2793 toplevel->priv->attached = FALSE(0);
2794
2795 toplevel->priv->attach_toplevel = NULL((void*)0);
2796 toplevel->priv->attach_widget = NULL((void*)0);
2797
2798 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
2799}
2800
2801gboolean
2802panel_toplevel_get_is_attached (PanelToplevel *toplevel)
2803{
2804 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return ((0));
} } while (0)
;
2805
2806 return toplevel->priv->attached;
2807}
2808
2809PanelToplevel *
2810panel_toplevel_get_attach_toplevel (PanelToplevel *toplevel)
2811{
2812 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return (((void
*)0)); } } while (0)
;
2813
2814 return toplevel->priv->attach_toplevel;
2815}
2816
2817GtkWidget *
2818panel_toplevel_get_attach_widget (PanelToplevel *toplevel)
2819{
2820 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return (((void
*)0)); } } while (0)
;
2821
2822 return toplevel->priv->attach_widget;
2823}
2824
2825static gboolean
2826panel_toplevel_popup_panel_menu (PanelToplevel *toplevel)
2827{
2828 gboolean retval = FALSE(0);
2829
2830 g_signal_emit_by_name (toplevel, "popup-menu", &retval);
2831
2832 return retval;
2833}
2834
2835static gboolean
2836panel_toplevel_toggle_expand (PanelToplevel *toplevel)
2837{
2838 panel_toplevel_set_expand (toplevel, !toplevel->priv->expand);
2839
2840 return TRUE(!(0));
2841}
2842
2843static gboolean
2844panel_toplevel_expand (PanelToplevel *toplevel)
2845{
2846 panel_toplevel_set_expand (toplevel, TRUE(!(0)));
2847
2848 return TRUE(!(0));
2849}
2850
2851static gboolean
2852panel_toplevel_unexpand (PanelToplevel *toplevel)
2853{
2854 panel_toplevel_set_expand (toplevel, FALSE(0));
2855
2856 return TRUE(!(0));
2857}
2858
2859static gboolean
2860panel_toplevel_toggle_hidden (PanelToplevel *toplevel)
2861{
2862 if (toplevel->priv->state == PANEL_STATE_NORMAL)
2863 panel_toplevel_hide (toplevel, toplevel->priv->auto_hide, -1);
2864 else
2865 panel_toplevel_unhide (toplevel);
2866
2867 return FALSE(0);
2868}
2869
2870static gboolean
2871panel_toplevel_begin_move (PanelToplevel *toplevel)
2872{
2873 if (toplevel->priv->grab_op != PANEL_GRAB_OP_NONE)
2874 return FALSE(0);
2875
2876 panel_toplevel_begin_grab_op (
2877 toplevel, PANEL_GRAB_OP_MOVE, TRUE(!(0)), GDK_CURRENT_TIME0L);
2878
2879 return TRUE(!(0));
2880}
2881
2882static gboolean
2883panel_toplevel_begin_resize (PanelToplevel *toplevel)
2884{
2885 if (toplevel->priv->grab_op != PANEL_GRAB_OP_NONE)
2886 return FALSE(0);
2887
2888 panel_toplevel_begin_grab_op (
2889 toplevel, PANEL_GRAB_OP_RESIZE, TRUE(!(0)), GDK_CURRENT_TIME0L);
2890
2891 return TRUE(!(0));
2892}
2893
2894static void
2895panel_toplevel_move_resize_window (PanelToplevel *toplevel,
2896 gboolean move,
2897 gboolean resize)
2898{
2899 GtkWidget *widget;
2900
2901 GList *list;
2902 gboolean stick;
2903
2904 widget = GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
;
2905
2906 g_assert (gtk_widget_get_realized (widget))do { if (gtk_widget_get_realized (widget)) ; else g_assertion_message_expr
(((gchar*) 0), "panel-toplevel.c", 2906, ((const char*) (__func__
)), "gtk_widget_get_realized (widget)"); } while (0)
;
2907
2908 if (move && resize)
2909 gdk_window_move_resize (gtk_widget_get_window (widget),
2910 toplevel->priv->geometry.x,
2911 toplevel->priv->geometry.y,
2912 toplevel->priv->geometry.width,
2913 toplevel->priv->geometry.height);
2914 else if (move)
2915 gdk_window_move (gtk_widget_get_window (widget),
2916 toplevel->priv->geometry.x,
2917 toplevel->priv->geometry.y);
2918 else if (resize)
2919 gdk_window_resize (gtk_widget_get_window (widget),
2920 toplevel->priv->geometry.width,
2921 toplevel->priv->geometry.height);
2922
2923 if (resize || move) {
2924 for (list = toplevel->priv->panel_widget->applet_list; list != NULL((void*)0); list = g_list_next (list)((list) ? (((GList *)(list))->next) : ((void*)0))) {
2925 AppletData *ad = list->data;
2926 const char *id = mate_panel_applet_get_id_by_widget (ad->applet);
2927
2928 if (!id)
2929 return;
2930
2931 AppletInfo *info;
2932 info = mate_panel_applet_get_by_id (id);
2933
2934 stick = g_settings_get_boolean (info->settings, PANEL_OBJECT_PANEL_RIGHT_STICK_KEY"panel-right-stick");
2935
2936 if (stick) {
2937 int position = g_settings_get_int (info->settings, PANEL_OBJECT_POSITION_KEY"position");
2938 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)) {
2939 ad->pos = toplevel->priv->geometry.width - position;
2940 } else {
2941 ad->pos = toplevel->priv->geometry.height - position;
2942 }
2943 }
2944 }
2945 }
2946}
2947
2948static void
2949panel_toplevel_initially_hide (PanelToplevel *toplevel)
2950{
2951 if (!toplevel->priv->attached) {
2952 toplevel->priv->initial_animation_done = FALSE(0);
2953
2954 /* We start the panel off hidden until all the applets are
2955 * loaded, and then finally slide it down when it's ready to be
2956 * used */
2957 toplevel->priv->state = PANEL_STATE_AUTO_HIDDEN;
2958 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
2959 } else
2960 toplevel->priv->initial_animation_done = TRUE(!(0));
2961}
2962
2963static void
2964set_background_default_style (GtkWidget *widget)
2965{
2966 PanelToplevel *toplevel;
2967 GtkStyleContext *context;
2968 GtkStateFlags state;
2969 GdkRGBA *bg_color;
2970 cairo_pattern_t *bg_image;
2971
2972 if (!gtk_widget_get_realized (widget))
2973 return;
2974
2975 toplevel = PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
;
2976
2977 context = gtk_widget_get_style_context (widget);
2978 state = gtk_style_context_get_state (context);
2979
2980 gtk_style_context_get (context, state,
2981 "background-color", &bg_color,
2982 "background-image", &bg_image,
2983 NULL((void*)0));
2984
2985 panel_background_set_default_style (&toplevel->background,
2986 bg_color, bg_image);
2987
2988 if (bg_color)
2989 gdk_rgba_free (bg_color);
2990
2991 if (bg_image)
2992 cairo_pattern_destroy (bg_image);
2993}
2994
2995static void
2996panel_toplevel_realize (GtkWidget *widget)
2997{
2998 PanelToplevel *toplevel;
2999 GdkScreen *screen;
3000 GdkVisual *visual;
3001 GdkWindow *window;
3002
3003 toplevel = PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
;
3004
3005 screen = gtk_widget_get_screen (widget);
3006 visual = gdk_screen_get_rgba_visual (screen);
3007
3008 if (visual == NULL((void*)0))
3009 visual = gdk_screen_get_system_visual (screen);
3010
3011 gtk_widget_set_visual (widget, visual);
3012 gtk_window_stick (GTK_WINDOW (widget)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_window_get_type ()))))))
);
3013 gtk_window_set_decorated (GTK_WINDOW (widget)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_window_get_type ()))))))
, FALSE(0));
3014 gtk_window_stick (GTK_WINDOW (widget)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_window_get_type ()))))))
);
3015 gtk_window_set_type_hint (GTK_WINDOW (widget)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_window_get_type ()))))))
, GDK_WINDOW_TYPE_HINT_DOCK);
3016
3017 GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->realize (widget);
3018
3019 window = gtk_widget_get_window (widget);
3020 set_background_default_style (widget);
3021 panel_background_realized (&toplevel->background, window);
3022
3023#ifdef HAVE_X111
3024 if (GDK_IS_X11_WINDOW (window)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(window)); GType __t = ((gdk_x11_window_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
) {
3025 panel_struts_set_window_hint (toplevel);
3026 gdk_window_set_geometry_hints (window, NULL((void*)0), 0);
3027 }
3028#endif /* HAVE_X11 */
3029
3030 gdk_window_set_group (window, window);
3031 panel_toplevel_initially_hide (toplevel);
3032
3033 panel_toplevel_move_resize_window (toplevel, TRUE(!(0)), TRUE(!(0)));
3034}
3035
3036static void
3037panel_toplevel_disconnect_timeouts (PanelToplevel *toplevel)
3038{
3039 if (toplevel->priv->hide_timeout)
3040 g_source_remove (toplevel->priv->hide_timeout);
3041 toplevel->priv->hide_timeout = 0;
3042
3043 if (toplevel->priv->unhide_timeout)
3044 g_source_remove (toplevel->priv->unhide_timeout);
3045 toplevel->priv->unhide_timeout = 0;
3046
3047 if (toplevel->priv->animation_timeout)
3048 g_source_remove (toplevel->priv->animation_timeout);
3049 toplevel->priv->animation_timeout = 0;
3050}
3051
3052static void
3053panel_toplevel_unrealize (GtkWidget *widget)
3054{
3055 PanelToplevel *toplevel;
3056 toplevel = PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
;
3057 panel_toplevel_disconnect_timeouts (toplevel);
3058 panel_background_unrealized (&toplevel->background);
3059 GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->unrealize (widget);
3060}
3061
3062static void
3063panel_toplevel_dispose (GObject *widget)
3064{
3065 PanelToplevel *toplevel = (PanelToplevel *) widget;
3066
3067 g_clear_pointer (&toplevel->priv->settings_path, g_free)do { _Static_assert (sizeof *(&toplevel->priv->settings_path
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
((&toplevel->priv->settings_path)) _pp = (&toplevel
->priv->settings_path); __typeof__ (*(&toplevel->
priv->settings_path)) _ptr = *_pp; *_pp = ((void*)0); if (
_ptr) (g_free) (_ptr); } while (0)
;
3068
3069 if (toplevel->settings) {
3070 g_signal_handlers_disconnect_by_data (toplevel->settings, toplevel)g_signal_handlers_disconnect_matched ((toplevel->settings)
, G_SIGNAL_MATCH_DATA, 0, 0, ((void*)0), ((void*)0), (toplevel
))
;
3071 g_clear_object (&toplevel->settings)do { _Static_assert (sizeof *((&toplevel->settings)) ==
sizeof (gpointer), "Expression evaluates to false"); __typeof__
(((&toplevel->settings))) _pp = ((&toplevel->settings
)); __typeof__ (*((&toplevel->settings))) _ptr = *_pp;
*_pp = ((void*)0); if (_ptr) (g_object_unref) (_ptr); } while
(0)
;
3072 }
3073
3074 g_clear_object (&toplevel->queued_settings)do { _Static_assert (sizeof *((&toplevel->queued_settings
)) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(((&toplevel->queued_settings))) _pp = ((&toplevel
->queued_settings)); __typeof__ (*((&toplevel->queued_settings
))) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (g_object_unref
) (_ptr); } while (0)
;
3075
3076 if (toplevel->background_settings) {
3077 g_signal_handlers_disconnect_by_data (toplevel->background_settings, toplevel)g_signal_handlers_disconnect_matched ((toplevel->background_settings
), G_SIGNAL_MATCH_DATA, 0, 0, ((void*)0), ((void*)0), (toplevel
))
;
3078 g_clear_object (&toplevel->background_settings)do { _Static_assert (sizeof *((&toplevel->background_settings
)) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(((&toplevel->background_settings))) _pp = ((&toplevel
->background_settings)); __typeof__ (*((&toplevel->
background_settings))) _ptr = *_pp; *_pp = ((void*)0); if (_ptr
) (g_object_unref) (_ptr); } while (0)
;
3079 }
3080
3081 if (toplevel->priv->gtk_settings) {
3082 g_signal_handlers_disconnect_by_func (toplevel->priv->gtk_settings,g_signal_handlers_disconnect_matched ((toplevel->priv->
gtk_settings), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (panel_toplevel_drag_threshold_changed
))), (toplevel))
3083 G_CALLBACK (panel_toplevel_drag_threshold_changed),g_signal_handlers_disconnect_matched ((toplevel->priv->
gtk_settings), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (panel_toplevel_drag_threshold_changed
))), (toplevel))
3084 toplevel)g_signal_handlers_disconnect_matched ((toplevel->priv->
gtk_settings), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (panel_toplevel_drag_threshold_changed
))), (toplevel))
;
3085 toplevel->priv->gtk_settings = NULL((void*)0);
3086
3087 panel_background_free (&toplevel->background);
3088 }
3089
3090 if (toplevel->priv->attached) {
3091 panel_toplevel_disconnect_attached (toplevel);
3092 toplevel->priv->attached = FALSE(0);
3093
3094 toplevel->priv->attach_toplevel = NULL((void*)0);
3095 toplevel->priv->attach_widget = NULL((void*)0);
3096 }
3097
3098 g_clear_pointer (&toplevel->priv->description, g_free)do { _Static_assert (sizeof *(&toplevel->priv->description
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
((&toplevel->priv->description)) _pp = (&toplevel
->priv->description); __typeof__ (*(&toplevel->priv
->description)) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (
g_free) (_ptr); } while (0)
;
3099 g_clear_pointer (&toplevel->priv->name, g_free)do { _Static_assert (sizeof *(&toplevel->priv->name
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
((&toplevel->priv->name)) _pp = (&toplevel->
priv->name); __typeof__ (*(&toplevel->priv->name
)) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (g_free) (_ptr);
} while (0)
;
3100
3101 panel_toplevel_disconnect_timeouts (toplevel);
3102
3103 G_OBJECT_CLASS (panel_toplevel_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), (((GType) ((20) << (
2))))))))
->dispose (widget);
3104}
3105
3106static void
3107panel_toplevel_check_resize (GtkContainer *container)
3108{
3109 GtkAllocation allocation;
3110 GtkRequisition requisition;
3111 GtkWidget *widget;
3112
3113 widget = GTK_WIDGET (container)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((container)), ((gtk_widget_get_type ()))))))
;
3114
3115 if (!gtk_widget_get_visible (widget))
3116 return;
3117
3118 requisition.width = -1;
3119 requisition.height = -1;
3120
3121 gtk_widget_get_preferred_size (widget, &requisition, NULL((void*)0));
3122 gtk_widget_get_allocation (widget, &allocation);
3123
3124 allocation.width = requisition.width;
3125 allocation.height = requisition.height;
3126
3127 gtk_widget_size_allocate (widget, &allocation);
3128}
3129
3130static void
3131panel_toplevel_size_request (GtkWidget *widget,
3132 GtkRequisition *requisition)
3133{
3134 PanelToplevel *toplevel;
3135 GtkBin *bin;
3136 GtkWidget *child;
3137 GdkRectangle old_geometry;
3138 int position_changed = FALSE(0);
3139 int size_changed = FALSE(0);
3140
3141 toplevel = PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
;
3142 bin = GTK_BIN (widget)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_bin_get_type ()))))))
;
3143
3144 /* we get a size request when there are new monitors, so first try to
3145 * see if we need to move to a new monitor */
3146 panel_toplevel_update_monitor (toplevel);
3147
3148 child = gtk_bin_get_child (bin);
3149 if (child && gtk_widget_get_visible (child))
2
Assuming 'child' is null
3150 gtk_widget_get_preferred_size (child, requisition, NULL((void*)0));
3151
3152 old_geometry = toplevel->priv->geometry;
3153
3154 panel_toplevel_update_geometry (toplevel, requisition);
3
Calling 'panel_toplevel_update_geometry'
3155
3156 requisition->width = toplevel->priv->geometry.width;
3157 requisition->height = toplevel->priv->geometry.height;
3158
3159 if (!gtk_widget_get_realized (widget))
3160 return;
3161
3162 if (old_geometry.width != toplevel->priv->geometry.width ||
3163 old_geometry.height != toplevel->priv->geometry.height)
3164 size_changed = TRUE(!(0));
3165
3166 if (old_geometry.x != toplevel->priv->geometry.x ||
3167 old_geometry.y != toplevel->priv->geometry.y)
3168 position_changed = TRUE(!(0));
3169
3170 panel_toplevel_move_resize_window (toplevel, position_changed, size_changed);
3171}
3172
3173static void
3174panel_toplevel_get_preferred_width (GtkWidget *widget,
3175 gint *minimum_width,
3176 gint *natural_width)
3177{
3178 GtkRequisition req;
3179 panel_toplevel_size_request (widget, &req);
3180 *minimum_width = *natural_width = req.width;
3181}
3182
3183static void
3184panel_toplevel_get_preferred_height (GtkWidget *widget,
3185 gint *minimum_height,
3186 gint *natural_height)
3187{
3188 GtkRequisition req;
3189 panel_toplevel_size_request (widget, &req);
1
Calling 'panel_toplevel_size_request'
3190 *minimum_height = *natural_height = req.height;
3191}
3192
3193static void
3194set_background_region (PanelToplevel *toplevel)
3195{
3196 GtkWidget *widget;
3197 GdkWindow *window;
3198 gint origin_x;
3199 gint origin_y;
3200 GtkAllocation allocation;
3201 GtkOrientation orientation;
3202
3203 widget = GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
;
3204
3205 if (!gtk_widget_get_realized (widget))
3206 return;
3207
3208 window = gtk_widget_get_window (widget);
3209 origin_x = -1;
3210 origin_y = -1;
3211
3212 gdk_window_get_origin (window, &origin_x, &origin_y);
3213 gtk_widget_get_allocation (widget, &allocation);
3214
3215 orientation = GTK_ORIENTATION_HORIZONTAL;
3216 if (toplevel->priv->orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT))
3217 orientation = GTK_ORIENTATION_VERTICAL;
3218
3219 panel_background_change_region (&toplevel->background, orientation,
3220 origin_x, origin_y,
3221 allocation.width, allocation.height);
3222}
3223
3224static void
3225panel_toplevel_size_allocate (GtkWidget *widget,
3226 GtkAllocation *allocation)
3227{
3228 PanelToplevel *toplevel = (PanelToplevel *) widget;
3229 GtkBin *bin = (GtkBin *) widget;
3230 GtkStyleContext *context;
3231 GtkStateFlags state;
3232 GtkBorder padding;
3233 GtkWidget *child;
3234 GtkAllocation challoc;
3235 GtkAllocation child_allocation;
3236
3237 gtk_widget_set_allocation (widget, allocation);
3238
3239 if (toplevel->priv->expand ||
3240 toplevel->priv->buttons_enabled ||
3241 toplevel->priv->attached)
3242 challoc = *allocation;
3243 else {
3244 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)) {
3245 challoc.x = HANDLE_SIZE10;
3246 challoc.y = 0;
3247 challoc.width = allocation->width - 2 * HANDLE_SIZE10;
3248 challoc.height = allocation->height;
3249 } else {
3250 challoc.x = 0;
3251 challoc.y = HANDLE_SIZE10;
3252 challoc.width = allocation->width;
3253 challoc.height = allocation->height - 2 * HANDLE_SIZE10;
3254 }
3255 }
3256
3257 state = gtk_widget_get_state_flags (widget);
3258 context = gtk_widget_get_style_context (widget);
3259 gtk_style_context_get_padding (context, state, &padding);
3260
3261 if (toplevel->priv->edges & PANEL_EDGE_TOP) {
3262 challoc.y += padding.top;
3263 challoc.height -= padding.top;
3264 }
3265
3266 if (toplevel->priv->edges & PANEL_EDGE_LEFT) {
3267 challoc.x += padding.left;
3268 challoc.width -= padding.left;
3269 }
3270
3271 if (toplevel->priv->edges & PANEL_EDGE_BOTTOM)
3272 challoc.height -= padding.bottom;
3273
3274 if (toplevel->priv->edges & PANEL_EDGE_RIGHT)
3275 challoc.width -= padding.right;
3276
3277 challoc.width = MAX (1, challoc.width)(((1) > (challoc.width)) ? (1) : (challoc.width));
3278 challoc.height = MAX (1, challoc.height)(((1) > (challoc.height)) ? (1) : (challoc.height));
3279
3280 child = gtk_bin_get_child (bin);
3281 gtk_widget_get_allocation (child, &child_allocation);
3282
3283 if (gtk_widget_get_mapped (widget) &&
3284 (challoc.x != child_allocation.x ||
3285 challoc.y != child_allocation.y ||
3286 challoc.width != child_allocation.width ||
3287 challoc.height != child_allocation.height)) {
3288 GtkAllocation allocation_to_invalidate;
3289
3290 gtk_widget_get_allocation (widget, &allocation_to_invalidate);
3291 gdk_window_invalidate_rect (gtk_widget_get_window (widget),
3292 &allocation_to_invalidate, FALSE(0));
3293 }
3294
3295 if (child && gtk_widget_get_visible (child))
3296 gtk_widget_size_allocate (child, &challoc);
3297
3298 set_background_region (toplevel);
3299}
3300
3301static gboolean panel_toplevel_draw(GtkWidget* widget, cairo_t* cr)
3302{
3303 PanelToplevel* toplevel = (PanelToplevel*) widget;
3304 PanelFrameEdge edges;
3305 gboolean retval = FALSE(0);
3306 int awidth;
3307 int aheight;
3308 GtkStyleContext *context;
3309 GtkStateFlags state;
3310 GtkBorder padding;
3311
3312 if (!gtk_widget_is_drawable (widget))
3313 return retval;
3314
3315 if (GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->draw)
3316 retval = GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->draw (widget, cr);
3317
3318 edges = toplevel->priv->edges;
3319 panel_frame_draw (widget, cr, edges);
3320
3321 if (toplevel->priv->expand ||
3322 toplevel->priv->buttons_enabled ||
3323 toplevel->priv->attached)
3324 return retval;
3325
3326 state = gtk_widget_get_state_flags (widget);
3327 awidth = gtk_widget_get_allocated_width (widget);
3328 aheight = gtk_widget_get_allocated_height (widget);
3329
3330 context = gtk_widget_get_style_context (widget);
3331 gtk_style_context_get_padding (context, state, &padding);
3332
3333 gtk_style_context_save (context);
3334 gtk_style_context_set_state (context, state);
3335
3336 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)) {
3337 int x, y, width, height;
3338
3339 x = 0;
3340 y = 0;
3341 height = aheight;
3342 width = HANDLE_SIZE10;
3343
3344 if (edges & PANEL_EDGE_TOP) {
3345 y += padding.top;
3346 height -= padding.top;
3347 }
3348 if (edges & PANEL_EDGE_BOTTOM)
3349 height -= padding.bottom;
3350 if (edges & PANEL_EDGE_LEFT)
3351 x += padding.left;
3352
3353 cairo_save (cr);
3354 gtk_render_handle (context, cr, x, y, width, height);
3355 cairo_restore (cr);
3356
3357 x = awidth - HANDLE_SIZE10;
3358 if (edges & PANEL_EDGE_RIGHT)
3359 x -= padding.right;
3360
3361 cairo_save (cr);
3362 gtk_render_handle (context, cr, x, y, width, height);
3363 cairo_restore (cr);
3364 } else {
3365 int x, y, width, height;
3366
3367 x = 0;
3368 y = 0;
3369 width = awidth;
3370 height = HANDLE_SIZE10;
3371
3372 if (edges & PANEL_EDGE_LEFT) {
3373 x += padding.left;
3374 width -= padding.left;
3375 }
3376 if (edges & PANEL_EDGE_RIGHT)
3377 width -= padding.right;
3378 if (edges & PANEL_EDGE_TOP)
3379 y += padding.top;
3380
3381 cairo_save (cr);
3382 gtk_render_handle (context, cr, x, y, width, height);
3383 cairo_restore (cr);
3384
3385 y = aheight - HANDLE_SIZE10;
3386 if (edges & PANEL_EDGE_BOTTOM)
3387 y -= padding.bottom;
3388
3389 cairo_save (cr);
3390 gtk_render_handle (context, cr, x, y, width, height);
3391 cairo_restore (cr);
3392 }
3393
3394 gtk_style_context_restore (context);
3395
3396 return retval;
3397}
3398
3399static gboolean
3400panel_toplevel_button_press_event (GtkWidget *widget,
3401 GdkEventButton *event)
3402{
3403 PanelToplevel *toplevel;
3404 GtkWidget *event_widget;
3405
3406 g_return_val_if_fail (PANEL_IS_TOPLEVEL (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (widget)"); return ((0)); }
} while (0)
;
3407
3408 toplevel = PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
;
3409
3410 if (event->button != 1 && event->button != 2)
3411 return FALSE(0);
3412
3413 if (toplevel->priv->animating)
3414 return FALSE(0);
3415
3416 /* Get the mouse-button modifier from marco so that only intentional
3417 * moves are considered. We don't this for non-expanded panels since we
3418 * only have the handles that the user can grab. */
3419 if ((toplevel->priv->expand || toplevel->priv->attached) &&
3420 (event->state & GDK_MODIFIER_MASK) != panel_bindings_get_mouse_button_modifier_keymask ())
3421 return FALSE(0);
3422
3423 gdk_window_get_user_data (event->window, (gpointer)&event_widget);
3424 g_assert (GTK_IS_WIDGET (event_widget))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((event_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_assertion_message_expr (((gchar*) 0), "panel-toplevel.c", 3424
, ((const char*) (__func__)), "GTK_IS_WIDGET (event_widget)")
; } while (0)
;
3425 gtk_widget_translate_coordinates (event_widget,
3426 widget,
3427 event->x,
3428 event->y,
3429 &toplevel->priv->drag_offset_x,
3430 &toplevel->priv->drag_offset_y);
3431
3432 panel_toplevel_begin_grab_op (toplevel, PANEL_GRAB_OP_MOVE, FALSE(0), event->time);
3433
3434 return TRUE(!(0));
3435}
3436
3437static gboolean
3438panel_toplevel_button_release_event (GtkWidget *widget,
3439 GdkEventButton *event)
3440{
3441 PanelToplevel *toplevel;
3442
3443 if (event->button != 1 && event->button != 2)
3444 return FALSE(0);
3445
3446 toplevel = PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
;
3447
3448 if (toplevel->priv->grab_op == PANEL_GRAB_OP_NONE)
3449 return FALSE(0);
3450
3451 if (toplevel->priv->grab_is_keyboard)
3452 return FALSE(0);
3453
3454 panel_toplevel_end_grab_op (toplevel, event->time);
3455
3456 return TRUE(!(0));
3457}
3458
3459static gboolean
3460panel_toplevel_configure_event (GtkWidget *widget,
3461 GdkEventConfigure *event)
3462{
3463 PanelToplevel *toplevel;
3464
3465 toplevel = PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
;
3466
3467 set_background_region (toplevel);
3468
3469 return TRUE(!(0));
3470}
3471
3472static gboolean
3473panel_toplevel_key_press_event (GtkWidget *widget,
3474 GdkEventKey *event)
3475{
3476 PanelToplevel *toplevel = (PanelToplevel *) widget;
3477
3478 if (toplevel->priv->grab_op != PANEL_GRAB_OP_NONE &&
3479 panel_toplevel_handle_grab_op_key_event (toplevel, event))
3480 return TRUE(!(0));
3481
3482 if (GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->key_press_event)
3483 return GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->key_press_event (widget, event);
3484
3485 return FALSE(0);
3486}
3487
3488static void
3489panel_toplevel_state_flags_changed (GtkWidget *widget,
3490 GtkStateFlags previous_state)
3491{
3492 GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->state_flags_changed (widget,
3493 previous_state);
3494
3495 set_background_default_style (widget);
3496}
3497
3498static gboolean
3499panel_toplevel_motion_notify_event (GtkWidget *widget,
3500 GdkEventMotion *event)
3501{
3502 if (gdk_event_get_screen ((GdkEvent *)event) ==
3503 gtk_window_get_screen (GTK_WINDOW (widget)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_window_get_type ()))))))
))
3504 return panel_toplevel_handle_grab_op_motion_event (
3505 PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
, event);
3506 else
3507 return FALSE(0);
3508}
3509
3510static gboolean
3511panel_toplevel_animation_timeout (PanelToplevel *toplevel)
3512{
3513 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
3514
3515 if (!toplevel->priv->animating) {
3516 toplevel->priv->animation_end_x = 0xdead;
3517 toplevel->priv->animation_end_y = 0xdead;
3518 toplevel->priv->animation_end_width = 0xdead;
3519 toplevel->priv->animation_end_height = 0xdead;
3520 toplevel->priv->animation_start_time = 0xdead;
3521 toplevel->priv->animation_duration_time = 0xdead;
3522 toplevel->priv->animation_timeout = 0;
3523 toplevel->priv->initial_animation_done = TRUE(!(0));
3524 }
3525
3526 return toplevel->priv->animating;
3527}
3528
3529static GTimeSpan
3530panel_toplevel_get_animation_time (PanelToplevel *toplevel)
3531{
3532 /* The number of seconds to complete the animation.
3533 */
3534#define ANIMATION_TIME_FAST 400
3535#define ANIMATION_TIME_MEDIUM 1200
3536#define ANIMATION_TIME_SLOW 2000
3537
3538 GTimeSpan t;
3539
3540 switch (toplevel->priv->animation_speed) {
3541 case PANEL_ANIMATION_SLOW:
3542 t = ANIMATION_TIME_SLOW * G_TIME_SPAN_MILLISECOND((1000L));
3543 break;
3544 case PANEL_ANIMATION_MEDIUM:
3545 t = ANIMATION_TIME_MEDIUM * G_TIME_SPAN_MILLISECOND((1000L));
3546 break;
3547 case PANEL_ANIMATION_FAST:
3548 t = ANIMATION_TIME_FAST * G_TIME_SPAN_MILLISECOND((1000L));
3549 break;
3550 default:
3551 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 3551, ((const char*) (__func__)), ((void*)0)); } while (0)
;
3552 break;
3553 }
3554
3555 return t;
3556
3557#undef ANIMATION_TIME_FAST
3558#undef ANIMATION_TIME_MEDIUM
3559#undef ANIMATION_TIME_SLOW
3560}
3561
3562static void
3563panel_toplevel_calculate_animation_end_geometry (PanelToplevel *toplevel)
3564{
3565 GdkRectangle monitor_geom;
3566
3567 toplevel->priv->animation_end_x = toplevel->priv->x;
3568 toplevel->priv->animation_end_y = toplevel->priv->y;
3569 toplevel->priv->animation_end_width = -1;
3570 toplevel->priv->animation_end_height = -1;
3571
3572 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
3573
3574 if (!toplevel->priv->expand) {
3575
3576 if (toplevel->priv->x_centered)
3577 toplevel->priv->animation_end_x =
3578 (monitor_geom.width - toplevel->priv->geometry.width) / 2;
3579 if (toplevel->priv->y_centered)
3580 toplevel->priv->animation_end_y =
3581 (monitor_geom.height - toplevel->priv->geometry.height) / 2;
3582 }
3583
3584 /* we consider the toplevels which are in the initial animation stage
3585 * as in a normal state */
3586 if (toplevel->priv->state == PANEL_STATE_NORMAL ||
3587 (!toplevel->priv->initial_animation_done &&
3588 !toplevel->priv->auto_hide))
3589 panel_toplevel_update_normal_position (toplevel,
3590 &toplevel->priv->animation_end_x,
3591 &toplevel->priv->animation_end_y,
3592 &toplevel->priv->animation_end_width,
3593 &toplevel->priv->animation_end_height);
3594
3595 else if (toplevel->priv->state == PANEL_STATE_AUTO_HIDDEN)
3596 panel_toplevel_update_auto_hide_position (toplevel,
3597 &toplevel->priv->animation_end_x,
3598 &toplevel->priv->animation_end_y,
3599 &toplevel->priv->animation_end_width,
3600 &toplevel->priv->animation_end_height,
3601 TRUE(!(0)));
3602 else
3603 panel_toplevel_update_hidden_position (toplevel,
3604 &toplevel->priv->animation_end_x,
3605 &toplevel->priv->animation_end_y,
3606 &toplevel->priv->animation_end_width,
3607 &toplevel->priv->animation_end_height);
3608}
3609
3610static void
3611panel_toplevel_start_animation (PanelToplevel *toplevel)
3612{
3613 GtkRequisition requisition;
3614 int deltax, deltay, deltaw = 0, deltah = 0;
3615 int cur_x = -1, cur_y = -1;
3616
3617 panel_toplevel_calculate_animation_end_geometry (toplevel);
3618
3619 toplevel->priv->animating = TRUE(!(0));
3620
3621 panel_toplevel_update_struts (toplevel, TRUE(!(0)));
3622#ifdef HAVE_X111
3623 if (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel)))(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gtk_widget_get_display (((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((toplevel)), ((gtk_widget_get_type ()))))
))))); GType __t = ((gdk_x11_display_get_type())); gboolean __r
; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
) {
3624 panel_struts_update_toplevel_geometry (toplevel,
3625 &toplevel->priv->animation_end_x,
3626 &toplevel->priv->animation_end_y,
3627 &toplevel->priv->animation_end_width,
3628 &toplevel->priv->animation_end_height);
3629 }
3630#endif /* HAVE_X11 */
3631 panel_toplevel_update_struts (toplevel, FALSE(0));
3632
3633 gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
), &cur_x, &cur_y);
3634
3635 cur_x -= panel_multimonitor_x (toplevel->priv->monitor);
3636 cur_y -= panel_multimonitor_y (toplevel->priv->monitor);
3637
3638 deltax = toplevel->priv->animation_end_x - cur_x;
3639 deltay = toplevel->priv->animation_end_y - cur_y;
3640
3641 gtk_widget_get_preferred_size (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
, &requisition, NULL((void*)0));
3642
3643 if (toplevel->priv->animation_end_width != -1)
3644 deltaw = toplevel->priv->animation_end_width - requisition.width;
3645
3646 if (toplevel->priv->animation_end_height != -1)
3647 deltah = toplevel->priv->animation_end_height - requisition.height;
3648
3649 if (deltax == 0 && deltay == 0 && deltaw == 0 && deltah == 0) {
3650 toplevel->priv->animation_end_x = -1;
3651 toplevel->priv->animation_end_y = -1;
3652 toplevel->priv->animation_end_width = -1;
3653 toplevel->priv->animation_end_height = -1;
3654 toplevel->priv->animating = FALSE(0);
3655 return;
3656 }
3657
3658 if (toplevel->priv->attached) {
3659 /* Re-map unmapped attached toplevels */
3660 if (!gtk_widget_get_visible (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
))
3661 gtk_widget_set_visible (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
, TRUE(!(0)));
3662
3663 if (!gtk_widget_get_mapped (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
))
3664 gtk_widget_map (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
3665
3666 gtk_window_present (GTK_WINDOW (toplevel->priv->attach_toplevel)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->attach_toplevel)), ((gtk_window_get_type
()))))))
);
3667 }
3668
3669 toplevel->priv->animation_start_time = g_get_monotonic_time ();
3670 toplevel->priv->animation_duration_time = panel_toplevel_get_animation_time (toplevel);
3671
3672 if (!toplevel->priv->animation_timeout)
3673 toplevel->priv->animation_timeout =
3674 g_timeout_add (20, (GSourceFunc) panel_toplevel_animation_timeout, toplevel);
3675}
3676
3677void
3678panel_toplevel_hide (PanelToplevel *toplevel,
3679 gboolean auto_hide,
3680 gint direction)
3681{
3682 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
3683
3684 if (toplevel->priv->state != PANEL_STATE_NORMAL)
3685 return;
3686
3687 g_signal_emit (toplevel, toplevel_signals [HIDE_SIGNAL], 0);
3688
3689 if (toplevel->priv->attach_toplevel)
3690 panel_toplevel_pop_autohide_disabler (toplevel->priv->attach_toplevel);
3691
3692 if (auto_hide)
3693 toplevel->priv->state = PANEL_STATE_AUTO_HIDDEN;
3694 else {
3695 GtkDirectionType hide_direction;
3696
3697 if (direction == -1) {
3698 if (toplevel->priv->orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT))
3699 hide_direction = GTK_DIR_UP;
3700 else
3701 hide_direction = GTK_DIR_LEFT;
3702 } else {
3703 hide_direction = (GtkDirectionType) direction;
3704 }
3705
3706 switch (hide_direction) {
3707 case GTK_DIR_UP:
3708 g_return_if_fail (toplevel->priv->orientation & PANEL_VERTICAL_MASK)do { if ((toplevel->priv->orientation & (PANEL_ORIENTATION_LEFT
| PANEL_ORIENTATION_RIGHT))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "toplevel->priv->orientation & PANEL_VERTICAL_MASK"
); return; } } while (0)
;
3709 toplevel->priv->state = PANEL_STATE_HIDDEN_UP;
3710 break;
3711 case GTK_DIR_DOWN:
3712 g_return_if_fail (toplevel->priv->orientation & PANEL_VERTICAL_MASK)do { if ((toplevel->priv->orientation & (PANEL_ORIENTATION_LEFT
| PANEL_ORIENTATION_RIGHT))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "toplevel->priv->orientation & PANEL_VERTICAL_MASK"
); return; } } while (0)
;
3713 toplevel->priv->state = PANEL_STATE_HIDDEN_DOWN;
3714 break;
3715 case GTK_DIR_LEFT:
3716 g_return_if_fail (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK)do { if ((toplevel->priv->orientation & (PANEL_ORIENTATION_TOP
| PANEL_ORIENTATION_BOTTOM))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "toplevel->priv->orientation & PANEL_HORIZONTAL_MASK"
); return; } } while (0)
;
3717 toplevel->priv->state = PANEL_STATE_HIDDEN_LEFT;
3718 break;
3719 case GTK_DIR_RIGHT:
3720 g_return_if_fail (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK)do { if ((toplevel->priv->orientation & (PANEL_ORIENTATION_TOP
| PANEL_ORIENTATION_BOTTOM))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "toplevel->priv->orientation & PANEL_HORIZONTAL_MASK"
); return; } } while (0)
;
3721 toplevel->priv->state = PANEL_STATE_HIDDEN_RIGHT;
3722 break;
3723 default:
3724 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 3724, ((const char*) (__func__)), ((void*)0)); } while (0)
;
3725 break;
3726 }
3727
3728 panel_toplevel_update_hide_buttons (toplevel);
3729 }
3730
3731 if (toplevel->priv->animate && gtk_widget_get_realized (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
)) {
3732 panel_toplevel_start_animation (toplevel);
3733 }
3734
3735 /* if the toplevel is attached (-> drawer), hide it after the animation
3736 * this hides the hide button properly as well */
3737 if (toplevel->priv->attached) {
3738 gtk_widget_hide (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
3739 }
3740
3741 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
3742}
3743
3744static gboolean
3745panel_toplevel_auto_hide_timeout_handler (PanelToplevel *toplevel)
3746{
3747 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return ((0));
} } while (0)
;
3748
3749 if (panel_toplevel_get_autohide_disabled (toplevel)) {
3750 toplevel->priv->hide_timeout = 0;
3751 return FALSE(0);
3752 }
3753
3754 /* keep coming back until the animation has finished.
3755 * FIXME: we should really remove the timeout/idle
3756 * completely and re-instate it when the
3757 * animation has finished.
3758 */
3759 if (toplevel->priv->animating)
3760 return TRUE(!(0));
3761
3762 panel_toplevel_hide (toplevel, TRUE(!(0)), -1);
3763
3764 toplevel->priv->hide_timeout = 0;
3765
3766 return FALSE(0);
3767}
3768
3769void
3770panel_toplevel_unhide (PanelToplevel *toplevel)
3771{
3772 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
3773
3774 if (toplevel->priv->state == PANEL_STATE_NORMAL)
3775 return;
3776
3777 toplevel->priv->state = PANEL_STATE_NORMAL;
3778
3779 panel_toplevel_update_hide_buttons (toplevel);
3780
3781 if (toplevel->priv->attach_toplevel)
3782 panel_toplevel_push_autohide_disabler (toplevel->priv->attach_toplevel);
3783
3784 if (toplevel->priv->animate && gtk_widget_get_realized (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
)) {
3785 panel_toplevel_start_animation (toplevel);
3786 }
3787
3788 /* if the toplevel is attached (-> drawer), unhide it after the animation
3789 * (same as for hide) */
3790 if (toplevel->priv->attached) {
3791 gtk_widget_show (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
3792 }
3793
3794 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
3795
3796 if (!toplevel->priv->animate)
3797 g_signal_emit (toplevel, toplevel_signals [UNHIDE_SIGNAL], 0);
3798}
3799
3800static gboolean
3801panel_toplevel_auto_unhide_timeout_handler (PanelToplevel *toplevel)
3802{
3803 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return ((0));
} } while (0)
;
3804
3805 /* keep coming back until the animation has finished.
3806 * FIXME: we should really remove the timeout/idle
3807 * completely and re-instate it when the
3808 * animation has finished.
3809 */
3810 if (toplevel->priv->animating)
3811 return TRUE(!(0));
3812
3813 if (!toplevel->priv->animate)
3814 toplevel->priv->initial_animation_done = TRUE(!(0));
3815
3816 /* initial animation for auto-hidden panels: we need to unhide and hide
3817 * again to get at the right size */
3818 if (!toplevel->priv->initial_animation_done &&
3819 toplevel->priv->auto_hide) {
3820 toplevel->priv->unhide_timeout = 0;
3821 panel_toplevel_unhide (toplevel);
3822 panel_toplevel_hide (toplevel, TRUE(!(0)), -1);
3823 return FALSE(0);
3824 }
3825
3826 if (!panel_toplevel_contains_pointer (toplevel) &&
3827 toplevel->priv->auto_hide) {
3828 toplevel->priv->unhide_timeout = 0;
3829 return FALSE(0);
3830 }
3831
3832 panel_toplevel_unhide (toplevel);
3833
3834 toplevel->priv->unhide_timeout = 0;
3835
3836 return FALSE(0);
3837}
3838
3839void
3840panel_toplevel_queue_auto_hide (PanelToplevel *toplevel)
3841{
3842 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
3843
3844 if (!toplevel->priv->auto_hide ||
3845 panel_toplevel_contains_pointer (toplevel) ||
3846 panel_toplevel_get_autohide_disabled (toplevel))
3847 return;
3848
3849 if (toplevel->priv->unhide_timeout)
3850 g_source_remove (toplevel->priv->unhide_timeout);
3851 toplevel->priv->unhide_timeout = 0;
3852
3853 if (toplevel->priv->hide_timeout ||
3854 toplevel->priv->state != PANEL_STATE_NORMAL)
3855 return;
3856
3857 if (toplevel->priv->hide_delay > 0)
3858 toplevel->priv->hide_timeout =
3859 g_timeout_add (toplevel->priv->hide_delay,
3860 (GSourceFunc) panel_toplevel_auto_hide_timeout_handler,
3861 toplevel);
3862 else
3863 toplevel->priv->hide_timeout =
3864 g_idle_add ((GSourceFunc) panel_toplevel_auto_hide_timeout_handler,
3865 toplevel);
3866}
3867
3868void
3869panel_toplevel_queue_auto_unhide (PanelToplevel *toplevel)
3870{
3871 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
3872
3873 if (toplevel->priv->unhide_timeout)
3874 return;
3875
3876 if (toplevel->priv->hide_timeout)
3877 g_source_remove (toplevel->priv->hide_timeout);
3878 toplevel->priv->hide_timeout = 0;
3879
3880 if (toplevel->priv->state != PANEL_STATE_AUTO_HIDDEN)
3881 return;
3882
3883 if (toplevel->priv->unhide_delay > 0)
3884 toplevel->priv->unhide_timeout =
3885 g_timeout_add (toplevel->priv->unhide_delay,
3886 (GSourceFunc) panel_toplevel_auto_unhide_timeout_handler,
3887 toplevel);
3888 else
3889 toplevel->priv->unhide_timeout =
3890 g_idle_add ((GSourceFunc) panel_toplevel_auto_unhide_timeout_handler,
3891 toplevel);
3892}
3893
3894void
3895panel_toplevel_queue_initial_unhide (PanelToplevel *toplevel)
3896{
3897 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
3898
3899 if (toplevel->priv->initial_animation_done)
3900 return;
3901
3902 if (toplevel->priv->unhide_timeout)
3903 return;
3904
3905 toplevel->priv->unhide_timeout =
3906 g_idle_add ((GSourceFunc) panel_toplevel_auto_unhide_timeout_handler,
3907 toplevel);
3908}
3909
3910static gboolean
3911panel_toplevel_enter_notify_event (GtkWidget *widget,
3912 GdkEventCrossing *event)
3913{
3914 PanelToplevel *toplevel;
3915
3916 g_return_val_if_fail (PANEL_IS_TOPLEVEL (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (widget)"); return ((0)); }
} while (0)
;
3917
3918 toplevel = PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
;
3919
3920 if (toplevel->priv->auto_hide && event->detail != GDK_NOTIFY_INFERIOR)
3921 panel_toplevel_queue_auto_unhide (toplevel);
3922
3923 if (GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->enter_notify_event)
3924 return GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->enter_notify_event (widget, event);
3925
3926 return FALSE(0);
3927}
3928
3929static gboolean
3930panel_toplevel_leave_notify_event (GtkWidget *widget,
3931 GdkEventCrossing *event)
3932{
3933 PanelToplevel *toplevel;
3934
3935 g_return_val_if_fail (PANEL_IS_TOPLEVEL (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (widget)"); return ((0)); }
} while (0)
;
3936
3937 toplevel = PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
;
3938
3939 if (toplevel->priv->auto_hide && event->detail != GDK_NOTIFY_INFERIOR)
3940 panel_toplevel_queue_auto_hide (toplevel);
3941
3942 if (GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->leave_notify_event)
3943 return GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->leave_notify_event (widget, event);
3944
3945 return FALSE(0);
3946}
3947
3948static gboolean
3949panel_toplevel_focus_in_event (GtkWidget *widget,
3950 GdkEventFocus *event)
3951{
3952 PanelToplevel *toplevel = PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
;
3953
3954 if (toplevel->priv->state == PANEL_STATE_AUTO_HIDDEN)
3955 panel_toplevel_unhide (toplevel);
3956
3957 if (GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->focus_in_event)
3958 return GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->focus_in_event (widget, event);
3959
3960 return FALSE(0);
3961}
3962
3963static gboolean
3964panel_toplevel_focus_out_event (GtkWidget *widget,
3965 GdkEventFocus *event)
3966{
3967 PanelToplevel *toplevel = PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
;
3968
3969 /* It appears that sometimes we don't get a leave notify event,
3970 but just a focus in/out, so queue the autohide in that case.
3971 If the pointer is inside the panel then obviously we won't hide */
3972 if (toplevel->priv->auto_hide)
3973 panel_toplevel_queue_auto_hide (toplevel);
3974
3975 if (GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->focus_out_event)
3976 return GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->focus_out_event (widget, event);
3977
3978 return FALSE(0);
3979}
3980
3981static void
3982panel_toplevel_style_updated (GtkWidget *widget)
3983{
3984 panel_toplevel_update_hide_buttons (PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
);
3985
3986 if (GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->style_updated)
3987 GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->style_updated (widget);
3988
3989 set_background_default_style (widget);
3990}
3991
3992static void
3993panel_toplevel_drag_threshold_changed (PanelToplevel *toplevel)
3994{
3995 int threshold;
3996
3997 threshold = 0;
3998 g_object_get (G_OBJECT (toplevel->priv->gtk_settings)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->gtk_settings)), (((GType) ((20) <<
(2))))))))
,
3999 "gtk-dnd-drag-threshold", &threshold,
4000 NULL((void*)0));
4001
4002 if (threshold)
4003 toplevel->priv->snap_tolerance = threshold * SNAP_TOLERANCE_FACTOR6;
4004}
4005
4006static void
4007panel_toplevel_update_gtk_settings (PanelToplevel *toplevel)
4008{
4009 if (toplevel->priv->gtk_settings)
4010 g_signal_handlers_disconnect_by_func (toplevel->priv->gtk_settings,g_signal_handlers_disconnect_matched ((toplevel->priv->
gtk_settings), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (panel_toplevel_drag_threshold_changed
))), (toplevel))
4011 G_CALLBACK (panel_toplevel_drag_threshold_changed),g_signal_handlers_disconnect_matched ((toplevel->priv->
gtk_settings), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (panel_toplevel_drag_threshold_changed
))), (toplevel))
4012 toplevel)g_signal_handlers_disconnect_matched ((toplevel->priv->
gtk_settings), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (panel_toplevel_drag_threshold_changed
))), (toplevel))
;
4013
4014 toplevel->priv->gtk_settings = gtk_widget_get_settings (GTK_WIDGET (toplevel->priv->panel_widget)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->panel_widget)), ((gtk_widget_get_type
()))))))
);
4015
4016 g_signal_connect_swapped (toplevel->priv->gtk_settings, "notify::gtk-dnd-drag-threshold",g_signal_connect_data ((toplevel->priv->gtk_settings), (
"notify::gtk-dnd-drag-threshold"), (((GCallback) (panel_toplevel_drag_threshold_changed
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
4017 G_CALLBACK (panel_toplevel_drag_threshold_changed),g_signal_connect_data ((toplevel->priv->gtk_settings), (
"notify::gtk-dnd-drag-threshold"), (((GCallback) (panel_toplevel_drag_threshold_changed
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
4018 toplevel)g_signal_connect_data ((toplevel->priv->gtk_settings), (
"notify::gtk-dnd-drag-threshold"), (((GCallback) (panel_toplevel_drag_threshold_changed
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
;
4019
4020 panel_toplevel_drag_threshold_changed (toplevel);
4021}
4022
4023static void
4024panel_toplevel_screen_changed (GtkWidget *widget,
4025 GdkScreen *previous_screen)
4026{
4027 panel_toplevel_update_gtk_settings (PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
);
4028
4029 if (GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->screen_changed)
4030 GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->screen_changed (widget, previous_screen);
4031
4032 gtk_widget_queue_resize (widget);
4033}
4034
4035static void
4036panel_toplevel_set_property (GObject *object,
4037 guint prop_id,
4038 const GValue *value,
4039 GParamSpec *pspec)
4040{
4041 PanelToplevel *toplevel;
4042
4043 g_return_if_fail (PANEL_IS_TOPLEVEL (object))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((object)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (object)"); return; } } while
(0)
;
4044
4045 toplevel = PANEL_TOPLEVEL (object)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((panel_toplevel_get_type ()))))))
;
4046
4047 switch (prop_id) {
4048 case PROP_NAME:
4049 panel_toplevel_set_name (toplevel, g_value_get_string (value));
4050 break;
4051 case PROP_SETTINGS_PATH:
4052 panel_toplevel_set_settings_path (toplevel, g_value_get_string (value));
4053 break;
4054 case PROP_EXPAND:
4055 panel_toplevel_set_expand (toplevel, g_value_get_boolean (value));
4056 break;
4057 case PROP_ORIENTATION:
4058 panel_toplevel_set_orientation (toplevel, g_value_get_enum (value));
4059 break;
4060 case PROP_SIZE:
4061 panel_toplevel_set_size (toplevel, g_value_get_int (value));
4062 break;
4063 case PROP_X:
4064 panel_toplevel_set_x (toplevel,
4065 g_value_get_int (value),
4066 toplevel->priv->x_right,
4067 toplevel->priv->x_centered);
4068 break;
4069 case PROP_X_RIGHT:
4070 panel_toplevel_set_x (toplevel,
4071 toplevel->priv->x,
4072 g_value_get_int (value),
4073 toplevel->priv->x_centered);
4074 break;
4075 case PROP_X_CENTERED:
4076 panel_toplevel_set_x (toplevel,
4077 toplevel->priv->x,
4078 toplevel->priv->x_right,
4079 g_value_get_boolean (value));
4080 break;
4081 case PROP_Y:
4082 panel_toplevel_set_y (toplevel,
4083 g_value_get_int (value),
4084 toplevel->priv->y_bottom,
4085 toplevel->priv->y_centered);
4086 break;
4087 case PROP_Y_BOTTOM:
4088 panel_toplevel_set_y (toplevel,
4089 toplevel->priv->y,
4090 g_value_get_int (value),
4091 toplevel->priv->y_centered);
4092 break;
4093 case PROP_Y_CENTERED:
4094 panel_toplevel_set_y (toplevel,
4095 toplevel->priv->y,
4096 toplevel->priv->y_bottom,
4097 g_value_get_boolean (value));
4098 break;
4099 case PROP_MONITOR:
4100 panel_toplevel_set_monitor (toplevel, g_value_get_int (value));
4101 break;
4102 case PROP_AUTOHIDE:
4103 panel_toplevel_set_auto_hide (toplevel, g_value_get_boolean (value));
4104 break;
4105 case PROP_HIDE_DELAY:
4106 panel_toplevel_set_hide_delay (toplevel, g_value_get_int (value));
4107 break;
4108 case PROP_UNHIDE_DELAY:
4109 panel_toplevel_set_unhide_delay (toplevel, g_value_get_int (value));
4110 break;
4111 case PROP_AUTOHIDE_SIZE:
4112 panel_toplevel_set_auto_hide_size (toplevel, g_value_get_int (value));
4113 break;
4114 case PROP_ANIMATE:
4115 panel_toplevel_set_animate (toplevel, g_value_get_boolean (value));
4116 break;
4117 case PROP_ANIMATION_SPEED:
4118 panel_toplevel_set_animation_speed (toplevel, g_value_get_enum (value));
4119 break;
4120 case PROP_BUTTONS_ENABLED:
4121 panel_toplevel_set_enable_buttons (toplevel, g_value_get_boolean (value));
4122 break;
4123 case PROP_ARROWS_ENABLED:
4124 panel_toplevel_set_enable_arrows (toplevel, g_value_get_boolean (value));
4125 break;
4126 default:
4127 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "panel-toplevel.c", 4127, ("property"), _glib__property_id,
_glib__pspec->name, g_type_name ((((((GTypeClass*) (((GTypeInstance
*) (_glib__pspec))->g_class))->g_type)))), (g_type_name
((((((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
4128 break;
4129 }
4130}
4131
4132static void
4133panel_toplevel_get_property (GObject *object,
4134 guint prop_id,
4135 GValue *value,
4136 GParamSpec *pspec)
4137{
4138 PanelToplevel *toplevel;
4139
4140 g_return_if_fail (PANEL_IS_TOPLEVEL (object))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((object)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (object)"); return; } } while
(0)
;
4141
4142 toplevel = PANEL_TOPLEVEL (object)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((panel_toplevel_get_type ()))))))
;
4143
4144 switch (prop_id) {
4145 case PROP_NAME:
4146 g_value_set_string (value, panel_toplevel_get_name (toplevel));
4147 break;
4148 case PROP_SETTINGS_PATH:
4149 g_value_set_string (value, toplevel->priv->settings_path);
4150 break;
4151 case PROP_EXPAND:
4152 g_value_set_boolean (value, toplevel->priv->expand);
4153 break;
4154 case PROP_ORIENTATION:
4155 g_value_set_enum (value, toplevel->priv->orientation);
4156 break;
4157 case PROP_SIZE:
4158 g_value_set_int (value, toplevel->priv->size);
4159 break;
4160 case PROP_X:
4161 g_value_set_int (value, toplevel->priv->x);
4162 break;
4163 case PROP_X_RIGHT:
4164 g_value_set_int (value, toplevel->priv->x_right);
4165 break;
4166 case PROP_X_CENTERED:
4167 g_value_set_boolean (value, toplevel->priv->x_centered);
4168 break;
4169 case PROP_Y:
4170 g_value_set_int (value, toplevel->priv->y);
4171 break;
4172 case PROP_Y_BOTTOM:
4173 g_value_set_int (value, toplevel->priv->y_bottom);
4174 break;
4175 case PROP_Y_CENTERED:
4176 g_value_set_boolean (value, toplevel->priv->y_centered);
4177 break;
4178 case PROP_MONITOR:
4179 g_value_set_int (value, toplevel->priv->monitor);
4180 break;
4181 case PROP_AUTOHIDE:
4182 g_value_set_boolean (value, toplevel->priv->auto_hide);
4183 break;
4184 case PROP_HIDE_DELAY:
4185 g_value_set_int (value, toplevel->priv->hide_delay);
4186 break;
4187 case PROP_UNHIDE_DELAY:
4188 g_value_set_int (value, toplevel->priv->unhide_delay);
4189 break;
4190 case PROP_AUTOHIDE_SIZE:
4191 g_value_set_int (value, toplevel->priv->auto_hide_size);
4192 break;
4193 case PROP_ANIMATE:
4194 g_value_set_boolean (value, toplevel->priv->animate);
4195 break;
4196 case PROP_ANIMATION_SPEED:
4197 g_value_set_enum (value, toplevel->priv->animation_speed);
4198 break;
4199 case PROP_BUTTONS_ENABLED:
4200 g_value_set_boolean (value, toplevel->priv->buttons_enabled);
4201 break;
4202 case PROP_ARROWS_ENABLED:
4203 g_value_set_boolean (value, toplevel->priv->arrows_enabled);
4204 break;
4205 default:
4206 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "panel-toplevel.c", 4206, ("property"), _glib__property_id,
_glib__pspec->name, g_type_name ((((((GTypeClass*) (((GTypeInstance
*) (_glib__pspec))->g_class))->g_type)))), (g_type_name
((((((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
4207 break;
4208 }
4209}
4210
4211static GObject*
4212panel_toplevel_constructor (GType type,
4213 guint n_construct_properties,
4214 GObjectConstructParam *construct_properties)
4215{
4216 GObject *object;
4217
4218 object = G_OBJECT_CLASS (panel_toplevel_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), (((GType) ((20) << (
2))))))))
->constructor (type,
4219 n_construct_properties,
4220 construct_properties);
4221 PanelToplevel *toplevel = PANEL_TOPLEVEL(object)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((panel_toplevel_get_type ()))))))
;
4222 GdkScreen *screen = gtk_widget_get_screen(GTK_WIDGET(toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
4223 GdkVisual *visual = gdk_screen_get_rgba_visual(screen);
4224 gtk_widget_set_visual(GTK_WIDGET(toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
, visual);
4225
4226 return object;
4227}
4228
4229static void
4230panel_toplevel_finalize (GObject *object)
4231{
4232 PanelToplevel *toplevel = (PanelToplevel *) object;
4233
4234#ifdef HAVE_X111
4235 if (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel)))(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gtk_widget_get_display (((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((toplevel)), ((gtk_widget_get_type ()))))
))))); GType __t = ((gdk_x11_display_get_type())); gboolean __r
; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
)
4236 panel_struts_unregister_strut (toplevel);
4237#endif /* HAVE_X11 */
4238
4239 toplevel_list = g_slist_remove (toplevel_list, toplevel);
4240
4241 G_OBJECT_CLASS (panel_toplevel_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), (((GType) ((20) << (
2))))))))
->finalize (object);
4242}
4243
4244static void
4245panel_toplevel_class_init (PanelToplevelClass *klass)
4246{
4247 GObjectClass *gobject_class = (GObjectClass *) klass;
4248 GtkWidgetClass *widget_class = (GtkWidgetClass *) klass;
4249 GtkContainerClass *container_class = (GtkContainerClass *) klass;
4250 GtkBindingSet *binding_set;
4251
4252 binding_set = gtk_binding_set_by_class (klass);
4253
4254 gobject_class->constructor = panel_toplevel_constructor;
4255 gobject_class->set_property = panel_toplevel_set_property;
4256 gobject_class->get_property = panel_toplevel_get_property;
4257 gobject_class->finalize = panel_toplevel_finalize;
4258
4259 gobject_class->dispose = panel_toplevel_dispose;
4260
4261 widget_class->realize = panel_toplevel_realize;
4262 widget_class->unrealize = panel_toplevel_unrealize;
4263 widget_class->state_flags_changed = panel_toplevel_state_flags_changed;
4264 widget_class->draw = panel_toplevel_draw;
4265 widget_class->get_preferred_width = panel_toplevel_get_preferred_width;
4266 widget_class->get_preferred_height = panel_toplevel_get_preferred_height;
4267 widget_class->style_updated = panel_toplevel_style_updated;
4268 widget_class->size_allocate = panel_toplevel_size_allocate;
4269 widget_class->button_press_event = panel_toplevel_button_press_event;
4270 widget_class->button_release_event = panel_toplevel_button_release_event;
4271 widget_class->configure_event = panel_toplevel_configure_event;
4272 widget_class->key_press_event = panel_toplevel_key_press_event;
4273 widget_class->motion_notify_event = panel_toplevel_motion_notify_event;
4274 widget_class->enter_notify_event = panel_toplevel_enter_notify_event;
4275 widget_class->leave_notify_event = panel_toplevel_leave_notify_event;
4276 widget_class->screen_changed = panel_toplevel_screen_changed;
4277 widget_class->focus_in_event = panel_toplevel_focus_in_event;
4278 widget_class->focus_out_event = panel_toplevel_focus_out_event;
4279
4280 gtk_widget_class_set_css_name (widget_class, "PanelToplevel");
4281
4282 container_class->check_resize = panel_toplevel_check_resize;
4283
4284 klass->hiding = NULL((void*)0);
4285 klass->unhiding = NULL((void*)0);
4286 klass->popup_panel_menu = panel_toplevel_popup_panel_menu;
4287 klass->toggle_expand = panel_toplevel_toggle_expand;
4288 klass->expand = panel_toplevel_expand;
4289 klass->unexpand = panel_toplevel_unexpand;
4290 klass->toggle_hidden = panel_toplevel_toggle_hidden;
4291 klass->begin_move = panel_toplevel_begin_move;
4292 klass->begin_resize = panel_toplevel_begin_resize;
4293
4294 g_object_class_install_property (
4295 gobject_class,
4296 PROP_NAME,
4297 g_param_spec_string (
4298 "name",
4299 "Name",
4300 "The name of this panel",
4301 NULL((void*)0),
4302 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4303
4304 g_object_class_install_property (
4305 gobject_class,
4306 PROP_SETTINGS_PATH,
4307 g_param_spec_string (
4308 "settings-path",
4309 "GSettings path",
4310 "The GSettings path used for this panel",
4311 NULL((void*)0),
4312 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4313
4314 g_object_class_install_property (
4315 gobject_class,
4316 PROP_EXPAND,
4317 g_param_spec_boolean (
4318 "expand",
4319 "Expand",
4320 "Expand to take up the full monitor width/height",
4321 TRUE(!(0)),
4322 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4323
4324 g_object_class_install_property (
4325 gobject_class,
4326 PROP_ORIENTATION,
4327 g_param_spec_enum (
4328 "orientation",
4329 "Orientation",
4330 "The orientation of the panel",
4331 PANEL_TYPE_ORIENTATIONpanel_orientation_get_type(),
4332 PANEL_ORIENTATION_TOP,
4333 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4334
4335 g_object_class_install_property (
4336 gobject_class,
4337 PROP_SIZE,
4338 g_param_spec_int (
4339 "size",
4340 "Size",
4341 "The height (or width when vertical) of the panel",
4342 0,
4343 G_MAXINT2147483647,
4344 DEFAULT_SIZE48,
4345 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4346
4347 g_object_class_install_property (
4348 gobject_class,
4349 PROP_X,
4350 g_param_spec_int (
4351 "x",
4352 "X position",
4353 "The X position of the panel",
4354 0,
4355 G_MAXINT2147483647,
4356 0,
4357 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4358
4359 g_object_class_install_property (
4360 gobject_class,
4361 PROP_X_RIGHT,
4362 g_param_spec_int (
4363 "x-right",
4364 "X position, from the right",
4365 "The X position of the panel, starting from the right of the screen",
4366 -1,
4367 G_MAXINT2147483647,
4368 -1,
4369 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4370
4371 g_object_class_install_property (
4372 gobject_class,
4373 PROP_X_CENTERED,
4374 g_param_spec_boolean (
4375 "x-centered",
4376 "X centered",
4377 "The x co-ordinate is relative to center screen",
4378 FALSE(0),
4379 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4380
4381 g_object_class_install_property (
4382 gobject_class,
4383 PROP_Y,
4384 g_param_spec_int (
4385 "y",
4386 "Y position",
4387 "The Y position of the panel",
4388 0,
4389 G_MAXINT2147483647,
4390 0,
4391 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4392
4393 g_object_class_install_property (
4394 gobject_class,
4395 PROP_Y_BOTTOM,
4396 g_param_spec_int (
4397 "y_bottom",
4398 "Y position, from the bottom",
4399 "The Y position of the panel, starting from the bottom of the screen",
4400 -1,
4401 G_MAXINT2147483647,
4402 -1,
4403 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4404
4405 g_object_class_install_property (
4406 gobject_class,
4407 PROP_Y_CENTERED,
4408 g_param_spec_boolean (
4409 "y-centered",
4410 "Y centered",
4411 "The y co-ordinate is relative to center screen",
4412 FALSE(0),
4413 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4414
4415 g_object_class_install_property (
4416 gobject_class,
4417 PROP_MONITOR,
4418 g_param_spec_int (
4419 "monitor",
4420 "Xinerama monitor",
4421 "The monitor (in terms of Xinerama) which the panel is on",
4422 0,
4423 G_MAXINT2147483647,
4424 0,
4425 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4426
4427 g_object_class_install_property (
4428 gobject_class,
4429 PROP_AUTOHIDE,
4430 g_param_spec_boolean (
4431 "auto-hide",
4432 "Auto hide",
4433 "Automatically hide the panel when the mouse leaves the panel",
4434 FALSE(0),
4435 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4436
4437 g_object_class_install_property (
4438 gobject_class,
4439 PROP_HIDE_DELAY,
4440 g_param_spec_int (
4441 "hide-delay",
4442 "Hide delay",
4443 "The number of milliseconds to delay before automatically hiding",
4444 0,
4445 G_MAXINT2147483647,
4446 DEFAULT_HIDE_DELAY300,
4447 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4448
4449 g_object_class_install_property (
4450 gobject_class,
4451 PROP_UNHIDE_DELAY,
4452 g_param_spec_int (
4453 "unhide-delay",
4454 "Un-hide delay",
4455 "The number of milliseconds to delay before automatically un-hiding",
4456 0,
4457 G_MAXINT2147483647,
4458 DEFAULT_UNHIDE_DELAY100,
4459 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4460
4461 g_object_class_install_property (
4462 gobject_class,
4463 PROP_AUTOHIDE_SIZE,
4464 g_param_spec_int (
4465 "auto-hide-size",
4466 "Auto-hide size",
4467 "The number of pixels visible when the panel has been automatically hidden",
4468 1,
4469 G_MAXINT2147483647,
4470 DEFAULT_AUTO_HIDE_SIZE1,
4471 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4472
4473 g_object_class_install_property (
4474 gobject_class,
4475 PROP_ANIMATE,
4476 g_param_spec_boolean (
4477 "animate",
4478 "Animate",
4479 "Enable hiding/showing animations",
4480 TRUE(!(0)),
4481 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4482
4483 g_object_class_install_property (
4484 gobject_class,
4485 PROP_ANIMATION_SPEED,
4486 g_param_spec_enum (
4487 "animation-speed",
4488 "Animation Speed",
4489 "The speed at which to animate panel hiding/showing",
4490 PANEL_TYPE_ANIMATION_SPEEDpanel_animation_speed_get_type(),
4491 PANEL_ANIMATION_MEDIUM,
4492 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4493
4494 g_object_class_install_property (
4495 gobject_class,
4496 PROP_BUTTONS_ENABLED,
4497 g_param_spec_boolean (
4498 "buttons-enabled",
4499 "Buttons Enabled",
4500 "Enable hide/show buttons",
4501 TRUE(!(0)),
4502 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4503
4504 g_object_class_install_property (
4505 gobject_class,
4506 PROP_ARROWS_ENABLED,
4507 g_param_spec_boolean (
4508 "arrows-enabled",
4509 "Arrows Enabled",
4510 "Enable arrows on hide/show buttons",
4511 TRUE(!(0)),
4512 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4513
4514 gtk_widget_class_install_style_property (
4515 widget_class,
4516 g_param_spec_int (
4517 "arrow-size",
4518 "Arrow Size",
4519 "The size of the arrows on the hide/show buttons",
4520 0,
4521 G_MAXINT2147483647,
4522 DEFAULT_ARROW_SIZE20,
4523 G_PARAM_READABLE));
4524
4525 toplevel_signals [HIDE_SIGNAL] =
4526 g_signal_new ("hiding",
4527 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
4528 G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
4529 G_STRUCT_OFFSET (PanelToplevelClass, hiding)((glong) __builtin_offsetof(PanelToplevelClass, hiding)),
4530 NULL((void*)0),
4531 NULL((void*)0),
4532 g_cclosure_marshal_VOID__VOID,
4533 G_TYPE_NONE((GType) ((1) << (2))),
4534 0);
4535
4536 toplevel_signals [UNHIDE_SIGNAL] =
4537 g_signal_new ("unhiding",
4538 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
4539 G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
4540 G_STRUCT_OFFSET (PanelToplevelClass, unhiding)((glong) __builtin_offsetof(PanelToplevelClass, unhiding)),
4541 NULL((void*)0),
4542 NULL((void*)0),
4543 g_cclosure_marshal_VOID__VOID,
4544 G_TYPE_NONE((GType) ((1) << (2))),
4545 0);
4546
4547 toplevel_signals [POPUP_PANEL_MENU_SIGNAL] =
4548 g_signal_new ("popup-panel-menu",
4549 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
4550 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
4551 G_STRUCT_OFFSET (PanelToplevelClass, popup_panel_menu)((glong) __builtin_offsetof(PanelToplevelClass, popup_panel_menu
))
,
4552 NULL((void*)0),
4553 NULL((void*)0),
4554 panel_marshal_BOOLEAN__VOID,
4555 G_TYPE_BOOLEAN((GType) ((5) << (2))),
4556 0);
4557
4558 toplevel_signals [TOGGLE_EXPAND_SIGNAL] =
4559 g_signal_new ("toggle-expand",
4560 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
4561 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
4562 G_STRUCT_OFFSET (PanelToplevelClass, toggle_expand)((glong) __builtin_offsetof(PanelToplevelClass, toggle_expand
))
,
4563 NULL((void*)0),
4564 NULL((void*)0),
4565 panel_marshal_BOOLEAN__VOID,
4566 G_TYPE_BOOLEAN((GType) ((5) << (2))),
4567 0);
4568
4569 toplevel_signals [EXPAND_SIGNAL] =
4570 g_signal_new ("expand",
4571 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
4572 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
4573 G_STRUCT_OFFSET (PanelToplevelClass, expand)((glong) __builtin_offsetof(PanelToplevelClass, expand)),
4574 NULL((void*)0),
4575 NULL((void*)0),
4576 panel_marshal_BOOLEAN__VOID,
4577 G_TYPE_BOOLEAN((GType) ((5) << (2))),
4578 0);
4579
4580 toplevel_signals [UNEXPAND_SIGNAL] =
4581 g_signal_new ("unexpand",
4582 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
4583 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
4584 G_STRUCT_OFFSET (PanelToplevelClass, unexpand)((glong) __builtin_offsetof(PanelToplevelClass, unexpand)),
4585 NULL((void*)0),
4586 NULL((void*)0),
4587 panel_marshal_BOOLEAN__VOID,
4588 G_TYPE_BOOLEAN((GType) ((5) << (2))),
4589 0);
4590
4591 toplevel_signals [TOGGLE_HIDDEN_SIGNAL] =
4592 g_signal_new ("toggle-hidden",
4593 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
4594 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
4595 G_STRUCT_OFFSET (PanelToplevelClass, toggle_hidden)((glong) __builtin_offsetof(PanelToplevelClass, toggle_hidden
))
,
4596 NULL((void*)0),
4597 NULL((void*)0),
4598 panel_marshal_BOOLEAN__VOID,
4599 G_TYPE_BOOLEAN((GType) ((5) << (2))),
4600 0);
4601
4602 toplevel_signals [BEGIN_MOVE_SIGNAL] =
4603 g_signal_new ("begin-move",
4604 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
4605 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
4606 G_STRUCT_OFFSET (PanelToplevelClass, begin_move)((glong) __builtin_offsetof(PanelToplevelClass, begin_move)),
4607 NULL((void*)0),
4608 NULL((void*)0),
4609 panel_marshal_BOOLEAN__VOID,
4610 G_TYPE_BOOLEAN((GType) ((5) << (2))),
4611 0);
4612
4613 toplevel_signals [BEGIN_RESIZE_SIGNAL] =
4614 g_signal_new ("begin-resize",
4615 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
4616 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
4617 G_STRUCT_OFFSET (PanelToplevelClass, begin_resize)((glong) __builtin_offsetof(PanelToplevelClass, begin_resize)
)
,
4618 NULL((void*)0),
4619 NULL((void*)0),
4620 panel_marshal_BOOLEAN__VOID,
4621 G_TYPE_BOOLEAN((GType) ((5) << (2))),
4622 0);
4623
4624 gtk_binding_entry_add_signal (binding_set, GDK_KEY_F100xffc7, GDK_CONTROL_MASK,
4625 "popup_panel_menu", 0);
4626
4627 panel_bindings_set_entries (binding_set);
4628}
4629
4630static void
4631panel_toplevel_setup_widgets (PanelToplevel *toplevel)
4632{
4633 GtkWidget* container;
4634
4635 toplevel->priv->grid = gtk_grid_new ();
4636
4637 toplevel->priv->hide_button_top = panel_toplevel_add_hide_button (toplevel, GTK_ARROW_UP, 1, 0);
4638 toplevel->priv->hide_button_bottom = panel_toplevel_add_hide_button (toplevel, GTK_ARROW_DOWN, 1, 2);
4639 toplevel->priv->hide_button_left = panel_toplevel_add_hide_button (toplevel, GTK_ARROW_LEFT, 0, 1);
4640 toplevel->priv->hide_button_right = panel_toplevel_add_hide_button (toplevel, GTK_ARROW_RIGHT, 2, 1);
4641
4642 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM))
4643 {
4644 gtk_widget_show(toplevel->priv->hide_button_left);
4645 gtk_widget_show(toplevel->priv->hide_button_right);
4646 }
4647 else
4648 {
4649 gtk_widget_show(toplevel->priv->hide_button_top);
4650 gtk_widget_show(toplevel->priv->hide_button_bottom);
4651 }
4652
4653 toplevel->priv->inner_frame = g_object_new(PANEL_TYPE_FRAME(panel_frame_get_type ()), NULL((void*)0));
4654
4655 gtk_widget_set_hexpand (GTK_WIDGET (toplevel->priv->inner_frame)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->inner_frame)), ((gtk_widget_get_type
()))))))
, TRUE(!(0)));
4656 gtk_widget_set_vexpand (GTK_WIDGET (toplevel->priv->inner_frame)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->inner_frame)), ((gtk_widget_get_type
()))))))
, TRUE(!(0)));
4657
4658 gtk_grid_attach (GTK_GRID (toplevel->priv->grid)((((GtkGrid*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->grid)), ((gtk_grid_get_type ()))))
))
, GTK_WIDGET (toplevel->priv->inner_frame)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->inner_frame)), ((gtk_widget_get_type
()))))))
, 1, 1, 1, 1);
4659 gtk_widget_show (GTK_WIDGET (toplevel->priv->inner_frame)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->inner_frame)), ((gtk_widget_get_type
()))))))
);
4660
4661 container = panel_widget_new (toplevel,
4662 !toplevel->priv->expand,
4663 (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)) ?
4664 GTK_ORIENTATION_HORIZONTAL :
4665 GTK_ORIENTATION_VERTICAL,
4666 toplevel->priv->size);
4667
4668 toplevel->priv->panel_widget = PANEL_WIDGET(container)((((PanelWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((container)), ((panel_widget_get_type()))))))
;
4669
4670 gtk_container_add(GTK_CONTAINER(toplevel->priv->inner_frame)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->inner_frame)), ((gtk_container_get_type
()))))))
, container);
4671 gtk_widget_show(container);
4672
4673 gtk_container_add (GTK_CONTAINER (toplevel)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_container_get_type ()))))))
, toplevel->priv->grid);
4674 gtk_widget_show (toplevel->priv->grid);
4675}
4676
4677static void
4678background_changed (PanelBackground *background,
4679 PanelToplevel *toplevel)
4680{
4681 panel_toplevel_update_edges (toplevel);
4682 panel_widget_emit_background_changed (toplevel->priv->panel_widget);
4683}
4684
4685static void
4686panel_toplevel_init (PanelToplevel *toplevel)
4687{
4688 GtkWidget *widget;
4689 int i;
4690
4691 toplevel->priv = panel_toplevel_get_instance_private (toplevel);
4692
4693 toplevel->priv->expand = TRUE(!(0));
4694 toplevel->priv->orientation = PANEL_ORIENTATION_BOTTOM;
4695 toplevel->priv->size = DEFAULT_SIZE48;
4696 toplevel->priv->scale = gtk_widget_get_scale_factor (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
4697 toplevel->priv->x = 0;
4698 toplevel->priv->y = 0;
4699 toplevel->priv->x_right = -1;
4700 toplevel->priv->y_bottom = -1;
4701 toplevel->priv->monitor = 0;
4702 toplevel->priv->configured_monitor = -1;
4703 toplevel->priv->hide_delay = DEFAULT_HIDE_DELAY300;
4704 toplevel->priv->unhide_delay = DEFAULT_UNHIDE_DELAY100;
4705 toplevel->priv->auto_hide_size = DEFAULT_AUTO_HIDE_SIZE1;
4706 toplevel->priv->animation_speed = PANEL_ANIMATION_FAST;
4707
4708 toplevel->priv->snap_tolerance = DEFAULT_DND_THRESHOLD8 * SNAP_TOLERANCE_FACTOR6;
4709 toplevel->priv->gtk_settings = NULL((void*)0);
4710
4711 toplevel->priv->state = PANEL_STATE_NORMAL;
4712
4713 toplevel->priv->name = NULL((void*)0);
4714 toplevel->priv->description = NULL((void*)0);
4715
4716 toplevel->priv->hide_timeout = 0;
4717 toplevel->priv->unhide_timeout = 0;
4718
4719 toplevel->priv->geometry.x = -1;
4720 toplevel->priv->geometry.y = -1;
4721 toplevel->priv->geometry.width = -1;
4722 toplevel->priv->geometry.height = -1;
4723
4724 toplevel->priv->original_width = -1;
4725 toplevel->priv->original_height = -1;
4726
4727 toplevel->priv->grab_op = PANEL_GRAB_OP_NONE;
4728
4729 toplevel->priv->drag_offset_x = 0;
4730 toplevel->priv->drag_offset_y = 0;
4731
4732 toplevel->priv->animation_end_x = 0;
4733 toplevel->priv->animation_end_y = 0;
4734 toplevel->priv->animation_end_width = 0;
4735 toplevel->priv->animation_end_height = 0;
4736 toplevel->priv->animation_start_time = 0;
4737 toplevel->priv->animation_duration_time = 0;
4738 toplevel->priv->animation_timeout = 0;
4739
4740 toplevel->priv->panel_widget = NULL((void*)0);
4741 toplevel->priv->inner_frame = NULL((void*)0);
4742 toplevel->priv->grid = NULL((void*)0);
4743 toplevel->priv->hide_button_top = NULL((void*)0);
4744 toplevel->priv->hide_button_bottom = NULL((void*)0);
4745 toplevel->priv->hide_button_left = NULL((void*)0);
4746 toplevel->priv->hide_button_right = NULL((void*)0);
4747
4748 toplevel->priv->attach_toplevel = NULL((void*)0);
4749 toplevel->priv->attach_widget = NULL((void*)0);
4750 toplevel->priv->n_autohide_disablers = 0;
4751
4752 for (i = 0; i < N_ATTACH_TOPLEVEL_SIGNALS5; i++)
4753 toplevel->priv->attach_toplevel_signals [i] = 0;
4754 for (i = 0; i < N_ATTACH_WIDGET_SIGNALS5; i++)
4755 toplevel->priv->attach_widget_signals [i] = 0;
4756
4757 toplevel->priv->auto_hide = FALSE(0);
4758 toplevel->priv->buttons_enabled = TRUE(!(0));
4759 toplevel->priv->arrows_enabled = TRUE(!(0));
4760 toplevel->priv->x_centered = FALSE(0);
4761 toplevel->priv->y_centered = FALSE(0);
4762 toplevel->priv->animating = FALSE(0);
4763 toplevel->priv->grab_is_keyboard = FALSE(0);
4764 toplevel->priv->position_centered = FALSE(0);
4765 toplevel->priv->attached = FALSE(0);
4766 toplevel->priv->attach_hidden = FALSE(0);
4767 toplevel->priv->updated_geometry_initial = FALSE(0);
4768 toplevel->priv->initial_animation_done = FALSE(0);
4769
4770 widget = GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
;
4771 gtk_widget_add_events (widget,
4772 GDK_BUTTON_PRESS_MASK |
4773 GDK_BUTTON_RELEASE_MASK |
4774 GDK_POINTER_MOTION_MASK |
4775 GDK_ENTER_NOTIFY_MASK |
4776 GDK_LEAVE_NOTIFY_MASK);
4777
4778 gtk_widget_set_app_paintable (widget, TRUE(!(0)));
4779
4780 panel_toplevel_setup_widgets (toplevel);
4781 panel_toplevel_update_description (toplevel);
4782 panel_toplevel_update_gtk_settings (toplevel);
4783
4784 toplevel_list = g_slist_prepend (toplevel_list, toplevel);
4785
4786 /* Prevent the window from being deleted via Alt+F4 by accident. This
4787 * happens with "alternative" window managers such as Sawfish or XFWM4.
4788 */
4789 g_signal_connect (toplevel, "delete-event", G_CALLBACK(gtk_true), NULL)g_signal_connect_data ((toplevel), ("delete-event"), (((GCallback
) (gtk_true))), (((void*)0)), ((void*)0), (GConnectFlags) 0)
;
4790
4791 panel_background_init (&toplevel->background,
4792 (PanelBackgroundChangedNotify) background_changed,
4793 toplevel);
4794
4795 update_style_classes (toplevel);
4796
4797#ifdef HAVE_WAYLAND1
4798 if (GDK_IS_WAYLAND_DISPLAY (gdk_display_get_default ())(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gdk_display_get_default ())); GType __t = ((gdk_wayland_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
) {
4799 wayland_panel_toplevel_init (toplevel);
4800 }
4801#endif /* HAVE_WAYLAND */
4802}
4803
4804PanelWidget *
4805panel_toplevel_get_panel_widget (PanelToplevel *toplevel)
4806{
4807
4808 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return (((void
*)0)); } } while (0)
;
4809
4810 return toplevel->priv->panel_widget;
4811}
4812
4813static void
4814panel_toplevel_update_name (PanelToplevel *toplevel)
4815{
4816 char *title;
4817
4818 g_assert (toplevel->priv->description != NULL)do { if (toplevel->priv->description != ((void*)0)) ; else
g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c", 4818
, ((const char*) (__func__)), "toplevel->priv->description != NULL"
); } while (0)
;
4819
4820 title = toplevel->priv->name ? toplevel->priv->name : toplevel->priv->description;
4821
4822 gtk_window_set_title (GTK_WINDOW (toplevel)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_window_get_type ()))))))
, title);
4823
4824 panel_a11y_set_atk_name_desc (
4825 GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
,
4826 title, toplevel->priv->description);
4827}
4828
4829void
4830panel_toplevel_set_name (PanelToplevel *toplevel,
4831 const char *name)
4832{
4833 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
4834
4835 if (!toplevel->priv->name && (!name || !name [0]))
4836 return;
4837
4838 if (toplevel->priv->name && name && name [0] &&
4839 !strcmp (toplevel->priv->name, name))
4840 return;
4841
4842 g_free (toplevel->priv->name);
4843 if (name && name [0])
4844 toplevel->priv->name = g_strdup (name)g_strdup_inline (name);
4845 else
4846 toplevel->priv->name = NULL((void*)0);
4847
4848 panel_toplevel_update_name (toplevel);
4849
4850 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "name");
4851}
4852
4853void
4854panel_toplevel_set_settings_path (PanelToplevel *toplevel,
4855 const char *settings_path)
4856{
4857 toplevel->priv->settings_path = g_strdup (settings_path)g_strdup_inline (settings_path);
4858}
4859
4860const char* panel_toplevel_get_name(PanelToplevel* toplevel)
4861{
4862 g_return_val_if_fail(PANEL_IS_TOPLEVEL(toplevel), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL(toplevel)"); return (((void
*)0)); } } while (0)
;
4863
4864 return toplevel->priv->name;
4865}
4866
4867const char* panel_toplevel_get_description(PanelToplevel* toplevel)
4868{
4869 g_return_val_if_fail(PANEL_IS_TOPLEVEL(toplevel), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL(toplevel)"); return (((void
*)0)); } } while (0)
;
4870
4871 return toplevel->priv->description;
4872}
4873
4874void
4875panel_toplevel_set_expand (PanelToplevel *toplevel,
4876 gboolean expand)
4877{
4878 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
4879
4880 if (toplevel->priv->attached && expand) {
4881 g_warning ("attempt to expand attached toplevel; ignoring");
4882 return;
4883 }
4884
4885 expand = expand != FALSE(0);
4886
4887 if (toplevel->priv->expand == expand)
4888 return;
4889
4890 toplevel->priv->expand = expand;
4891
4892 if (!toplevel->priv->expand && toplevel->priv->updated_geometry_initial) {
4893 switch (toplevel->priv->orientation) {
4894 case PANEL_ORIENTATION_TOP:
4895 panel_toplevel_set_x (toplevel, 0, -1, TRUE(!(0)));
4896 break;
4897 case PANEL_ORIENTATION_BOTTOM:
4898 panel_toplevel_set_x (toplevel, 0, 0, TRUE(!(0)));
4899 break;
4900 case PANEL_ORIENTATION_LEFT:
4901 panel_toplevel_set_y (toplevel, 0, -1, TRUE(!(0)));
4902 break;
4903 case PANEL_ORIENTATION_RIGHT:
4904 panel_toplevel_set_y (toplevel, 0, 0, TRUE(!(0)));
4905 break;
4906 default:
4907 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 4907, ((const char*) (__func__)), ((void*)0)); } while (0)
;
4908 break;
4909 }
4910 }
4911
4912 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
4913
4914 panel_widget_set_packed (toplevel->priv->panel_widget, !toplevel->priv->expand);
4915
4916 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "expand");
4917}
4918
4919gboolean
4920panel_toplevel_get_expand (PanelToplevel *toplevel)
4921{
4922 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), TRUE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return ((!(0)
)); } } while (0)
;
4923
4924 return toplevel->priv->expand;
4925}
4926
4927gboolean
4928panel_toplevel_get_is_floating (PanelToplevel *toplevel)
4929{
4930 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), TRUE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return ((!(0)
)); } } while (0)
;
4931
4932 return toplevel->priv->floating;
4933}
4934
4935void
4936panel_toplevel_set_orientation (PanelToplevel *toplevel,
4937 PanelOrientation orientation)
4938{
4939 gboolean rotate;
4940 GdkRectangle monitor_geom;
4941
4942 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
4943
4944 if (toplevel->priv->orientation == orientation)
4945 return;
4946
4947 g_object_freeze_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
);
4948
4949 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
4950
4951 /* Un-snap from center if no longer along screen edge */
4952 if (toplevel->priv->x_centered &&
4953 (orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT))) {
4954 toplevel->priv->x_centered = FALSE(0);
4955 toplevel->priv->x = (monitor_geom.width - toplevel->priv->geometry.width) / 2;
4956 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "x");
4957 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "x-centered");
4958
4959 if (toplevel->priv->x_right != -1) {
4960 toplevel->priv->x_right = -1;
4961 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "x-right");
4962 }
4963 }
4964
4965 if (toplevel->priv->y_centered &&
4966 (orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM))) {
4967 toplevel->priv->y_centered = FALSE(0);
4968 toplevel->priv->y = (monitor_geom.height - toplevel->priv->geometry.height) / 2;
4969 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "y");
4970 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "y-centered");
4971
4972 if (toplevel->priv->y_bottom != -1) {
4973 toplevel->priv->y_bottom = -1;
4974 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "y-bottom");
4975 }
4976 }
4977
4978 rotate = FALSE(0);
4979 if ((orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)) &&
4980 (toplevel->priv->orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT)))
4981 rotate = TRUE(!(0));
4982 else if ((orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT)) &&
4983 (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)))
4984 rotate = TRUE(!(0));
4985
4986 /* rotate around the center */
4987 if (rotate && !toplevel->priv->position_centered && !toplevel->priv->expand &&
4988 toplevel->priv->updated_geometry_initial) {
4989 toplevel->priv->position_centered = TRUE(!(0));
4990
4991 /* x, y temporary refer to the panel center, so we don't care
4992 * about x_right, y_bottom. Those will get updated in
4993 * panel_toplevel_update_position() accordingly. */
4994 if (!toplevel->priv->x_centered) {
4995 toplevel->priv->x += toplevel->priv->geometry.width / 2;
4996 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "x");
4997 }
4998
4999 if (!toplevel->priv->y_centered) {
5000 toplevel->priv->y += toplevel->priv->geometry.height / 2;
5001 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "y");
5002 }
5003
5004 }
5005
5006 toplevel->priv->orientation = orientation;
5007 update_style_classes (toplevel);
5008
5009 gtk_widget_reset_style (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
5010
5011 panel_toplevel_update_hide_buttons (toplevel);
5012
5013 panel_widget_set_orientation (
5014 toplevel->priv->panel_widget,
5015 (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)) ?
5016 GTK_ORIENTATION_HORIZONTAL :
5017 GTK_ORIENTATION_VERTICAL);
5018
5019 switch (toplevel->priv->state) {
5020 case PANEL_STATE_HIDDEN_UP:
5021 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM))
5022 toplevel->priv->state = PANEL_STATE_HIDDEN_LEFT;
5023 break;
5024 case PANEL_STATE_HIDDEN_DOWN:
5025 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM))
5026 toplevel->priv->state = PANEL_STATE_HIDDEN_RIGHT;
5027 break;
5028 case PANEL_STATE_HIDDEN_LEFT:
5029 if (toplevel->priv->orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT))
5030 toplevel->priv->state = PANEL_STATE_HIDDEN_UP;
5031 break;
5032 case PANEL_STATE_HIDDEN_RIGHT:
5033 if (toplevel->priv->orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT))
5034 toplevel->priv->state = PANEL_STATE_HIDDEN_DOWN;
5035 break;
5036 default:
5037 break;
5038 }
5039
5040 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
5041
5042 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "orientation");
5043
5044 g_object_thaw_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
);
5045
5046#ifdef HAVE_WAYLAND1
5047 if (GDK_IS_WAYLAND_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel)))(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gtk_widget_get_display (((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((toplevel)), ((gtk_widget_get_type ()))))
))))); GType __t = ((gdk_wayland_display_get_type())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
) {
5048 wayland_panel_toplevel_update_placement (toplevel);
5049 }
5050#endif /* HAVE_WAYLAND */
5051}
5052
5053PanelOrientation
5054panel_toplevel_get_orientation (PanelToplevel *toplevel)
5055{
5056 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), PANEL_ORIENTATION_TOP)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return (PANEL_ORIENTATION_TOP
); } } while (0)
;
5057
5058 return toplevel->priv->orientation;
5059}
5060
5061void
5062panel_toplevel_set_size (PanelToplevel *toplevel,
5063 int size)
5064{
5065 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
5066 g_return_if_fail (size >= 0)do { if ((size >= 0)) { } else { g_return_if_fail_warning (
((gchar*) 0), ((const char*) (__func__)), "size >= 0"); return
; } } while (0)
;
5067
5068 if (toplevel->priv->size == size)
5069 return;
5070
5071 toplevel->priv->size = size;
5072
5073 panel_widget_set_size (toplevel->priv->panel_widget, toplevel->priv->size);
5074
5075 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
5076
5077 panel_toplevel_update_hide_buttons (toplevel);
5078
5079 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "size");
5080}
5081
5082int
5083panel_toplevel_get_size (PanelToplevel *toplevel)
5084{
5085 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), DEFAULT_SIZE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return (48); }
} while (0)
;
5086
5087 return toplevel->priv->size;
5088}
5089
5090void
5091panel_toplevel_set_auto_hide_size (PanelToplevel *toplevel,
5092 int auto_hide_size)
5093{
5094 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
5095
5096 if (toplevel->priv->auto_hide_size == auto_hide_size)
5097 return;
5098
5099 toplevel->priv->auto_hide_size = auto_hide_size;
5100
5101 if (toplevel->priv->state == PANEL_STATE_AUTO_HIDDEN) {
5102 if (panel_toplevel_update_struts (toplevel, FALSE(0))) {
5103 if (toplevel->priv->animate) {
5104 panel_toplevel_unhide (toplevel);
5105 panel_toplevel_hide (toplevel, TRUE(!(0)), -1);
5106 } else
5107 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
5108 }
5109 }
5110
5111 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "auto-hide-size");
5112}
5113
5114int
5115panel_toplevel_get_auto_hide_size (PanelToplevel *toplevel)
5116{
5117 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), DEFAULT_AUTO_HIDE_SIZE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return (1); }
} while (0)
;
5118
5119 return toplevel->priv->auto_hide_size;
5120}
5121
5122void
5123panel_toplevel_set_x (PanelToplevel *toplevel,
5124 int x,
5125 int x_right,
5126 gboolean x_centered)
5127{
5128 gboolean changed = FALSE(0);
5129
5130 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
5131
5132 x_centered = x_centered != FALSE(0);
5133
5134 g_object_freeze_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
);
5135
5136 if (toplevel->priv->x != x) {
5137 toplevel->priv->x = x;
5138 changed = TRUE(!(0));
5139 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "x");
5140 }
5141
5142 if (toplevel->priv->x_right != x_right) {
5143 toplevel->priv->x_right = x_right;
5144 changed = TRUE(!(0));
5145 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "x-right");
5146 }
5147
5148 if (toplevel->priv->x_centered != x_centered) {
5149 toplevel->priv->x_centered = (x_centered != FALSE(0));
5150 changed = TRUE(!(0));
5151 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "x-centered");
5152 }
5153
5154 if (changed)
5155 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
5156
5157 g_object_thaw_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
);
5158}
5159
5160void
5161panel_toplevel_set_y (PanelToplevel *toplevel,
5162 int y,
5163 int y_bottom,
5164 gboolean y_centered)
5165{
5166 gboolean changed = FALSE(0);
5167
5168 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
5169
5170 y_centered = y_centered != FALSE(0);
5171
5172 g_object_freeze_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
);
5173
5174 if (toplevel->priv->y != y) {
5175 toplevel->priv->y = y;
5176 changed = TRUE(!(0));
5177 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "y");
5178 }
5179
5180 if (toplevel->priv->y_bottom != y_bottom) {
5181 toplevel->priv->y_bottom = y_bottom;
5182 changed = TRUE(!(0));
5183 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "y-bottom");
5184 }
5185
5186 if (toplevel->priv->y_centered != y_centered) {
5187 toplevel->priv->y_centered = (y_centered != FALSE(0));
5188 changed = TRUE(!(0));
5189 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "y-centered");
5190 }
5191
5192 if (changed)
5193 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
5194
5195 g_object_thaw_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
);
5196}
5197
5198void
5199panel_toplevel_get_position (PanelToplevel *toplevel,
5200 int *x,
5201 int *x_right,
5202 int *y,
5203 int *y_bottom)
5204{
5205 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
5206
5207 if (x)
5208 *x = toplevel->priv->x;
5209
5210 if (y)
5211 *y = toplevel->priv->y;
5212
5213 if (x_right)
5214 *x_right = toplevel->priv->x_right;
5215
5216 if (y_bottom)
5217 *y_bottom = toplevel->priv->y_bottom;
5218}
5219
5220gboolean
5221panel_toplevel_get_x_centered (PanelToplevel *toplevel)
5222{
5223 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return ((0));
} } while (0)
;
5224
5225 return toplevel->priv->x_centered;
5226}
5227
5228gboolean
5229panel_toplevel_get_y_centered (PanelToplevel *toplevel)
5230{
5231 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return ((0));
} } while (0)
;
5232
5233 return toplevel->priv->y_centered;
5234}
5235
5236/**
5237 * panel_toplevel_set_monitor_internal:
5238 *
5239 * Sets the monitor of the toplevel, but only the internal state. We need to
5240 * make the difference between the internal state and the configuration of the
5241 * user because internal constraints might affect the monitor of the toplevel.
5242 *
5243 * panel_toplevel_set_monitor_internal() won't update the configuration of the
5244 * user.
5245 **/
5246static void
5247panel_toplevel_set_monitor_internal (PanelToplevel *toplevel,
5248 int monitor,
5249 gboolean force_resize)
5250{
5251 if (toplevel->priv->monitor == monitor)
5252 return;
5253
5254 toplevel->priv->monitor = monitor;
5255
5256 if (force_resize)
5257 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
5258}
5259
5260/**
5261 * panel_toplevel_update_monitor:
5262 *
5263 * Moves the toplevel to its configured monitor or the first one, if needed.
5264 * This generally happens when the configured monitor was non-existing before,
5265 * and it appeared at runtime, or if it was existing and disappeared.
5266 *
5267 * This must only be called at the beginning of the size request of the
5268 * toplevel because it doesn't queue a size request.
5269 **/
5270static void
5271panel_toplevel_update_monitor (PanelToplevel *toplevel)
5272{
5273 /* If we were not using the configured monitor, can we use it now? */
5274 if ((toplevel->priv->configured_monitor != -1) &&
5275 (toplevel->priv->configured_monitor != toplevel->priv->monitor) &&
5276 toplevel->priv->configured_monitor < panel_multimonitor_monitors ()) {
5277 panel_toplevel_set_monitor_internal (toplevel,
5278 toplevel->priv->configured_monitor,
5279 FALSE(0));
5280
5281 /* else, can we still use the monitor we were using? */
5282 } else if (toplevel->priv->monitor >= panel_multimonitor_monitors ()) {
5283 panel_toplevel_set_monitor_internal (toplevel,
5284 0,
5285 FALSE(0));
5286 }
5287}
5288
5289void
5290panel_toplevel_set_monitor (PanelToplevel *toplevel,
5291 int monitor)
5292{
5293 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
5294
5295 if (toplevel->priv->configured_monitor == monitor)
5296 return;
5297
5298 toplevel->priv->configured_monitor = monitor;
5299
5300 /* Only use the configured monitor if it's existing. Else, we ignore
5301 * the non-existing monitor, and keep the old one. The main use case is
5302 * when logging in after having used a multimonitor environment.
5303 * We will put the panel on the monitor 0 for this session, and it will
5304 * move back to the right monitor next time. */
5305 if (monitor < panel_multimonitor_monitors ())
5306 panel_toplevel_set_monitor_internal (toplevel, monitor, TRUE(!(0)));
5307
5308 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "monitor");
5309}
5310
5311int
5312panel_toplevel_get_monitor (PanelToplevel *toplevel)
5313{
5314 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), -1)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return (-1); }
} while (0)
;
5315
5316 return toplevel->priv->monitor;
5317}
5318
5319void
5320panel_toplevel_set_auto_hide (PanelToplevel *toplevel,
5321 gboolean auto_hide)
5322{
5323 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
5324
5325 auto_hide = auto_hide != FALSE(0);
5326
5327 if (toplevel->priv->auto_hide == auto_hide)
5328 return;
5329
5330 toplevel->priv->auto_hide = (auto_hide != FALSE(0));
5331
5332 if (toplevel->priv->auto_hide)
5333 panel_toplevel_queue_auto_hide (toplevel);
5334 else
5335 panel_toplevel_queue_auto_unhide (toplevel);
5336
5337 if (panel_toplevel_update_struts (toplevel, FALSE(0)))
5338 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
5339
5340 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "auto-hide");
5341}
5342
5343gboolean
5344panel_toplevel_get_auto_hide (PanelToplevel *toplevel)
5345{
5346 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return ((0));
} } while (0)
;
5347
5348 return toplevel->priv->auto_hide;
5349}
5350
5351void
5352panel_toplevel_set_hide_delay (PanelToplevel *toplevel,
5353 int hide_delay)
5354{
5355 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
5356
5357 if (toplevel->priv->hide_delay == hide_delay)
5358 return;
5359
5360 toplevel->priv->hide_delay = hide_delay;
5361
5362 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "hide-delay");
5363}
5364
5365int
5366panel_toplevel_get_hide_delay (PanelToplevel *toplevel)
5367{
5368 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), -1)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return (-1); }
} while (0)
;
5369
5370 return toplevel->priv->hide_delay;
5371}
5372
5373void
5374panel_toplevel_set_unhide_delay (PanelToplevel *toplevel,
5375 int unhide_delay)
5376{
5377 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
5378
5379 if (toplevel->priv->unhide_delay == unhide_delay)
5380 return;
5381
5382 toplevel->priv->unhide_delay = unhide_delay;
5383
5384 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "unhide-delay");
5385}
5386
5387int
5388panel_toplevel_get_unhide_delay (PanelToplevel *toplevel)
5389{
5390 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), -1)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return (-1); }
} while (0)
;
5391
5392 return toplevel->priv->unhide_delay;
5393}
5394
5395void
5396panel_toplevel_set_animate (PanelToplevel *toplevel,
5397 gboolean animate)
5398{
5399 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
5400
5401 animate = animate != FALSE(0);
5402
5403 if (toplevel->priv->animate == animate)
5404 return;
5405
5406 toplevel->priv->animate = (animate != FALSE(0));
5407
5408 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "animate");
5409}
5410
5411gboolean
5412panel_toplevel_get_animate (PanelToplevel *toplevel)
5413{
5414 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return ((0));
} } while (0)
;
5415
5416 return toplevel->priv->animate;
5417}
5418
5419void
5420panel_toplevel_set_animation_speed (PanelToplevel *toplevel,
5421 PanelAnimationSpeed animation_speed)
5422{
5423 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
5424
5425 if (toplevel->priv->animation_speed == animation_speed)
5426 return;
5427
5428 toplevel->priv->animation_speed = animation_speed;
5429
5430 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "animation-speed");
5431}
5432
5433PanelAnimationSpeed
5434panel_toplevel_get_animation_speed (PanelToplevel *toplevel)
5435{
5436 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), 0)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return (0); }
} while (0)
;
5437
5438 return toplevel->priv->animation_speed;
5439}
5440
5441void
5442panel_toplevel_set_enable_buttons (PanelToplevel *toplevel,
5443 gboolean enable_buttons)
5444{
5445 enable_buttons = enable_buttons != FALSE(0);
5446
5447 if (toplevel->priv->buttons_enabled == enable_buttons)
5448 return;
5449
5450 toplevel->priv->buttons_enabled = enable_buttons;
5451
5452 panel_toplevel_update_hide_buttons (toplevel);
5453
5454 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "buttons-enabled");
5455}
5456
5457gboolean
5458panel_toplevel_get_enable_buttons (PanelToplevel *toplevel)
5459{
5460 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return ((0));
} } while (0)
;
5461
5462 return toplevel->priv->buttons_enabled;
5463}
5464
5465void
5466panel_toplevel_set_enable_arrows (PanelToplevel *toplevel,
5467 gboolean enable_arrows)
5468{
5469 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
5470
5471 enable_arrows = enable_arrows != FALSE(0);
5472
5473 if (toplevel->priv->arrows_enabled == enable_arrows)
5474 return;
5475
5476 toplevel->priv->arrows_enabled = (enable_arrows != FALSE(0));
5477
5478 panel_toplevel_update_hide_buttons (toplevel);
5479
5480 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "arrows-enabled");
5481}
5482
5483gboolean
5484panel_toplevel_get_enable_arrows (PanelToplevel *toplevel)
5485{
5486 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return ((0));
} } while (0)
;
5487
5488 return toplevel->priv->arrows_enabled;
5489}
5490
5491void
5492panel_toplevel_rotate (PanelToplevel *toplevel,
5493 gboolean clockwise)
5494{
5495 PanelOrientation orientation;
5496
5497 /* Relies on PanelOrientation definition:
5498 *
5499 * typedef enum {
5500 * PANEL_ORIENTATION_TOP = 1 << 0,
5501 * PANEL_ORIENTATION_RIGHT = 1 << 1,
5502 * PANEL_ORIENTATION_BOTTOM = 1 << 2,
5503 * PANEL_ORIENTATION_LEFT = 1 << 3
5504 * } PanelOrientation;
5505 */
5506
5507 orientation = toplevel->priv->orientation;
5508
5509 if (clockwise)
5510 orientation <<= 1;
5511 else
5512 orientation >>= 1;
5513
5514 if (orientation == 0)
5515 orientation = PANEL_ORIENTATION_LEFT;
5516
5517 else if (orientation > PANEL_ORIENTATION_LEFT)
5518 orientation = PANEL_ORIENTATION_TOP;
5519
5520 panel_toplevel_set_orientation (toplevel, orientation);
5521}
5522
5523PanelState
5524panel_toplevel_get_state (PanelToplevel *toplevel)
5525{
5526 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), 0)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return (0); }
} while (0)
;
5527
5528 return toplevel->priv->state;
5529}
5530
5531gboolean
5532panel_toplevel_get_is_hidden (PanelToplevel *toplevel)
5533{
5534 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return ((0));
} } while (0)
;
5535
5536 if (toplevel->priv->state == PANEL_STATE_HIDDEN_UP ||
5537 toplevel->priv->state == PANEL_STATE_HIDDEN_DOWN ||
5538 toplevel->priv->state == PANEL_STATE_HIDDEN_LEFT ||
5539 toplevel->priv->state == PANEL_STATE_HIDDEN_RIGHT)
5540 return TRUE(!(0));
5541
5542 return FALSE(0);
5543}
5544
5545int
5546panel_toplevel_get_minimum_size (PanelToplevel *toplevel)
5547{
5548 return calculate_minimum_height (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
,
5549 toplevel->priv->orientation);
5550}
5551
5552int
5553panel_toplevel_get_maximum_size (PanelToplevel *toplevel)
5554{
5555 GdkRectangle monitor_geom;
5556
5557 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
5558
5559 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM))
5560 return monitor_geom.height / MAXIMUM_SIZE_SCREEN_RATIO5;
5561 else
5562 return monitor_geom.width / MAXIMUM_SIZE_SCREEN_RATIO5;
5563}
diff --git a/2024-06-18-172109-13286-1@e182420b844f_master/report-0e9e9c.html b/2024-06-18-172109-13286-1@e182420b844f_master/report-0e9e9c.html new file mode 100644 index 00000000..bdd970f5 --- /dev/null +++ b/2024-06-18-172109-13286-1@e182420b844f_master/report-0e9e9c.html @@ -0,0 +1,868 @@ + + + +mate-panel-applet-gsettings.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:libmate-panel-applet/mate-panel-applet-gsettings.c
Warning:line 99, column 56
Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name mate-panel-applet-gsettings.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/libmate-panel-applet -fcoverage-compilation-dir=/rootdir/libmate-panel-applet -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I .. -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/gio-unix-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I ../libmate-panel-applet -D MATELOCALEDIR="/usr/local/share/locale" -D PIC -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-18-172109-13286-1 -x c mate-panel-applet-gsettings.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * mate-panel-applet-gsettings.c: panel applet preferences handling.
3 *
4 * Copyright (C) 2012 Stefano Karapetsas
5 * Copyright (C) 2012-2021 MATE Developers
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
16 *
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
21 *
22 * Authors:
23 * Stefano Karapetsas <stefano@karapetsas.com>
24 */
25
26#include <gtk/gtk.h>
27#include <gio/gio.h>
28
29#include "mate-panel-applet.h"
30#include "mate-panel-applet-gsettings.h"
31
32static GVariant *
33add_to_dict (GVariant *dict, const gchar *schema, const gchar *path)
34{
35 GVariantIter iter;
36 GVariantBuilder builder;
37 gboolean is_schema_found;
38 gboolean is_incorrect_schema;
39 gint path_counter;
40
41 gchar *key;
42 gchar *value;
43
44 g_variant_builder_init (&builder, (const GVariantType *) "a{ss}");
45 g_variant_iter_init (&iter, dict);
46
47 is_schema_found = FALSE(0);
48 is_incorrect_schema = FALSE(0);
49 path_counter = 0;
50
51 while (g_variant_iter_next (&iter, "{ss}", &key, &value)) {
52 gboolean path_is_found = FALSE(0);
53 if (g_strcmp0 (value, path) == 0) {
54 path_is_found = TRUE(!(0));
55 path_counter++;
56 if (g_strcmp0 (key, schema) == 0) {
57 is_schema_found = TRUE(!(0));
58 } else {
59 // skip incoorect schema for path
60 is_incorrect_schema = TRUE(!(0));
61 g_free (key);
62 g_free (value);
63 continue;
64 }
65 }
66
67 gboolean need_add_to_dict = !path_is_found || path_counter < 2;
68
69 if (need_add_to_dict) {
70 g_variant_builder_add (&builder, "{ss}", key, value);
71 }
72
73 g_free (key);
74 g_free (value);
75 }
76
77 if (!is_schema_found) {
78 g_variant_builder_add (&builder, "{ss}", schema, path);
79 }
80
81 if (!is_schema_found || is_incorrect_schema || (path_counter > 1)) {
82 return g_variant_ref_sink (g_variant_builder_end (&builder));
83 } else {
84 g_variant_builder_clear (&builder);
85 // no changes
86 return NULL((void*)0);
87 }
88}
89
90static void
91register_dconf_editor_relocatable_schema (const gchar *schema, const gchar *path)
92{
93 GSettings *dconf_editor_settings;
94 dconf_editor_settings = g_settings_new ("ca.desrt.dconf-editor.Settings");
95
96 if (dconf_editor_settings && g_settings_is_writable (dconf_editor_settings, "relocatable-schemas-user-paths")) {
97 GVariant *relocatable_schemas = g_settings_get_value (dconf_editor_settings, "relocatable-schemas-user-paths");
98
99 if (g_variant_is_of_type (relocatable_schemas, G_VARIANT_TYPE_DICTIONARY((const GVariantType *) "a{?*}"))) {
Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption
100 GVariant * new_relocatable_schemas = add_to_dict (relocatable_schemas, schema, path);
101 if (new_relocatable_schemas) {
102 g_settings_set_value (dconf_editor_settings, "relocatable-schemas-user-paths", new_relocatable_schemas);
103 g_variant_unref (new_relocatable_schemas);
104 }
105 }
106
107 g_variant_unref (relocatable_schemas);
108 }
109
110 g_object_unref (dconf_editor_settings);
111}
112
113GSettings *
114mate_panel_applet_settings_new (MatePanelApplet *applet, gchar *schema)
115{
116 GSettings *settings = NULL((void*)0);
117 gchar *path;
118
119 g_return_val_if_fail (MATE_PANEL_IS_APPLET (applet), NULL)do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return (((void*)0)); } } while (0)
;
120
121 path = mate_panel_applet_get_preferences_path (applet);
122
123 if (path) {
124 settings = g_settings_new_with_path (schema, path);
125 register_dconf_editor_relocatable_schema (schema, path);
126 g_free (path);
127 }
128
129 return settings;
130}
131
132GList*
133mate_panel_applet_settings_get_glist (GSettings *settings, gchar *key)
134{
135 gchar **array;
136 GList *list = NULL((void*)0);
137
138 array = g_settings_get_strv (settings, key);
139 if (array != NULL((void*)0)) {
140 for (gint i = 0; array[i]; i++) {
141 list = g_list_prepend (list, array[i]);
142 }
143 g_free (array);
144 }
145 return g_list_reverse (list);
146}
147
148void
149mate_panel_applet_settings_set_glist (GSettings *settings, gchar *key, GList *list)
150{
151 GArray *array;
152
153 array = g_array_new (TRUE(!(0)), TRUE(!(0)), sizeof (gchar *));
154 for (GList *l = list; l; l = l->next) {
155 array = g_array_append_val (array, l->data)g_array_append_vals (array, &(l->data), 1);
156 }
157 g_settings_set_strv (settings, key, (const gchar **) array->data);
158 g_array_free (array, TRUE(!(0)));
159}
160
161GSList*
162mate_panel_applet_settings_get_gslist (GSettings *settings, gchar *key)
163{
164 gchar **array;
165 GSList *list = NULL((void*)0);
166
167 array = g_settings_get_strv (settings, key);
168 if (array != NULL((void*)0)) {
169 for (gint i = 0; array[i]; i++) {
170 list = g_slist_prepend (list, array[i]);
171 }
172 g_free (array);
173 }
174 return g_slist_reverse (list);
175}
176
177void
178mate_panel_applet_settings_set_gslist (GSettings *settings, gchar *key, GSList *list)
179{
180 GArray *array;
181
182 array = g_array_new (TRUE(!(0)), TRUE(!(0)), sizeof (gchar *));
183 for (GSList *l = list; l; l = l->next) {
184 array = g_array_append_val (array, l->data)g_array_append_vals (array, &(l->data), 1);
185 }
186 g_settings_set_strv (settings, key, (const gchar **) array->data);
187 g_array_free (array, TRUE(!(0)));
188}
diff --git a/2024-06-18-172109-13286-1@e182420b844f_master/report-0f6d0c.html b/2024-06-18-172109-13286-1@e182420b844f_master/report-0f6d0c.html new file mode 100644 index 00000000..4f85c525 --- /dev/null +++ b/2024-06-18-172109-13286-1@e182420b844f_master/report-0f6d0c.html @@ -0,0 +1,2409 @@ + + + +panel-profile.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:mate-panel/panel-profile.c
Warning:line 847, column 39
Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name panel-profile.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/mate-panel -fcoverage-compilation-dir=/rootdir/mate-panel -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I .. -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/startup-notification-1.0 -I /usr/include/mate-menus -I /usr/include/gio-unix-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/dconf -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/dconf -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I . -I . -I ../mate-panel -I ../mate-panel/mate-submodules -I ../mate-panel/libpanel-util -D MATELOCALEDIR="/usr/local/share/locale" -D PANELDATADIR="/usr/local/share/mate-panel" -I /usr/include/gtk-layer-shell -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/gtk-3.0 -I /usr/include/cloudproviders -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/atk-1.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/gio-unix-2.0 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -D PANEL_MODULES_DIR="/usr/local/lib/mate-panel/modules" -D MATEMENU_I_KNOW_THIS_IS_UNSTABLE -I /usr/include/gtk-layer-shell -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/gtk-3.0 -I /usr/include/cloudproviders -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/atk-1.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/gio-unix-2.0 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-18-172109-13286-1 -x c panel-profile.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * panel-profile.c:
3 *
4 * Copyright (C) 2003 Sun Microsystems, Inc.
5 * Copyright (C) 2012-2021 MATE Developers
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of the
10 * License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301, USA.
21 *
22 * Authors:
23 * Mark McLoughlin <mark@skynet.ie>
24 */
25
26#include <config.h>
27
28#include "panel-profile.h"
29#include "panel-layout.h"
30
31#include <string.h>
32#include <glib/gi18n.h>
33#include <gio/gio.h>
34
35#ifdef HAVE_X111
36#include <gdk/gdkx.h>
37#endif
38
39#include <libpanel-util/panel-list.h>
40#include <libmate-desktop/mate-dconf.h>
41#include <libmate-desktop/mate-gsettings.h>
42
43#include "applet.h"
44#include "panel.h"
45#include "panel-widget.h"
46#include "panel-util.h"
47#include "panel-multimonitor.h"
48#include "panel-toplevel.h"
49#include "panel-lockdown.h"
50#include "panel-schemas.h"
51
52typedef struct {
53 GdkScreen *screen;
54 int monitor;
55 int size;
56 int x;
57 int x_right;
58 gboolean x_centered;
59 int y;
60 int y_bottom;
61 gboolean y_centered;
62 PanelOrientation orientation;
63
64 guint screen_changed : 1;
65 guint monitor_changed : 1;
66 guint size_changed : 1;
67 guint x_changed : 1;
68 guint x_right_changed : 1;
69 guint x_centered_changed : 1;
70 guint y_changed : 1;
71 guint y_bottom_changed : 1;
72 guint y_centered_changed : 1;
73 guint orientation_changed : 1;
74} ToplevelLocationChange;
75
76typedef const char *(*PanelProfileGetIdFunc) (gpointer object);
77typedef gboolean (*PanelProfileOnLoadQueue) (const char *id);
78typedef void (*PanelProfileLoadFunc) (const char *id);
79typedef void (*PanelProfileDestroyFunc) (const char *id);
80
81static GSettings *profile_settings = NULL((void*)0);
82
83static GQuark toplevel_id_quark = 0;
84#if 0
85static GQuark queued_changes_quark = 0;
86#endif
87static GQuark commit_timeout_quark = 0;
88
89static void panel_profile_object_id_list_update (gchar **objects);
90static void panel_profile_ensure_toplevel_per_screen (void);
91
92static void
93panel_profile_set_toplevel_id (PanelToplevel *toplevel,
94 const char *id)
95{
96 if (!toplevel_id_quark)
97 toplevel_id_quark = g_quark_from_static_string ("panel-toplevel-id");
98
99 g_object_set_qdata_full (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
,
100 toplevel_id_quark,
101 g_strdup (id)g_strdup_inline (id),
102 g_free);
103}
104
105const char *
106panel_profile_get_toplevel_id (PanelToplevel *toplevel)
107{
108 if (!toplevel_id_quark)
109 return NULL((void*)0);
110
111 return g_object_get_qdata (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, toplevel_id_quark);
112}
113
114PanelToplevel *
115panel_profile_get_toplevel_by_id (const char *toplevel_id)
116{
117 GSList *toplevels, *l;
118
119 if (!toplevel_id || !toplevel_id [0])
120 return NULL((void*)0);
121
122 toplevels = panel_toplevel_list_toplevels ();
123 for (l = toplevels; l; l = l->next)
124 if (!strcmp (panel_profile_get_toplevel_id (l->data), toplevel_id))
125 return l->data;
126
127 return NULL((void*)0);
128}
129
130char *
131panel_profile_find_new_id (PanelGSettingsKeyType type)
132{
133 gchar **existing_ids;
134 char *retval = NULL((void*)0);
135 char *prefix = NULL((void*)0);
136 char *dir = NULL((void*)0);
137 int i;
138 int j;
139
140 switch (type) {
141 case PANEL_GSETTINGS_TOPLEVELS:
142 prefix = PANEL_TOPLEVEL_DEFAULT_PREFIX"toplevel";
143 dir = PANEL_TOPLEVEL_PATH"/org/mate/panel/toplevels/";
144 break;
145 case PANEL_GSETTINGS_OBJECTS:
146 prefix = PANEL_OBJECT_DEFAULT_PREFIX"object";
147 dir = PANEL_OBJECT_PATH"/org/mate/panel/objects/";
148 break;
149 default:
150 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-profile.c"
, 150, ((const char*) (__func__)), ((void*)0)); } while (0)
;
151 break;
152 }
153
154 existing_ids = mate_dconf_list_subdirs (dir, TRUE(!(0)));
155
156 for (i = 0; !retval; i++) {
157 retval = g_strdup_printf ("%s-%d", prefix, i);
158
159 for (j = 0; existing_ids[j] != NULL((void*)0); j++) {
160 if (g_strcmp0 (existing_ids[j], retval) == 0) {
161 g_clear_pointer (&retval, g_free)do { _Static_assert (sizeof *(&retval) == sizeof (gpointer
), "Expression evaluates to false"); __typeof__ ((&retval
)) _pp = (&retval); __typeof__ (*(&retval)) _ptr = *_pp
; *_pp = ((void*)0); if (_ptr) (g_free) (_ptr); } while (0)
;
162 break;
163 }
164 }
165 }
166 if (existing_ids)
167 g_strfreev (existing_ids);
168
169 g_assert (retval != NULL)do { if (retval != ((void*)0)) ; else g_assertion_message_expr
(((gchar*) 0), "panel-profile.c", 169, ((const char*) (__func__
)), "retval != NULL"); } while (0)
;
170
171 return retval;
172}
173
174static void
175panel_profile_remove_commit_timeout (guint timeout)
176{
177 g_source_remove (timeout);
178}
179
180static void
181panel_profile_set_commit_timeout (PanelToplevel *toplevel,
182 guint timeout)
183{
184 GDestroyNotify destroy_notify;
185
186 if (!commit_timeout_quark)
187 commit_timeout_quark = g_quark_from_static_string ("panel-queued-timeout");
188
189 if (timeout)
190 destroy_notify = (GDestroyNotify) panel_profile_remove_commit_timeout;
191 else
192 destroy_notify = NULL((void*)0);
193
194 g_object_set_qdata_full (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
,
195 commit_timeout_quark,
196 GUINT_TO_POINTER (timeout)((gpointer) (gulong) (timeout)),
197 destroy_notify);
198}
199
200static guint
201panel_profile_get_commit_timeout (GObject *object)
202{
203 if (!commit_timeout_quark)
204 return 0;
205
206 return GPOINTER_TO_UINT (g_object_get_qdata (object, commit_timeout_quark))((guint) (gulong) (g_object_get_qdata (object, commit_timeout_quark
)))
;
207}
208
209gboolean
210panel_profile_key_is_writable (PanelToplevel *toplevel, gchar *key) {
211 return g_settings_is_writable (toplevel->settings, key);
212}
213
214gboolean
215panel_profile_background_key_is_writable (PanelToplevel *toplevel, gchar *key) {
216 return g_settings_is_writable (toplevel->background_settings, key);
217}
218
219void
220panel_profile_set_background_type (PanelToplevel *toplevel,
221 PanelBackgroundType background_type)
222{
223 g_settings_set_enum (toplevel->background_settings,
224 "type",
225 background_type);
226}
227
228PanelBackgroundType
229panel_profile_get_background_type (PanelToplevel *toplevel)
230{
231 PanelBackgroundType background_type;
232 background_type = g_settings_get_enum (toplevel->background_settings,
233 "type");
234 return background_type;
235}
236
237void
238panel_profile_set_background_color (PanelToplevel *toplevel,
239 GdkRGBA *color)
240{
241 char *color_str;
242
243 color_str = gdk_rgba_to_string (color);
244
245 g_settings_set_string (toplevel->background_settings, "color", color_str);
246
247 g_free (color_str);
248}
249
250void
251panel_profile_get_background_color (PanelToplevel *toplevel,
252 GdkRGBA *color)
253{
254 char *color_str;
255
256 color_str = g_settings_get_string (toplevel->background_settings, "color");
257 if (!color_str || !gdk_rgba_parse (color, color_str)) {
258 color->red = 0.;
259 color->green = 0.;
260 color->blue = 0.;
261 color->alpha = 1.;
262 }
263
264 g_free (color_str);
265}
266
267void
268panel_profile_set_background_opacity (PanelToplevel *toplevel,
269 gdouble percentage)
270{
271 GdkRGBA color;
272 panel_profile_get_background_color (toplevel, &color);
273 color.alpha = percentage / 100.0;
274 panel_profile_set_background_color (toplevel, &color);
275}
276
277gdouble
278panel_profile_get_background_opacity (PanelToplevel *toplevel)
279{
280 GdkRGBA color;
281 panel_profile_get_background_color (toplevel, &color);
282 return color.alpha * 100.0;
283}
284
285void
286panel_profile_set_background_image (PanelToplevel *toplevel,
287 const char *image)
288{
289 if (image && image [0])
290 g_settings_set_string (toplevel->background_settings, "image", image);
291 else
292 g_settings_reset (toplevel->background_settings, "image");
293}
294
295char *
296panel_profile_get_background_image (PanelToplevel *toplevel)
297{
298 return g_settings_get_string (toplevel->background_settings, "image");
299}
300
301void
302panel_profile_set_toplevel_name (PanelToplevel *toplevel,
303 const char *name)
304{
305 if (name && name [0])
306 g_settings_set_string (toplevel->settings, "name", name);
307 else
308 g_settings_reset (toplevel->settings, "name");
309}
310
311char *
312panel_profile_get_toplevel_name (PanelToplevel *toplevel)
313{
314 return g_settings_get_string (toplevel->settings, "name");
315}
316
317void
318panel_profile_set_toplevel_orientation (PanelToplevel *toplevel,
319 PanelOrientation orientation)
320{
321 g_settings_set_enum (toplevel->settings, "orientation", orientation);
322}
323
324PanelOrientation
325panel_profile_get_toplevel_orientation (PanelToplevel *toplevel)
326{
327 PanelOrientation orientation;
328 orientation = g_settings_get_enum (toplevel->settings, "orientation");
329 return orientation;
330}
331
332#define TOPLEVEL_GET_SET_FUNCS(k, p, t, s, a)void panel_profile_set_p_s (PanelToplevel *toplevel, a s) { g_settings_set_t
(toplevel->settings, k, s); } a panel_profile_get_p_s (PanelToplevel
*toplevel) { a retval; retval = g_settings_get_t (toplevel->
settings, k); return retval; }
\
333 void \
334 panel_profile_set_##p##_##s (PanelToplevel *toplevel, a s) \
335 { \
336 g_settings_set_##t (toplevel->settings, k, s); \
337 } \
338 a \
339 panel_profile_get_##p##_##s (PanelToplevel *toplevel) \
340 { \
341 a retval; \
342 retval = g_settings_get_##t (toplevel->settings, k); \
343 return retval; \
344 }
345
346TOPLEVEL_GET_SET_FUNCS ("size", toplevel, int, size, int)void panel_profile_set_toplevel_size (PanelToplevel *toplevel
, int size) { g_settings_set_int (toplevel->settings, "size"
, size); } int panel_profile_get_toplevel_size (PanelToplevel
*toplevel) { int retval; retval = g_settings_get_int (toplevel
->settings, "size"); return retval; }
347TOPLEVEL_GET_SET_FUNCS ("expand", toplevel, boolean, expand, gboolean)void panel_profile_set_toplevel_expand (PanelToplevel *toplevel
, gboolean expand) { g_settings_set_boolean (toplevel->settings
, "expand", expand); } gboolean panel_profile_get_toplevel_expand
(PanelToplevel *toplevel) { gboolean retval; retval = g_settings_get_boolean
(toplevel->settings, "expand"); return retval; }
348TOPLEVEL_GET_SET_FUNCS ("auto-hide", toplevel, boolean, auto_hide, gboolean)void panel_profile_set_toplevel_auto_hide (PanelToplevel *toplevel
, gboolean auto_hide) { g_settings_set_boolean (toplevel->
settings, "auto-hide", auto_hide); } gboolean panel_profile_get_toplevel_auto_hide
(PanelToplevel *toplevel) { gboolean retval; retval = g_settings_get_boolean
(toplevel->settings, "auto-hide"); return retval; }
349TOPLEVEL_GET_SET_FUNCS ("enable-buttons", toplevel, boolean, enable_buttons, gboolean)void panel_profile_set_toplevel_enable_buttons (PanelToplevel
*toplevel, gboolean enable_buttons) { g_settings_set_boolean
(toplevel->settings, "enable-buttons", enable_buttons); }
gboolean panel_profile_get_toplevel_enable_buttons (PanelToplevel
*toplevel) { gboolean retval; retval = g_settings_get_boolean
(toplevel->settings, "enable-buttons"); return retval; }
350TOPLEVEL_GET_SET_FUNCS ("enable-arrows", toplevel, boolean, enable_arrows, gboolean)void panel_profile_set_toplevel_enable_arrows (PanelToplevel *
toplevel, gboolean enable_arrows) { g_settings_set_boolean (toplevel
->settings, "enable-arrows", enable_arrows); } gboolean panel_profile_get_toplevel_enable_arrows
(PanelToplevel *toplevel) { gboolean retval; retval = g_settings_get_boolean
(toplevel->settings, "enable-arrows"); return retval; }
351
352#define TOPLEVEL_GET_SET_BG_FUNCS(k, p, t, s, a)void panel_profile_set_p_s (PanelToplevel *toplevel, a s) { g_settings_set_t
(toplevel->background_settings, k, s); } a panel_profile_get_p_s
(PanelToplevel *toplevel) { a retval; retval = g_settings_get_t
(toplevel->background_settings, k); return retval; }
\
353 void \
354 panel_profile_set_##p##_##s (PanelToplevel *toplevel, a s) \
355 { \
356 g_settings_set_##t (toplevel->background_settings, k, s); \
357 } \
358 a \
359 panel_profile_get_##p##_##s (PanelToplevel *toplevel) \
360 { \
361 a retval; \
362 retval = g_settings_get_##t (toplevel->background_settings, k); \
363 return retval; \
364 }
365
366TOPLEVEL_GET_SET_BG_FUNCS ("fit", background, boolean, fit, gboolean)void panel_profile_set_background_fit (PanelToplevel *toplevel
, gboolean fit) { g_settings_set_boolean (toplevel->background_settings
, "fit", fit); } gboolean panel_profile_get_background_fit (PanelToplevel
*toplevel) { gboolean retval; retval = g_settings_get_boolean
(toplevel->background_settings, "fit"); return retval; }
367TOPLEVEL_GET_SET_BG_FUNCS ("stretch", background, boolean, stretch, gboolean)void panel_profile_set_background_stretch (PanelToplevel *toplevel
, gboolean stretch) { g_settings_set_boolean (toplevel->background_settings
, "stretch", stretch); } gboolean panel_profile_get_background_stretch
(PanelToplevel *toplevel) { gboolean retval; retval = g_settings_get_boolean
(toplevel->background_settings, "stretch"); return retval
; }
368TOPLEVEL_GET_SET_BG_FUNCS ("rotate", background, boolean, rotate, gboolean)void panel_profile_set_background_rotate (PanelToplevel *toplevel
, gboolean rotate) { g_settings_set_boolean (toplevel->background_settings
, "rotate", rotate); } gboolean panel_profile_get_background_rotate
(PanelToplevel *toplevel) { gboolean retval; retval = g_settings_get_boolean
(toplevel->background_settings, "rotate"); return retval;
}
369
370GSettings*
371panel_profile_get_attached_object_settings (PanelToplevel *toplevel)
372{
373 GtkWidget *attach_widget;
374 const char *id;
375 char *path;
376 GSettings *settings;
377
378 attach_widget = panel_toplevel_get_attach_widget (toplevel);
379
380 id = mate_panel_applet_get_id_by_widget (attach_widget);
381
382 if (!id)
383 return NULL((void*)0);
384
385 path = g_strdup_printf (PANEL_OBJECT_PATH"/org/mate/panel/objects/" "%s/", id);
386 settings = g_settings_new_with_path (PANEL_OBJECT_SCHEMA"org.mate.panel.object", path);
387 g_free (path);
388
389 return settings;
390}
391
392void
393panel_profile_set_attached_custom_icon (PanelToplevel *toplevel,
394 const char *custom_icon)
395{
396 GSettings *settings;
397 settings = panel_profile_get_attached_object_settings (toplevel);
398
399 g_settings_set_boolean (settings, PANEL_OBJECT_USE_CUSTOM_ICON_KEY"use-custom-icon", custom_icon != NULL((void*)0));
400 g_settings_set_string (settings, PANEL_OBJECT_CUSTOM_ICON_KEY"custom-icon", sure_string (custom_icon)((const char *)((custom_icon)!=((void*)0)?(custom_icon):"")));
401
402 g_object_unref (settings);
403}
404
405char *
406panel_profile_get_attached_custom_icon (PanelToplevel *toplevel)
407{
408 gchar *custom_icon = NULL((void*)0);
409 if (panel_toplevel_get_is_attached (toplevel))
410 {
411 GSettings *settings;
412 settings = panel_profile_get_attached_object_settings (toplevel);
413
414 if (!g_settings_get_boolean (settings, PANEL_OBJECT_USE_CUSTOM_ICON_KEY"use-custom-icon"))
415 {
416 g_object_unref (settings);
417 return NULL((void*)0);
418 }
419
420 custom_icon = g_settings_get_string (settings, PANEL_OBJECT_CUSTOM_ICON_KEY"custom-icon");
421 g_object_unref (settings);
422 }
423 return custom_icon;
424}
425
426gboolean
427panel_profile_is_writable_attached_custom_icon (PanelToplevel *toplevel)
428{
429 gboolean is_writable = FALSE(0);
430 if (panel_toplevel_get_is_attached (toplevel))
431 {
432 GSettings *settings;
433 settings = panel_profile_get_attached_object_settings (toplevel);
434
435 is_writable = g_settings_is_writable (settings, PANEL_OBJECT_USE_CUSTOM_ICON_KEY"use-custom-icon") &&
436 g_settings_is_writable (settings, PANEL_OBJECT_CUSTOM_ICON_KEY"custom-icon");
437
438 g_object_unref (settings);
439 }
440 return is_writable;
441}
442
443void
444panel_profile_set_attached_tooltip (PanelToplevel *toplevel,
445 const char *tooltip)
446{
447 GSettings *settings;
448 settings = panel_profile_get_attached_object_settings (toplevel);
449 g_settings_set_string (settings, PANEL_OBJECT_TOOLTIP_KEY"tooltip", tooltip);
450 g_object_unref (settings);
451}
452
453char *
454panel_profile_get_attached_tooltip (PanelToplevel *toplevel)
455{
456 gchar *tooltip = NULL((void*)0);
457 if (panel_toplevel_get_is_attached (toplevel))
458 {
459 GSettings *settings;
460 settings = panel_profile_get_attached_object_settings (toplevel);
461 tooltip = g_settings_get_string (settings, PANEL_OBJECT_TOOLTIP_KEY"tooltip");
462 g_object_unref (settings);
463 }
464 return tooltip;
465}
466
467gboolean
468panel_profile_is_writable_attached_tooltip (PanelToplevel *toplevel)
469{
470 gboolean is_writable = FALSE(0);
471 if (panel_toplevel_get_is_attached (toplevel))
472 {
473 GSettings *settings;
474 settings = panel_profile_get_attached_object_settings (toplevel);
475 is_writable = g_settings_is_writable (settings, PANEL_OBJECT_TOOLTIP_KEY"tooltip");
476 g_object_unref (settings);
477 }
478 return is_writable;
479}
480
481static char *
482get_background_image (PanelToplevel *toplevel,
483 gboolean *fit,
484 gboolean *stretch,
485 gboolean *rotate)
486{
487 char *image;
488 image = g_settings_get_string (toplevel->background_settings, "image");
489 *fit = g_settings_get_boolean (toplevel->background_settings, "fit");
490 *stretch = g_settings_get_boolean (toplevel->background_settings, "stretch");
491 *rotate = g_settings_get_boolean (toplevel->background_settings, "rotate");
492 return image;
493}
494
495static void
496panel_profile_load_background (PanelToplevel *toplevel)
497{
498 PanelWidget *panel_widget;
499 PanelBackground *background;
500 PanelBackgroundType background_type;
501 GdkRGBA color;
502 char *image;
503 gboolean fit;
504 gboolean stretch;
505 gboolean rotate;
506
507 panel_widget = panel_toplevel_get_panel_widget (toplevel);
508
509 background = &panel_widget->toplevel->background;
510 background_type = panel_profile_get_background_type (toplevel);
511
512 panel_profile_get_background_color (toplevel, &color);
513
514 image = get_background_image (toplevel, &fit, &stretch, &rotate);
515
516 panel_background_set (background,
517 background_type,
518 &color,
519 image,
520 fit,
521 stretch,
522 rotate);
523
524 g_free (image);
525}
526
527static gboolean
528panel_profile_commit_toplevel_changes (PanelToplevel *toplevel)
529{
530 if (g_settings_get_has_unapplied (toplevel->queued_settings))
531 g_settings_apply (toplevel->queued_settings);
532
533 panel_profile_set_commit_timeout (toplevel, 0);
534
535 return FALSE(0);
536}
537
538static void
539panel_profile_queue_toplevel_location_change (PanelToplevel *toplevel,
540 ToplevelLocationChange *change)
541{
542 guint commit_timeout;
543
544 g_settings_delay (toplevel->queued_settings);
545
546#ifdef HAVE_X111
547 if (change->screen_changed &&
548 GDK_IS_X11_SCREEN (change->screen)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(change->screen)); GType __t = ((gdk_x11_screen_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; }))))
) {
549 g_settings_set_int (toplevel->queued_settings,
550 "screen",
551 gdk_x11_screen_get_screen_number (change->screen));
552 }
553#endif
554
555 if (change->monitor_changed)
556 g_settings_set_int (toplevel->queued_settings,
557 "monitor",
558 change->monitor);
559
560 if (change->size_changed)
561 g_settings_set_int (toplevel->queued_settings,
562 "size",
563 change->size);
564
565 if (change->orientation_changed)
566 g_settings_set_enum (toplevel->queued_settings,
567 "orientation",
568 change->orientation);
569
570 if (change->x_changed)
571 g_settings_set_int (toplevel->queued_settings,
572 "x",
573 change->x);
574
575 if (change->x_right_changed)
576 g_settings_set_int (toplevel->queued_settings,
577 "x-right",
578 change->x_right);
579
580 if (change->x_centered_changed)
581 g_settings_set_boolean (toplevel->queued_settings,
582 "x-centered",
583 change->x_centered);
584
585 if (change->y_changed)
586 g_settings_set_int (toplevel->queued_settings,
587 "y",
588 change->y);
589
590 if (change->y_bottom_changed)
591 g_settings_set_int (toplevel->queued_settings,
592 "y-bottom",
593 change->y_bottom);
594
595 if (change->y_centered_changed)
596 g_settings_set_boolean (toplevel->queued_settings,
597 "y-centered",
598 change->y_centered);
599
600 commit_timeout = panel_profile_get_commit_timeout (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
);
601 if (!commit_timeout) {
602 commit_timeout =
603 g_timeout_add (500,
604 (GSourceFunc) panel_profile_commit_toplevel_changes,
605 toplevel);
606 panel_profile_set_commit_timeout (toplevel, commit_timeout);
607 }
608}
609
610#define TOPLEVEL_LOCATION_CHANGED_HANDLER(c)static void panel_profile_toplevel_c_changed (PanelToplevel *
toplevel) { ToplevelLocationChange change = { ((void*)0) }; change
.c_changed = (!(0)); change.c = panel_toplevel_get_c (toplevel
); panel_profile_queue_toplevel_location_change (toplevel, &
change); }
\
611 static void \
612 panel_profile_toplevel_##c##_changed (PanelToplevel *toplevel) \
613 { \
614 ToplevelLocationChange change = { NULL((void*)0) }; \
615 change.c##_changed = TRUE(!(0)); \
616 change.c = panel_toplevel_get_##c (toplevel); \
617 panel_profile_queue_toplevel_location_change (toplevel, &change); \
618 }
619
620TOPLEVEL_LOCATION_CHANGED_HANDLER(monitor)static void panel_profile_toplevel_monitor_changed (PanelToplevel
*toplevel) { ToplevelLocationChange change = { ((void*)0) };
change.monitor_changed = (!(0)); change.monitor = panel_toplevel_get_monitor
(toplevel); panel_profile_queue_toplevel_location_change (toplevel
, &change); }
621TOPLEVEL_LOCATION_CHANGED_HANDLER(size)static void panel_profile_toplevel_size_changed (PanelToplevel
*toplevel) { ToplevelLocationChange change = { ((void*)0) };
change.size_changed = (!(0)); change.size = panel_toplevel_get_size
(toplevel); panel_profile_queue_toplevel_location_change (toplevel
, &change); }
622TOPLEVEL_LOCATION_CHANGED_HANDLER(orientation)static void panel_profile_toplevel_orientation_changed (PanelToplevel
*toplevel) { ToplevelLocationChange change = { ((void*)0) };
change.orientation_changed = (!(0)); change.orientation = panel_toplevel_get_orientation
(toplevel); panel_profile_queue_toplevel_location_change (toplevel
, &change); }
623TOPLEVEL_LOCATION_CHANGED_HANDLER(x_centered)static void panel_profile_toplevel_x_centered_changed (PanelToplevel
*toplevel) { ToplevelLocationChange change = { ((void*)0) };
change.x_centered_changed = (!(0)); change.x_centered = panel_toplevel_get_x_centered
(toplevel); panel_profile_queue_toplevel_location_change (toplevel
, &change); }
624TOPLEVEL_LOCATION_CHANGED_HANDLER(y_centered)static void panel_profile_toplevel_y_centered_changed (PanelToplevel
*toplevel) { ToplevelLocationChange change = { ((void*)0) };
change.y_centered_changed = (!(0)); change.y_centered = panel_toplevel_get_y_centered
(toplevel); panel_profile_queue_toplevel_location_change (toplevel
, &change); }
625
626#define TOPLEVEL_POSITION_CHANGED_HANDLER(c)static void panel_profile_toplevel_c_changed (PanelToplevel *
toplevel) { ToplevelLocationChange change = { ((void*)0) }; int
x, y, x_right, y_bottom; change.c_changed = (!(0)); panel_toplevel_get_position
(toplevel, &x, &x_right, &y, &y_bottom); change
.c = c; panel_profile_queue_toplevel_location_change (toplevel
, &change); }
\
627 static void \
628 panel_profile_toplevel_##c##_changed (PanelToplevel *toplevel) \
629 { \
630 ToplevelLocationChange change = { NULL((void*)0) }; \
631 int x, y, x_right, y_bottom; \
632 change.c##_changed = TRUE(!(0)); \
633 panel_toplevel_get_position (toplevel, \
634 &x, &x_right, \
635 &y, &y_bottom); \
636 change.c = c; \
637 panel_profile_queue_toplevel_location_change (toplevel, &change); \
638 }
639
640TOPLEVEL_POSITION_CHANGED_HANDLER(x)static void panel_profile_toplevel_x_changed (PanelToplevel *
toplevel) { ToplevelLocationChange change = { ((void*)0) }; int
x, y, x_right, y_bottom; change.x_changed = (!(0)); panel_toplevel_get_position
(toplevel, &x, &x_right, &y, &y_bottom); change
.x = x; panel_profile_queue_toplevel_location_change (toplevel
, &change); }
641TOPLEVEL_POSITION_CHANGED_HANDLER(x_right)static void panel_profile_toplevel_x_right_changed (PanelToplevel
*toplevel) { ToplevelLocationChange change = { ((void*)0) };
int x, y, x_right, y_bottom; change.x_right_changed = (!(0))
; panel_toplevel_get_position (toplevel, &x, &x_right
, &y, &y_bottom); change.x_right = x_right; panel_profile_queue_toplevel_location_change
(toplevel, &change); }
642TOPLEVEL_POSITION_CHANGED_HANDLER(y)static void panel_profile_toplevel_y_changed (PanelToplevel *
toplevel) { ToplevelLocationChange change = { ((void*)0) }; int
x, y, x_right, y_bottom; change.y_changed = (!(0)); panel_toplevel_get_position
(toplevel, &x, &x_right, &y, &y_bottom); change
.y = y; panel_profile_queue_toplevel_location_change (toplevel
, &change); }
643TOPLEVEL_POSITION_CHANGED_HANDLER(y_bottom)static void panel_profile_toplevel_y_bottom_changed (PanelToplevel
*toplevel) { ToplevelLocationChange change = { ((void*)0) };
int x, y, x_right, y_bottom; change.y_bottom_changed = (!(0)
); panel_toplevel_get_position (toplevel, &x, &x_right
, &y, &y_bottom); change.y_bottom = y_bottom; panel_profile_queue_toplevel_location_change
(toplevel, &change); }
644
645static void
646panel_profile_toplevel_screen_changed (PanelToplevel *toplevel)
647{
648 ToplevelLocationChange change = { NULL((void*)0) };
649
650 change.screen_changed = TRUE(!(0));
651 change.screen = gtk_window_get_screen (GTK_WINDOW (toplevel)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_window_get_type ()))))))
);
652
653 panel_profile_queue_toplevel_location_change (toplevel, &change);
654}
655
656static void
657panel_profile_connect_to_toplevel (PanelToplevel *toplevel)
658{
659 g_signal_connect (toplevel, "notify::screen",g_signal_connect_data ((toplevel), ("notify::screen"), (((GCallback
) (panel_profile_toplevel_screen_changed))), (((void*)0)), ((
void*)0), (GConnectFlags) 0)
660 G_CALLBACK (panel_profile_toplevel_screen_changed), NULL)g_signal_connect_data ((toplevel), ("notify::screen"), (((GCallback
) (panel_profile_toplevel_screen_changed))), (((void*)0)), ((
void*)0), (GConnectFlags) 0)
;
661 g_signal_connect (toplevel, "notify::monitor",g_signal_connect_data ((toplevel), ("notify::monitor"), (((GCallback
) (panel_profile_toplevel_monitor_changed))), (((void*)0)), (
(void*)0), (GConnectFlags) 0)
662 G_CALLBACK (panel_profile_toplevel_monitor_changed), NULL)g_signal_connect_data ((toplevel), ("notify::monitor"), (((GCallback
) (panel_profile_toplevel_monitor_changed))), (((void*)0)), (
(void*)0), (GConnectFlags) 0)
;
663 g_signal_connect (toplevel, "notify::size",g_signal_connect_data ((toplevel), ("notify::size"), (((GCallback
) (panel_profile_toplevel_size_changed))), (((void*)0)), ((void
*)0), (GConnectFlags) 0)
664 G_CALLBACK (panel_profile_toplevel_size_changed), NULL)g_signal_connect_data ((toplevel), ("notify::size"), (((GCallback
) (panel_profile_toplevel_size_changed))), (((void*)0)), ((void
*)0), (GConnectFlags) 0)
;
665 g_signal_connect (toplevel, "notify::x",g_signal_connect_data ((toplevel), ("notify::x"), (((GCallback
) (panel_profile_toplevel_x_changed))), (((void*)0)), ((void*
)0), (GConnectFlags) 0)
666 G_CALLBACK (panel_profile_toplevel_x_changed), NULL)g_signal_connect_data ((toplevel), ("notify::x"), (((GCallback
) (panel_profile_toplevel_x_changed))), (((void*)0)), ((void*
)0), (GConnectFlags) 0)
;
667 g_signal_connect (toplevel, "notify::x-right",g_signal_connect_data ((toplevel), ("notify::x-right"), (((GCallback
) (panel_profile_toplevel_x_right_changed))), (((void*)0)), (
(void*)0), (GConnectFlags) 0)
668 G_CALLBACK (panel_profile_toplevel_x_right_changed), NULL)g_signal_connect_data ((toplevel), ("notify::x-right"), (((GCallback
) (panel_profile_toplevel_x_right_changed))), (((void*)0)), (
(void*)0), (GConnectFlags) 0)
;
669 g_signal_connect (toplevel, "notify::x-centered",g_signal_connect_data ((toplevel), ("notify::x-centered"), ((
(GCallback) (panel_profile_toplevel_x_centered_changed))), ((
(void*)0)), ((void*)0), (GConnectFlags) 0)
670 G_CALLBACK (panel_profile_toplevel_x_centered_changed), NULL)g_signal_connect_data ((toplevel), ("notify::x-centered"), ((
(GCallback) (panel_profile_toplevel_x_centered_changed))), ((
(void*)0)), ((void*)0), (GConnectFlags) 0)
;
671 g_signal_connect (toplevel, "notify::y",g_signal_connect_data ((toplevel), ("notify::y"), (((GCallback
) (panel_profile_toplevel_y_changed))), (((void*)0)), ((void*
)0), (GConnectFlags) 0)
672 G_CALLBACK (panel_profile_toplevel_y_changed), NULL)g_signal_connect_data ((toplevel), ("notify::y"), (((GCallback
) (panel_profile_toplevel_y_changed))), (((void*)0)), ((void*
)0), (GConnectFlags) 0)
;
673 g_signal_connect (toplevel, "notify::y-bottom",g_signal_connect_data ((toplevel), ("notify::y-bottom"), (((GCallback
) (panel_profile_toplevel_y_bottom_changed))), (((void*)0)), (
(void*)0), (GConnectFlags) 0)
674 G_CALLBACK (panel_profile_toplevel_y_bottom_changed), NULL)g_signal_connect_data ((toplevel), ("notify::y-bottom"), (((GCallback
) (panel_profile_toplevel_y_bottom_changed))), (((void*)0)), (
(void*)0), (GConnectFlags) 0)
;
675 g_signal_connect (toplevel, "notify::y-centered",g_signal_connect_data ((toplevel), ("notify::y-centered"), ((
(GCallback) (panel_profile_toplevel_y_centered_changed))), ((
(void*)0)), ((void*)0), (GConnectFlags) 0)
676 G_CALLBACK (panel_profile_toplevel_y_centered_changed), NULL)g_signal_connect_data ((toplevel), ("notify::y-centered"), ((
(GCallback) (panel_profile_toplevel_y_centered_changed))), ((
(void*)0)), ((void*)0), (GConnectFlags) 0)
;
677 g_signal_connect (toplevel, "notify::orientation",g_signal_connect_data ((toplevel), ("notify::orientation"), (
((GCallback) (panel_profile_toplevel_orientation_changed))), (
((void*)0)), ((void*)0), (GConnectFlags) 0)
678 G_CALLBACK (panel_profile_toplevel_orientation_changed), NULL)g_signal_connect_data ((toplevel), ("notify::orientation"), (
((GCallback) (panel_profile_toplevel_orientation_changed))), (
((void*)0)), ((void*)0), (GConnectFlags) 0)
;
679}
680
681static void
682panel_profile_toplevel_change_notify (GSettings *settings,
683 gchar *key,
684 PanelToplevel *toplevel)
685{
686 if (toplevel == NULL((void*)0) || !PANEL_IS_TOPLEVEL (toplevel)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(toplevel)); GType __t = ((panel_toplevel_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; }))))
)
687 return;
688
689#define UPDATE_STRING(k, n)if (!strcmp (key, k)) { gchar *value = g_settings_get_string (
settings, key); panel_toplevel_set_n (toplevel, value); g_free
(value); }
\
690 if (!strcmp (key, k)) { \
691 gchar *value = g_settings_get_string (settings, key); \
692 panel_toplevel_set_##n (toplevel, value); \
693 g_free (value); \
694 }
695
696#define UPDATE_ENUM(k, n)if (!strcmp (key, k)) { panel_toplevel_set_n (toplevel, g_settings_get_enum
(settings, key)); }
\
697 if (!strcmp (key, k)) { \
698 panel_toplevel_set_##n (toplevel, \
699 g_settings_get_enum (settings, key)); \
700 }
701
702#define UPDATE_INT(k, n)if (!strcmp (key, k)) { panel_toplevel_set_n (toplevel, g_settings_get_int
(settings, key)); }
\
703 if (!strcmp (key, k)) { \
704 panel_toplevel_set_##n (toplevel, \
705 g_settings_get_int (settings, key)); \
706 }
707
708#define UPDATE_BOOL(k, n)if (!strcmp (key, k)) { panel_toplevel_set_n (toplevel, g_settings_get_boolean
(settings, key)); }
\
709 if (!strcmp (key, k)) { \
710 panel_toplevel_set_##n (toplevel, \
711 g_settings_get_boolean (settings, key)); \
712 }
713
714#define UPDATE_POS(k, n, n2)if (!strcmp (key, k)) { int x, x_right, y, y_bottom; panel_toplevel_get_position
(toplevel, &x, &x_right, &y, &y_bottom); panel_toplevel_set_n
( toplevel, g_settings_get_int (settings, key), n2, panel_toplevel_get_n_centered
(toplevel)); }
\
715 if (!strcmp (key, k)) { \
716 int x, x_right, y, y_bottom; \
717 panel_toplevel_get_position (toplevel, &x, &x_right, \
718 &y, &y_bottom); \
719 panel_toplevel_set_##n ( \
720 toplevel, \
721 g_settings_get_int (settings, key), \
722 n2, \
723 panel_toplevel_get_##n##_centered (toplevel)); \
724 }
725
726#define UPDATE_POS2(k, n, n2)if (!strcmp (key, k)) { int x, x_right, y, y_bottom; panel_toplevel_get_position
(toplevel, &x, &x_right, &y, &y_bottom); panel_toplevel_set_n
( toplevel, n, g_settings_get_int (settings, key), panel_toplevel_get_n_centered
(toplevel)); }
\
727 if (!strcmp (key, k)) { \
728 int x, x_right, y, y_bottom; \
729 panel_toplevel_get_position (toplevel, &x, &x_right, \
730 &y, &y_bottom); \
731 panel_toplevel_set_##n ( \
732 toplevel, \
733 n, \
734 g_settings_get_int (settings, key), \
735 panel_toplevel_get_##n##_centered (toplevel)); \
736 }
737
738#define UPDATE_CENTERED(k, n, n2)if (!strcmp (key, k)) { int x, x_right, y, y_bottom; panel_toplevel_get_position
(toplevel, &x, &x_right, &y, &y_bottom); panel_toplevel_set_n
( toplevel, n, n2, g_settings_get_boolean (settings, key)); }
\
739 if (!strcmp (key, k)) { \
740 int x, x_right, y, y_bottom; \
741 panel_toplevel_get_position (toplevel, &x, &x_right, \
742 &y, &y_bottom); \
743 panel_toplevel_set_##n ( \
744 toplevel, n, n2, \
745 g_settings_get_boolean (settings, key)); \
746 }
747
748 if (!strcmp (key, "screen")) {
749 GdkScreen *screen;
750 screen = gdk_display_get_default_screen (gdk_display_get_default ());
751
752 if (screen)
753 gtk_window_set_screen (GTK_WINDOW (toplevel)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_window_get_type ()))))))
, screen);
754 else
755 /* Make sure to set the key back to an actual
756 * available screen so it will get loaded on
757 * next startup.
758 */
759 panel_profile_toplevel_screen_changed (toplevel);
760 }
761 else UPDATE_INT ("monitor", monitor)if (!strcmp (key, "monitor")) { panel_toplevel_set_monitor (toplevel
, g_settings_get_int (settings, key)); }
762 else UPDATE_STRING ("name", name)if (!strcmp (key, "name")) { gchar *value = g_settings_get_string
(settings, key); panel_toplevel_set_name (toplevel, value); g_free
(value); }
763 else UPDATE_BOOL ("expand", expand)if (!strcmp (key, "expand")) { panel_toplevel_set_expand (toplevel
, g_settings_get_boolean (settings, key)); }
764 else UPDATE_ENUM ("orientation", orientation)if (!strcmp (key, "orientation")) { panel_toplevel_set_orientation
(toplevel, g_settings_get_enum (settings, key)); }
765 else UPDATE_INT ("size", size)if (!strcmp (key, "size")) { panel_toplevel_set_size (toplevel
, g_settings_get_int (settings, key)); }
766 else UPDATE_POS ("x", x, x_right)if (!strcmp (key, "x")) { int x, x_right, y, y_bottom; panel_toplevel_get_position
(toplevel, &x, &x_right, &y, &y_bottom); panel_toplevel_set_x
( toplevel, g_settings_get_int (settings, key), x_right, panel_toplevel_get_x_centered
(toplevel)); }
767 else UPDATE_POS ("y", y, y_bottom)if (!strcmp (key, "y")) { int x, x_right, y, y_bottom; panel_toplevel_get_position
(toplevel, &x, &x_right, &y, &y_bottom); panel_toplevel_set_y
( toplevel, g_settings_get_int (settings, key), y_bottom, panel_toplevel_get_y_centered
(toplevel)); }
768 else UPDATE_POS2 ("x-right", x, x_right)if (!strcmp (key, "x-right")) { int x, x_right, y, y_bottom; panel_toplevel_get_position
(toplevel, &x, &x_right, &y, &y_bottom); panel_toplevel_set_x
( toplevel, x, g_settings_get_int (settings, key), panel_toplevel_get_x_centered
(toplevel)); }
769 else UPDATE_POS2 ("y-bottom", y, y_bottom)if (!strcmp (key, "y-bottom")) { int x, x_right, y, y_bottom;
panel_toplevel_get_position (toplevel, &x, &x_right,
&y, &y_bottom); panel_toplevel_set_y ( toplevel, y, g_settings_get_int
(settings, key), panel_toplevel_get_y_centered (toplevel)); }
770 else UPDATE_CENTERED ("x-centered", x, x_right)if (!strcmp (key, "x-centered")) { int x, x_right, y, y_bottom
; panel_toplevel_get_position (toplevel, &x, &x_right
, &y, &y_bottom); panel_toplevel_set_x ( toplevel, x,
x_right, g_settings_get_boolean (settings, key)); }
771 else UPDATE_CENTERED ("y-centered", y, y_bottom)if (!strcmp (key, "y-centered")) { int x, x_right, y, y_bottom
; panel_toplevel_get_position (toplevel, &x, &x_right
, &y, &y_bottom); panel_toplevel_set_y ( toplevel, y,
y_bottom, g_settings_get_boolean (settings, key)); }
772 else UPDATE_BOOL ("auto-hide", auto_hide)if (!strcmp (key, "auto-hide")) { panel_toplevel_set_auto_hide
(toplevel, g_settings_get_boolean (settings, key)); }
773 else UPDATE_BOOL ("enable-animations", animate)if (!strcmp (key, "enable-animations")) { panel_toplevel_set_animate
(toplevel, g_settings_get_boolean (settings, key)); }
774 else UPDATE_BOOL ("enable-buttons", enable_buttons)if (!strcmp (key, "enable-buttons")) { panel_toplevel_set_enable_buttons
(toplevel, g_settings_get_boolean (settings, key)); }
775 else UPDATE_BOOL ("enable-arrows", enable_arrows)if (!strcmp (key, "enable-arrows")) { panel_toplevel_set_enable_arrows
(toplevel, g_settings_get_boolean (settings, key)); }
776 else UPDATE_INT ("hide-delay", hide_delay)if (!strcmp (key, "hide-delay")) { panel_toplevel_set_hide_delay
(toplevel, g_settings_get_int (settings, key)); }
777 else UPDATE_INT ("unhide-delay", unhide_delay)if (!strcmp (key, "unhide-delay")) { panel_toplevel_set_unhide_delay
(toplevel, g_settings_get_int (settings, key)); }
778 else UPDATE_INT ("auto-hide-size", auto_hide_size)if (!strcmp (key, "auto-hide-size")) { panel_toplevel_set_auto_hide_size
(toplevel, g_settings_get_int (settings, key)); }
779 else UPDATE_ENUM ("animation-speed", animation_speed)if (!strcmp (key, "animation-speed")) { panel_toplevel_set_animation_speed
(toplevel, g_settings_get_enum (settings, key)); }
780}
781
782static void
783panel_profile_background_change_notify (GSettings *settings,
784 gchar *key,
785 PanelToplevel *toplevel)
786{
787 PanelWidget *panel_widget;
788 PanelBackground *background;
789
790 if (toplevel == NULL((void*)0) || !PANEL_IS_TOPLEVEL (toplevel)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(toplevel)); GType __t = ((panel_toplevel_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; }))))
)
791 return;
792
793 panel_widget = panel_toplevel_get_panel_widget (toplevel);
794 if (panel_widget == NULL((void*)0))
795 return;
796
797 background = &panel_widget->toplevel->background;
798
799 if (!strcmp (key, "type")) {
800 PanelBackgroundType background_type;
801 background_type = g_settings_get_enum (settings, key);
802 panel_background_set_type (background, background_type);
803 panel_toplevel_update_edges (toplevel);
804 } else if (!strcmp (key, "color")) {
805 GdkRGBA color;
806 gchar *str;
807 str = g_settings_get_string (settings, key);
808 if (gdk_rgba_parse (&color, str))
809 panel_background_set_color (background, &color);
810 g_free (str);
811 } else if (!strcmp (key, "image")) {
812 gchar *value = g_settings_get_string (settings, key);
813 panel_background_set_image (background, value);
814 g_free (value);
815 } else if (!strcmp (key, "fit")) {
816 panel_background_set_fit (background,
817 g_settings_get_boolean (settings, key));
818 } else if (!strcmp (key, "stretch")) {
819 panel_background_set_stretch (background,
820 g_settings_get_boolean (settings, key));
821 } else if (!strcmp (key, "rotate")) {
822 panel_background_set_rotate (background,
823 g_settings_get_boolean (settings, key));
824 }
825}
826
827static const char *
828key_from_type (PanelGSettingsKeyType type) {
829 if (type == PANEL_GSETTINGS_TOPLEVELS)
830 return PANEL_TOPLEVEL_ID_LIST_KEY"toplevel-id-list";
831 else if (type == PANEL_GSETTINGS_OBJECTS)
832 return PANEL_OBJECT_ID_LIST_KEY"object-id-list";
833
834 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-profile.c"
, 834, ((const char*) (__func__)), ((void*)0)); } while (0)
;
835 return NULL((void*)0);
836}
837
838static GVariant *
839remove_from_dict (GVariant *dict, const gchar *path)
840{
841 GVariantIter iter;
842 GVariantBuilder builder;
843
844 gchar *key;
845 gchar *value;
846
847 g_variant_builder_init (&builder, (const GVariantType *) "a{ss}");
Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption
848 g_variant_iter_init (&iter, dict);
849
850 while (g_variant_iter_next (&iter, "{ss}", &key, &value)) {
851 if ( g_strcmp0 (value, path) != 0) {
852 g_variant_builder_add (&builder, "{ss}", key, value);
853 }
854
855 g_free (key);
856 g_free (value);
857 }
858
859 return g_variant_ref_sink (g_variant_builder_end (&builder));
860}
861
862static void
863unregister_dconf_editor_relocatable_schema (const gchar *path)
864{
865 GSettings *dconf_editor_settings;
866 dconf_editor_settings = g_settings_new ("ca.desrt.dconf-editor.Settings");
867
868 if (dconf_editor_settings && g_settings_is_writable (dconf_editor_settings, "relocatable-schemas-user-paths")) {
869 GVariant *relocatable_schemas = g_settings_get_value (dconf_editor_settings, "relocatable-schemas-user-paths");
870
871 if (g_variant_is_of_type (relocatable_schemas, G_VARIANT_TYPE_DICTIONARY((const GVariantType *) "a{?*}"))) {
872 GVariant * new_relocatable_schemas = remove_from_dict (relocatable_schemas, path);
873 g_settings_set_value (dconf_editor_settings, "relocatable-schemas-user-paths", new_relocatable_schemas);
874 g_variant_unref (new_relocatable_schemas);
875 }
876
877 g_variant_unref (relocatable_schemas);
878 }
879
880 g_object_unref (dconf_editor_settings);
881}
882
883
884void
885panel_profile_add_to_list (PanelGSettingsKeyType type,
886 const char *id)
887{
888 char *new_id = id ? g_strdup (id)g_strdup_inline (id) : panel_profile_find_new_id (type);
889
890 if (new_id != NULL((void*)0)) {
891 mate_gsettings_append_strv (profile_settings,
892 key_from_type (type),
893 new_id);
894 g_free (new_id);
895 }
896}
897
898void
899panel_profile_remove_from_list (PanelGSettingsKeyType type,
900 const char *id)
901{
902 mate_gsettings_remove_all_from_strv (profile_settings,
903 key_from_type (type),
904 id);
905}
906
907static gboolean
908panel_profile_id_list_is_writable (PanelGSettingsKeyType type)
909{
910 return g_settings_is_writable (profile_settings, key_from_type (type));
911}
912
913gboolean
914panel_profile_id_lists_are_writable (void)
915{
916 return
917 panel_profile_id_list_is_writable (PANEL_GSETTINGS_TOPLEVELS) &&
918 panel_profile_id_list_is_writable (PANEL_GSETTINGS_OBJECTS);
919}
920
921static gboolean
922panel_profile_find_empty_spot (GdkScreen *screen,
923 PanelOrientation *orientation,
924 int *monitor)
925{
926 GSList *li;
927 int i;
928 int *filled_spots;
929 gboolean found_a_spot = FALSE(0);
930
931 *monitor = 0;
932 *orientation = PANEL_ORIENTATION_TOP;
933
934 filled_spots = g_new0 (int, panel_multimonitor_monitors ())((int *) g_malloc0_n ((panel_multimonitor_monitors ()), sizeof
(int)))
;
935
936 for (li = panel_toplevel_list_toplevels (); li != NULL((void*)0); li = li->next) {
937 PanelToplevel *toplevel = li->data;
938 GdkScreen *toplevel_screen = gtk_window_get_screen (GTK_WINDOW (toplevel)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_window_get_type ()))))))
);
939 int toplevel_monitor = panel_toplevel_get_monitor (toplevel);
940
941 if (toplevel_screen != screen ||
942 panel_toplevel_get_is_attached (toplevel) ||
943 toplevel_monitor < 0)
944 continue;
945
946 filled_spots[toplevel_monitor] |= panel_toplevel_get_orientation (toplevel);
947 }
948
949 for (i = 0; i < panel_multimonitor_monitors (); i++) {
950 /* These are ordered based on "priority" of the
951 orientation when picking it */
952 if ( ! (filled_spots[i] & PANEL_ORIENTATION_TOP)) {
953 *orientation = PANEL_ORIENTATION_TOP;
954 *monitor = i;
955 found_a_spot = TRUE(!(0));
956 break;
957 } else if ( ! (filled_spots[i] & PANEL_ORIENTATION_BOTTOM)) {
958 *orientation = PANEL_ORIENTATION_BOTTOM;
959 *monitor = i;
960 found_a_spot = TRUE(!(0));
961 break;
962 } else if ( ! (filled_spots[i] & PANEL_ORIENTATION_RIGHT)) {
963 *orientation = PANEL_ORIENTATION_RIGHT;
964 *monitor = i;
965 found_a_spot = TRUE(!(0));
966 break;
967 } else if ( ! (filled_spots[i] & PANEL_ORIENTATION_LEFT)) {
968 *orientation = PANEL_ORIENTATION_LEFT;
969 *monitor = i;
970 found_a_spot = TRUE(!(0));
971 break;
972 }
973 }
974
975 g_free (filled_spots);
976
977 return found_a_spot;
978}
979
980void
981panel_profile_create_toplevel (GdkScreen *screen)
982{
983 char *id;
984 char *path;
985 PanelOrientation orientation;
986 int monitor;
987 GSettings *settings;
988 int screen_number;
989
990 g_return_if_fail (screen != NULL)do { if ((screen != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "screen != NULL")
; return; } } while (0)
;
991
992 id = panel_profile_find_new_id (PANEL_GSETTINGS_TOPLEVELS);
993
994 path = g_strdup_printf (PANEL_TOPLEVEL_PATH"/org/mate/panel/toplevels/" "%s/", id);
995
996 settings = g_settings_new_with_path (PANEL_TOPLEVEL_SCHEMA"org.mate.panel.toplevel", path);
997 g_free (path);
998
999 screen_number = 0;
1000#ifdef HAVE_X111
1001 if (GDK_IS_X11_SCREEN (screen)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(screen)); GType __t = ((gdk_x11_screen_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; }))))
) {
1002 screen_number = gdk_x11_screen_get_screen_number (screen);
1003 }
1004#endif /* HAVE_X11 */
1005
1006 g_settings_set_int (settings, PANEL_TOPLEVEL_SCREEN_KEY"screen", screen_number);
1007
1008 if (panel_profile_find_empty_spot (screen, &orientation, &monitor)) {
1009 g_settings_set_int (settings, PANEL_TOPLEVEL_MONITOR_KEY"monitor", monitor);
1010 g_settings_set_enum (settings, PANEL_TOPLEVEL_ORIENTATION_KEY"orientation", orientation);
1011 }
1012
1013 panel_profile_add_to_list (PANEL_GSETTINGS_TOPLEVELS, id);
1014
1015 g_object_unref (settings);
1016 g_free (id);
1017}
1018
1019static void
1020panel_profile_delete_toplevel_objects (const char *toplevel_id)
1021{
1022 gchar **list;
1023 GArray *newlist;
1024 int i;
1025
1026 list = g_settings_get_strv (profile_settings, PANEL_OBJECT_ID_LIST_KEY"object-id-list");
1027 newlist = g_array_new (TRUE(!(0)), TRUE(!(0)), sizeof (gchar *));
1028
1029 for (i = 0; list[i]; i++) {
1030 char *path;
1031 char *parent_toplevel_id;
1032 GSettings *settings;
1033
1034 path = g_strdup_printf (PANEL_OBJECT_PATH"/org/mate/panel/objects/" "%s/", list[i]);
1035 settings = g_settings_new_with_path (PANEL_OBJECT_SCHEMA"org.mate.panel.object", path);
1036 parent_toplevel_id = g_settings_get_string (settings, PANEL_OBJECT_TOPLEVEL_ID_KEY"toplevel-id");
1037 g_free (path);
1038 g_object_unref (settings);
1039
1040 if (parent_toplevel_id && !strcmp (toplevel_id, parent_toplevel_id)) {
1041 g_free (parent_toplevel_id);
1042 continue;
1043 }
1044
1045 newlist = g_array_append_val (newlist, list[i])g_array_append_vals (newlist, &(list[i]), 1);
1046
1047 g_free (parent_toplevel_id);
1048 }
1049
1050 g_settings_set_strv (profile_settings, PANEL_OBJECT_ID_LIST_KEY"object-id-list", (const gchar **) newlist->data);
1051 g_array_free (newlist, TRUE(!(0)));
1052 g_strfreev (list);
1053}
1054
1055void
1056panel_profile_delete_toplevel (PanelToplevel *toplevel)
1057{
1058 const char *toplevel_id;
1059
1060 toplevel_id = panel_profile_get_toplevel_id (toplevel);
1061
1062 panel_profile_delete_toplevel_objects (toplevel_id);
1063
1064 panel_profile_remove_from_list (PANEL_GSETTINGS_TOPLEVELS, toplevel_id);
1065}
1066
1067PanelToplevel *
1068panel_profile_load_toplevel (const char *toplevel_id)
1069{
1070 PanelToplevel *toplevel;
1071 GdkScreen *screen;
1072 char *toplevel_path;
1073 char *toplevel_background_path;
1074
1075 if (!toplevel_id || !toplevel_id [0])
1076 return NULL((void*)0);
1077
1078 toplevel_path = g_strdup_printf ("%s%s/", PANEL_TOPLEVEL_PATH"/org/mate/panel/toplevels/", toplevel_id);
1079
1080 screen = gdk_display_get_default_screen (gdk_display_get_default ());
1081
1082 if (screen == NULL((void*)0)) {
1083 g_free (toplevel_path);
1084 return NULL((void*)0);
1085 }
1086
1087 toplevel = g_object_new (PANEL_TYPE_TOPLEVEL(panel_toplevel_get_type ()),
1088 "screen", screen,
1089 NULL((void*)0));
1090
1091 panel_toplevel_set_settings_path (toplevel, toplevel_path);
1092 toplevel->settings = g_settings_new_with_path (PANEL_TOPLEVEL_SCHEMA"org.mate.panel.toplevel", toplevel_path);
1093 toplevel->queued_settings = g_settings_new_with_path (PANEL_TOPLEVEL_SCHEMA"org.mate.panel.toplevel", toplevel_path);
1094
1095 toplevel_background_path = g_strdup_printf ("%sbackground/", toplevel_path);
1096 toplevel->background_settings = g_settings_new_with_path (PANEL_TOPLEVEL_BACKGROUND_SCHEMA"org.mate.panel.toplevel.background", toplevel_background_path);
1097
1098#define GET_INT(k, fn){ int val; val = g_settings_get_int (toplevel->settings, k
); panel_toplevel_set_fn (toplevel, val); }
\
1099 { \
1100 int val; \
1101 val = g_settings_get_int (toplevel->settings, k); \
1102 panel_toplevel_set_##fn (toplevel, val); \
1103 }
1104
1105#define GET_BOOL(k, fn){ gboolean val; val = g_settings_get_boolean (toplevel->settings
, k); panel_toplevel_set_fn (toplevel, val); }
\
1106 { \
1107 gboolean val; \
1108 val = g_settings_get_boolean (toplevel->settings, k); \
1109 panel_toplevel_set_##fn (toplevel, val); \
1110 }
1111
1112#define GET_STRING(k, fn){ char *val; val = g_settings_get_string (toplevel->settings
, k); panel_toplevel_set_fn (toplevel, val); g_free (val); }
\
1113 { \
1114 char *val; \
1115 val = g_settings_get_string (toplevel->settings, k); \
1116 panel_toplevel_set_##fn (toplevel, val); \
1117 g_free (val); \
1118 }
1119
1120#define GET_ENUM(k, fn){ int val; val = g_settings_get_enum (toplevel->settings, k
); panel_toplevel_set_fn (toplevel, val); }
\
1121 { \
1122 int val; \
1123 val = g_settings_get_enum (toplevel->settings, k); \
1124 panel_toplevel_set_##fn (toplevel, val); \
1125 }
1126
1127 GET_STRING ("name", name){ char *val; val = g_settings_get_string (toplevel->settings
, "name"); panel_toplevel_set_name (toplevel, val); g_free (val
); }
;
1128 GET_INT ("monitor", monitor){ int val; val = g_settings_get_int (toplevel->settings, "monitor"
); panel_toplevel_set_monitor (toplevel, val); }
;
1129 GET_BOOL ("expand", expand){ gboolean val; val = g_settings_get_boolean (toplevel->settings
, "expand"); panel_toplevel_set_expand (toplevel, val); }
;
1130 GET_ENUM ("orientation", orientation){ int val; val = g_settings_get_enum (toplevel->settings, "orientation"
); panel_toplevel_set_orientation (toplevel, val); }
;
1131 GET_INT ("size", size){ int val; val = g_settings_get_int (toplevel->settings, "size"
); panel_toplevel_set_size (toplevel, val); }
;
1132 GET_BOOL ("auto-hide", auto_hide){ gboolean val; val = g_settings_get_boolean (toplevel->settings
, "auto-hide"); panel_toplevel_set_auto_hide (toplevel, val);
}
;
1133 GET_BOOL ("enable-animations", animate){ gboolean val; val = g_settings_get_boolean (toplevel->settings
, "enable-animations"); panel_toplevel_set_animate (toplevel,
val); }
;
1134 GET_BOOL ("enable-buttons", enable_buttons){ gboolean val; val = g_settings_get_boolean (toplevel->settings
, "enable-buttons"); panel_toplevel_set_enable_buttons (toplevel
, val); }
;
1135 GET_BOOL ("enable-arrows", enable_arrows){ gboolean val; val = g_settings_get_boolean (toplevel->settings
, "enable-arrows"); panel_toplevel_set_enable_arrows (toplevel
, val); }
;
1136 GET_INT ("hide-delay", hide_delay){ int val; val = g_settings_get_int (toplevel->settings, "hide-delay"
); panel_toplevel_set_hide_delay (toplevel, val); }
;
1137 GET_INT ("unhide-delay", unhide_delay){ int val; val = g_settings_get_int (toplevel->settings, "unhide-delay"
); panel_toplevel_set_unhide_delay (toplevel, val); }
;
1138 GET_INT ("auto-hide-size", auto_hide_size){ int val; val = g_settings_get_int (toplevel->settings, "auto-hide-size"
); panel_toplevel_set_auto_hide_size (toplevel, val); }
;
1139 GET_ENUM ("animation-speed", animation_speed){ int val; val = g_settings_get_enum (toplevel->settings, "animation-speed"
); panel_toplevel_set_animation_speed (toplevel, val); }
;
1140
1141#define GET_POSITION(a, b, c, fn){ gboolean centered; int position; int position2; centered = g_settings_get_boolean
(toplevel->settings, c); position = g_settings_get_int (toplevel
->settings, a); position2 = g_settings_get_int (toplevel->
settings, b); panel_toplevel_set_fn (toplevel, position, position2
, centered); }
\
1142 { \
1143 gboolean centered; \
1144 int position; \
1145 int position2; \
1146 centered = g_settings_get_boolean (toplevel->settings, c); \
1147 position = g_settings_get_int (toplevel->settings, a); \
1148 position2 = g_settings_get_int (toplevel->settings, b); \
1149 panel_toplevel_set_##fn (toplevel, position, position2, centered); \
1150 }
1151
1152 GET_POSITION ("x", "x-right", "x-centered", x){ gboolean centered; int position; int position2; centered = g_settings_get_boolean
(toplevel->settings, "x-centered"); position = g_settings_get_int
(toplevel->settings, "x"); position2 = g_settings_get_int
(toplevel->settings, "x-right"); panel_toplevel_set_x (toplevel
, position, position2, centered); }
;
1153 GET_POSITION ("y", "y-bottom", "y-centered", y){ gboolean centered; int position; int position2; centered = g_settings_get_boolean
(toplevel->settings, "y-centered"); position = g_settings_get_int
(toplevel->settings, "y"); position2 = g_settings_get_int
(toplevel->settings, "y-bottom"); panel_toplevel_set_y (toplevel
, position, position2, centered); }
;
1154
1155 panel_profile_load_background (toplevel);
1156
1157 panel_profile_set_toplevel_id (toplevel, toplevel_id);
1158
1159 panel_profile_connect_to_toplevel (toplevel);
1160
1161 g_signal_connect (toplevel->settings,g_signal_connect_data ((toplevel->settings), ("changed"), (
((GCallback) (panel_profile_toplevel_change_notify))), (toplevel
), ((void*)0), (GConnectFlags) 0)
1162 "changed",g_signal_connect_data ((toplevel->settings), ("changed"), (
((GCallback) (panel_profile_toplevel_change_notify))), (toplevel
), ((void*)0), (GConnectFlags) 0)
1163 G_CALLBACK (panel_profile_toplevel_change_notify),g_signal_connect_data ((toplevel->settings), ("changed"), (
((GCallback) (panel_profile_toplevel_change_notify))), (toplevel
), ((void*)0), (GConnectFlags) 0)
1164 toplevel)g_signal_connect_data ((toplevel->settings), ("changed"), (
((GCallback) (panel_profile_toplevel_change_notify))), (toplevel
), ((void*)0), (GConnectFlags) 0)
;
1165 g_signal_connect (toplevel->background_settings,g_signal_connect_data ((toplevel->background_settings), ("changed"
), (((GCallback) (panel_profile_background_change_notify))), (
toplevel), ((void*)0), (GConnectFlags) 0)
1166 "changed",g_signal_connect_data ((toplevel->background_settings), ("changed"
), (((GCallback) (panel_profile_background_change_notify))), (
toplevel), ((void*)0), (GConnectFlags) 0)
1167 G_CALLBACK (panel_profile_background_change_notify),g_signal_connect_data ((toplevel->background_settings), ("changed"
), (((GCallback) (panel_profile_background_change_notify))), (
toplevel), ((void*)0), (GConnectFlags) 0)
1168 toplevel)g_signal_connect_data ((toplevel->background_settings), ("changed"
), (((GCallback) (panel_profile_background_change_notify))), (
toplevel), ((void*)0), (GConnectFlags) 0)
;
1169
1170 g_free (toplevel_path);
1171 g_free (toplevel_background_path);
1172
1173 panel_setup (toplevel);
1174
1175 return toplevel;
1176}
1177
1178static void
1179panel_profile_load_and_show_toplevel (char *toplevel_id)
1180{
1181 PanelToplevel *toplevel;
1182 gchar **objects;
1183 gboolean loading_queued_applets;
1184
1185 toplevel = panel_profile_load_toplevel (toplevel_id);
1186 if (!toplevel)
1187 return;
1188
1189 gtk_widget_show (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
1190
1191 loading_queued_applets = FALSE(0);
1192
1193 /* reload list of objects to get those that might be on the new
1194 * toplevel */
1195 GSettings *panel_settings;
1196 panel_settings = g_settings_new (PANEL_SCHEMA"org.mate.panel");
1197 objects = g_settings_get_strv (panel_settings, PANEL_OBJECT_ID_LIST_KEY"object-id-list");
1198
1199 if (objects) {
1200 panel_profile_object_id_list_update (objects);
1201 loading_queued_applets = TRUE(!(0));
1202 }
1203
1204 if (!loading_queued_applets)
1205 mate_panel_applet_load_queued_applets (FALSE(0));
1206
1207 g_strfreev (objects);
1208 g_object_unref (panel_settings);
1209}
1210
1211static void
1212panel_profile_load_and_show_toplevel_startup (const char *toplevel_id)
1213{
1214 PanelToplevel *toplevel;
1215 toplevel = panel_profile_load_toplevel (toplevel_id);
1216 if (toplevel)
1217 gtk_widget_show (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
1218}
1219
1220static void
1221panel_profile_destroy_toplevel (const char *id)
1222{
1223 PanelToplevel *toplevel;
1224
1225 if (!(toplevel = panel_profile_get_toplevel_by_id (id)))
1226 return;
1227
1228 gtk_widget_destroy (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
1229}
1230
1231char *
1232panel_profile_prepare_object_with_id (PanelObjectType object_type,
1233 const char *toplevel_id,
1234 int position,
1235 gboolean right_stick)
1236{
1237 PanelGSettingsKeyType key_type;
1238 char *id;
1239 char *settings_path;
1240 GSettings *settings;
1241
1242 key_type = PANEL_GSETTINGS_OBJECTS;
1243 id = panel_profile_find_new_id (key_type);
1244
1245 settings_path = g_strdup_printf (PANEL_OBJECT_PATH"/org/mate/panel/objects/" "%s/", id);
1246
1247 settings = g_settings_new_with_path (PANEL_OBJECT_SCHEMA"org.mate.panel.object", settings_path);
1248
1249 g_settings_set_enum (settings, PANEL_OBJECT_TYPE_KEY"object-type", object_type);
1250 g_settings_set_string (settings, PANEL_OBJECT_TOPLEVEL_ID_KEY"toplevel-id", toplevel_id);
1251 g_settings_set_int (settings, PANEL_OBJECT_POSITION_KEY"position", position);
1252 g_settings_set_boolean (settings, PANEL_OBJECT_PANEL_RIGHT_STICK_KEY"panel-right-stick", right_stick);
1253
1254 /* Force writing the settings in order to reserve the object ID *now*,
1255 * so that a later call to panel_profile_find_new_id() won't find the same
1256 * one. */
1257 g_settings_sync ();
1258
1259 g_free (settings_path);
1260 g_object_unref (settings);
1261
1262 return id;
1263}
1264
1265char *
1266panel_profile_prepare_object (PanelObjectType object_type,
1267 PanelToplevel *toplevel,
1268 int position,
1269 gboolean right_stick)
1270{
1271 return panel_profile_prepare_object_with_id (object_type,
1272 panel_profile_get_toplevel_id (toplevel),
1273 position,
1274 right_stick);
1275}
1276
1277void
1278panel_profile_delete_object (AppletInfo *applet_info)
1279{
1280 PanelGSettingsKeyType type;
1281 const char *id;
1282
1283 type = PANEL_GSETTINGS_OBJECTS;
1284 id = mate_panel_applet_get_id (applet_info);
1285
1286 panel_profile_remove_from_list (type, id);
1287}
1288
1289static void
1290panel_profile_load_object (char *id)
1291{
1292 PanelObjectType object_type;
1293 char *object_path;
1294 char *toplevel_id;
1295 int position;
1296 gboolean right_stick;
1297 gboolean locked;
1298 GSettings *settings;
1299
1300 object_path = g_strdup_printf (PANEL_OBJECT_PATH"/org/mate/panel/objects/" "%s/", id);
1301 settings = g_settings_new_with_path (PANEL_OBJECT_SCHEMA"org.mate.panel.object", object_path);
1302
1303 object_type = g_settings_get_enum (settings, PANEL_OBJECT_TYPE_KEY"object-type");
1304 position = g_settings_get_int (settings, PANEL_OBJECT_POSITION_KEY"position");
1305 toplevel_id = g_settings_get_string (settings, PANEL_OBJECT_TOPLEVEL_ID_KEY"toplevel-id");
1306 right_stick = g_settings_get_boolean (settings, PANEL_OBJECT_PANEL_RIGHT_STICK_KEY"panel-right-stick");
1307 locked = g_settings_get_boolean (settings, PANEL_OBJECT_LOCKED_KEY"locked");
1308
1309 mate_panel_applet_queue_applet_to_load (id,
1310 object_type,
1311 toplevel_id,
1312 position,
1313 right_stick,
1314 locked);
1315
1316 g_free (toplevel_id);
1317 g_free (object_path);
1318 g_object_unref (settings);
1319}
1320
1321static void
1322panel_profile_destroy_object (const char *id)
1323{
1324 AppletInfo *info;
1325
1326 info = mate_panel_applet_get_by_id (id);
1327
1328 mate_panel_applet_clean (info);
1329}
1330
1331static void
1332panel_profile_delete_dir (PanelGSettingsKeyType type,
1333 const char *id)
1334{
1335 gchar *dir = NULL((void*)0);
1336
1337 switch (type) {
1338 case PANEL_GSETTINGS_TOPLEVELS:
1339 dir = g_strdup_printf (PANEL_TOPLEVEL_PATH"/org/mate/panel/toplevels/" "%s/", id);
1340 break;
1341 case PANEL_GSETTINGS_OBJECTS:
1342 dir = g_strdup_printf (PANEL_OBJECT_PATH"/org/mate/panel/objects/" "%s/", id);
1343 break;
1344 default:
1345 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-profile.c"
, 1345, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1346 break;
1347 }
1348
1349 if (type == PANEL_GSETTINGS_TOPLEVELS) {
1350 gchar *subdir;
1351 subdir = g_strdup_printf (PANEL_TOPLEVEL_PATH"/org/mate/panel/toplevels/" "%s/background/", id);
1352 mate_dconf_recursive_reset (subdir, NULL((void*)0));
1353 g_free (subdir);
1354 }
1355 else if (type == PANEL_GSETTINGS_OBJECTS) {
1356 gchar *subdir;
1357 subdir = g_strdup_printf (PANEL_TOPLEVEL_PATH"/org/mate/panel/toplevels/" "%s/prefs/", id);
1358 mate_dconf_recursive_reset (subdir, NULL((void*)0));
1359 unregister_dconf_editor_relocatable_schema (subdir);
1360 g_free (subdir);
1361 }
1362
1363 if (dir != NULL((void*)0)) {
1364 mate_dconf_recursive_reset (dir, NULL((void*)0));
1365 g_free (dir);
1366 }
1367}
1368
1369static gboolean
1370panel_profile_object_exists (GSList *list,
1371 const char *id,
1372 PanelProfileGetIdFunc get_id_func)
1373{
1374 GSList *l;
1375
1376 if (!list || !id)
1377 return FALSE(0);
1378
1379 for (l = list; l; l = l->next) {
1380 const char *check_id;
1381
1382 check_id = get_id_func (l->data);
1383 g_assert (check_id != NULL)do { if (check_id != ((void*)0)) ; else g_assertion_message_expr
(((gchar*) 0), "panel-profile.c", 1383, ((const char*) (__func__
)), "check_id != NULL"); } while (0)
;
1384
1385 if (!strcmp (check_id, id))
1386 return TRUE(!(0));
1387 }
1388
1389 return FALSE(0);
1390}
1391
1392static gboolean
1393panel_profile_id_exists (GSList *id_list,
1394 const char *id)
1395{
1396 GSList *l;
1397
1398 if (!id_list || !id)
1399 return FALSE(0);
1400
1401 for (l = id_list; l; l = l->next) {
1402 const char *check_id = l->data;
1403
1404 if (!strcmp (id, check_id))
1405 return TRUE(!(0));
1406 }
1407
1408 return FALSE(0);
1409}
1410
1411static void
1412panel_profile_load_added_ids (GSList *list,
1413 GSList *id_list,
1414 PanelProfileGetIdFunc get_id_func,
1415 PanelProfileLoadFunc load_handler,
1416 PanelProfileOnLoadQueue on_load_queue)
1417{
1418 GSList *added_ids = NULL((void*)0);
1419 GSList *l;
1420
1421 for (l = id_list; l; l = l->next) {
1422 const char *id = l->data;
1423
1424 if (!panel_profile_object_exists (list, id, get_id_func) &&
1425 (on_load_queue == NULL((void*)0) || !on_load_queue (id)))
1426 added_ids = g_slist_prepend (added_ids, g_strdup (id)g_strdup_inline (id));
1427 }
1428
1429 for (l = added_ids; l; l = l->next) {
1430 char *id;
1431 id = (char *) l->data;
1432
1433 if (id && id[0])
1434 load_handler (id);
1435
1436 g_clear_pointer (&l->data, g_free)do { _Static_assert (sizeof *(&l->data) == sizeof (gpointer
), "Expression evaluates to false"); __typeof__ ((&l->
data)) _pp = (&l->data); __typeof__ (*(&l->data
)) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (g_free) (_ptr);
} while (0)
;
1437 }
1438
1439 g_slist_free (added_ids);
1440}
1441
1442static void
1443panel_profile_delete_removed_ids (PanelGSettingsKeyType type,
1444 GSList *list,
1445 GSList *id_list,
1446 PanelProfileGetIdFunc get_id_func,
1447 PanelProfileDestroyFunc destroy_handler)
1448{
1449 GSList *removed_ids = NULL((void*)0);
1450 GSList *l;
1451
1452 for (l = list; l; l = l->next) {
1453 const char *id;
1454
1455 id = get_id_func (l->data);
1456
1457 if (!panel_profile_id_exists (id_list, id))
1458 removed_ids = g_slist_prepend (removed_ids, g_strdup (id)g_strdup_inline (id));
1459 }
1460
1461 for (l = removed_ids; l; l = l->next) {
1462 const char *id = l->data;
1463
1464 panel_profile_delete_dir (type, id);
1465 destroy_handler (id);
1466
1467 g_clear_pointer (&l->data, g_free)do { _Static_assert (sizeof *(&l->data) == sizeof (gpointer
), "Expression evaluates to false"); __typeof__ ((&l->
data)) _pp = (&l->data); __typeof__ (*(&l->data
)) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (g_free) (_ptr);
} while (0)
;
1468 }
1469 g_slist_free (removed_ids);
1470}
1471
1472static gboolean
1473load_default_layout_idle (gpointer unused) {
1474 if (g_slist_length (panel_toplevel_list_toplevels ()) != 0) {
1475 /* some toplevels are not destroyed yet, waiting */
1476 return TRUE(!(0));
1477 }
1478
1479 /* load the default layout and stop this handler */
1480 panel_profile_ensure_toplevel_per_screen ();
1481 return FALSE(0);
1482}
1483
1484static void
1485panel_profile_toplevel_id_list_notify (GSettings *settings,
1486 gchar *key,
1487 gpointer user_data)
1488{
1489 GSList *l, *existing_toplevels;
1490 GSList *toplevel_ids;
1491 gchar **toplevel_ids_strv;
1492
1493 toplevel_ids_strv = g_settings_get_strv (settings, key);
1494
1495 toplevel_ids = mate_gsettings_strv_to_gslist ((const gchar **) toplevel_ids_strv);
1496 toplevel_ids = panel_g_slist_make_unique (toplevel_ids,
1497 (GCompareFunc) g_strcmp0,
1498 TRUE(!(0)));
1499 g_strfreev (toplevel_ids_strv);
1500
1501 existing_toplevels = NULL((void*)0);
1502 for (l = panel_toplevel_list_toplevels (); l; l = l->next) {
1503 PanelToplevel *toplevel = l->data;
1504
1505 /* Attached toplevels aren't on the id list */
1506 if (panel_toplevel_get_is_attached (toplevel))
1507 continue;
1508
1509 existing_toplevels = g_slist_prepend (existing_toplevels, toplevel);
1510 }
1511
1512 panel_profile_load_added_ids (existing_toplevels,
1513 toplevel_ids,
1514 (PanelProfileGetIdFunc) panel_profile_get_toplevel_id,
1515 (PanelProfileLoadFunc) panel_profile_load_and_show_toplevel,
1516 (PanelProfileOnLoadQueue) NULL((void*)0));
1517
1518 panel_profile_delete_removed_ids (PANEL_GSETTINGS_TOPLEVELS,
1519 existing_toplevels,
1520 toplevel_ids,
1521 (PanelProfileGetIdFunc) panel_profile_get_toplevel_id,
1522 (PanelProfileDestroyFunc) panel_profile_destroy_toplevel);
1523
1524 /* if there are no panels, reset layout to default */
1525 if (g_slist_length (toplevel_ids) == 0)
1526 g_idle_add (load_default_layout_idle, NULL((void*)0));
1527
1528 g_slist_free (existing_toplevels);
1529 g_slist_free_full (toplevel_ids, g_free);
1530}
1531
1532static void
1533panel_profile_object_id_list_update (gchar **objects)
1534{
1535 GSList *existing_applets;
1536 GSList *sublist = NULL((void*)0), *l;
1537 GSList *object_ids;
1538
1539 object_ids = mate_gsettings_strv_to_gslist ((const gchar **) objects);
1540 object_ids = panel_g_slist_make_unique (object_ids,
1541 (GCompareFunc) g_strcmp0,
1542 TRUE(!(0)));
1543
1544 existing_applets = mate_panel_applet_list_applets ();
1545
1546 for (l = existing_applets; l; l = l->next) {
1547 AppletInfo *info = l->data;
1548 sublist = g_slist_prepend (sublist, info);
1549 }
1550
1551 panel_profile_load_added_ids (sublist,
1552 object_ids,
1553 (PanelProfileGetIdFunc) mate_panel_applet_get_id,
1554 (PanelProfileLoadFunc) panel_profile_load_object,
1555 (PanelProfileOnLoadQueue) mate_panel_applet_on_load_queue);
1556
1557 panel_profile_delete_removed_ids (PANEL_GSETTINGS_OBJECTS,
1558 sublist,
1559 object_ids,
1560 (PanelProfileGetIdFunc) mate_panel_applet_get_id,
1561 (PanelProfileDestroyFunc) panel_profile_destroy_object);
1562
1563 g_slist_free (sublist);
1564 g_slist_free_full (object_ids, g_free);
1565
1566 mate_panel_applet_load_queued_applets (FALSE(0));
1567}
1568
1569static void
1570panel_profile_object_id_list_notify (GSettings *settings,
1571 gchar *key,
1572 gpointer data)
1573{
1574 gchar **objects;
1575 objects = g_settings_get_strv (settings, key);
1576 panel_profile_object_id_list_update (objects);
1577 g_strfreev (objects);
1578}
1579
1580static void
1581panel_profile_load_list (GSettings *settings,
1582 PanelGSettingsKeyType type,
1583 PanelProfileLoadFunc load_handler,
1584 GCallback notify_handler)
1585{
1586 const gchar *key = key_from_type (type);
1587 gchar *changed_signal;
1588 gchar **list;
1589
1590 changed_signal = g_strdup_printf ("changed::%s", key);
1591 g_signal_connect (settings, changed_signal, G_CALLBACK (notify_handler), NULL)g_signal_connect_data ((settings), (changed_signal), (((GCallback
) (notify_handler))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
1592 g_free (changed_signal);
1593
1594 list = g_settings_get_strv (settings, key);
1595
1596 if (list) {
1597 for (gint i = 0; list[i]; i++) {
1598 load_handler (list[i]);
1599 }
1600
1601 g_strfreev (list);
1602 }
1603}
1604
1605static void
1606panel_profile_ensure_toplevel_per_screen ()
1607{
1608 GSList *toplevels;
1609 GSList *empty_screens = NULL((void*)0);
1610 GSList *l;
1611 GdkDisplay *display;
1612 GdkScreen *screen;
1613
1614 toplevels = panel_toplevel_list_toplevels ();
1615
1616 display = gdk_display_get_default ();
1617
1618 screen = gdk_display_get_default_screen (display);
1619
1620 for (l = toplevels; l; l = l->next)
1621 if (gtk_window_get_screen (l->data) == screen)
1622 break;
1623
1624 if (!l)
1625 empty_screens = g_slist_prepend (empty_screens, screen);
1626
1627 for (l = empty_screens; l; l = l->next)
1628 panel_layout_apply_default_from_gkeyfile (l->data);
1629
1630 g_slist_free (empty_screens);
1631}
1632
1633void
1634panel_profile_settings_load (void)
1635{
1636 profile_settings = g_settings_new ("org.mate.panel");
1637}
1638
1639void
1640panel_profile_load (void)
1641{
1642 panel_profile_settings_load();
1643
1644 panel_profile_load_list (profile_settings,
1645 PANEL_GSETTINGS_TOPLEVELS,
1646 (PanelProfileLoadFunc)panel_profile_load_and_show_toplevel_startup,
1647 G_CALLBACK (panel_profile_toplevel_id_list_notify)((GCallback) (panel_profile_toplevel_id_list_notify)));
1648 panel_profile_load_list (profile_settings,
1649 PANEL_GSETTINGS_OBJECTS,
1650 (PanelProfileLoadFunc)panel_profile_load_object,
1651 G_CALLBACK (panel_profile_object_id_list_notify)((GCallback) (panel_profile_object_id_list_notify)));
1652
1653 panel_profile_ensure_toplevel_per_screen ();
1654
1655 mate_panel_applet_load_queued_applets (TRUE(!(0)));
1656}
1657
1658static gboolean
1659get_program_listing_setting (const char *key)
1660{
1661 gboolean retval;
1662 retval = g_settings_get_boolean (profile_settings, key);
1663 return retval;
1664}
1665
1666gboolean
1667panel_profile_get_show_program_list (void)
1668{
1669 return get_program_listing_setting ("show-program-list");
1670}
1671
1672gboolean
1673panel_profile_get_enable_program_list (void)
1674{
1675 return get_program_listing_setting ("enable-program-list");
1676}
1677
1678gboolean
1679panel_profile_get_enable_autocompletion (void)
1680{
1681 return get_program_listing_setting ("enable-autocompletion");
1682}
1683
1684void
1685panel_profile_set_show_program_list (gboolean show_program_list)
1686{
1687 g_settings_set_boolean (profile_settings, "show-program-list", show_program_list);
1688}
1689
1690gboolean
1691panel_profile_is_writable_show_program_list (void)
1692{
1693 return g_settings_is_writable (profile_settings, "show-program-list");
1694}
1695
1696gboolean
1697panel_profile_can_be_moved_freely (PanelToplevel *toplevel)
1698{
1699 if (panel_lockdown_get_locked_down () ||
1700 !g_settings_is_writable (toplevel->settings, PANEL_TOPLEVEL_ORIENTATION_KEY"orientation"))
1701 return FALSE(0);
1702
1703 if (!g_settings_is_writable (toplevel->settings, PANEL_TOPLEVEL_SCREEN_KEY"screen"))
1704 return FALSE(0);
1705
1706 if (!g_settings_is_writable (toplevel->settings, PANEL_TOPLEVEL_MONITOR_KEY"monitor"))
1707 return FALSE(0);
1708
1709 /* For expanded panels we don't really have to check
1710 x and y */
1711 if (panel_toplevel_get_expand (toplevel))
1712 return TRUE(!(0));
1713
1714 if (!g_settings_is_writable (toplevel->settings, PANEL_TOPLEVEL_X_KEY"x"))
1715 return FALSE(0);
1716 if (!g_settings_is_writable (toplevel->settings, PANEL_TOPLEVEL_X_RIGHT_KEY"x-right"))
1717 return FALSE(0);
1718 if (!g_settings_is_writable (toplevel->settings, PANEL_TOPLEVEL_X_CENTERED_KEY"x-centered"))
1719 return FALSE(0);
1720
1721 if (!g_settings_is_writable (toplevel->settings, PANEL_TOPLEVEL_Y_KEY"y"))
1722 return FALSE(0);
1723 if (!g_settings_is_writable (toplevel->settings, PANEL_TOPLEVEL_Y_BOTTOM_KEY"y-bottom"))
1724 return FALSE(0);
1725 if (!g_settings_is_writable (toplevel->settings, PANEL_TOPLEVEL_Y_CENTERED_KEY"y-centered"))
1726 return FALSE(0);
1727
1728 return TRUE(!(0));
1729}
diff --git a/2024-06-18-172109-13286-1@e182420b844f_master/report-1eba91.html b/2024-06-18-172109-13286-1@e182420b844f_master/report-1eba91.html new file mode 100644 index 00000000..5bc22907 --- /dev/null +++ b/2024-06-18-172109-13286-1@e182420b844f_master/report-1eba91.html @@ -0,0 +1,1074 @@ + + + +panel-test-applets.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:mate-panel/panel-test-applets.c
Warning:line 360, column 3
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name panel-test-applets.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/mate-panel -fcoverage-compilation-dir=/rootdir/mate-panel -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I .. -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/startup-notification-1.0 -I /usr/include/mate-menus -I /usr/include/gio-unix-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/dconf -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/dconf -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I . -I . -I ../mate-panel -I ../mate-panel/mate-submodules -I ../mate-panel/libpanel-util -D MATELOCALEDIR="/usr/local/share/locale" -D PANELDATADIR="/usr/local/share/mate-panel" -I /usr/include/gtk-layer-shell -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/gtk-3.0 -I /usr/include/cloudproviders -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/atk-1.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/gio-unix-2.0 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -D PANEL_MODULES_DIR="/usr/local/lib/mate-panel/modules" -D MATE_PANEL_APPLETS_DIR="/usr/local/share/mate-panel/applets" -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-18-172109-13286-1 -x c panel-test-applets.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * panel-test-applets.c:
3 *
4 * Authors:
5 * Mark McLoughlin <mark@skynet.ie>
6 * Stefano Karapetsas <stefano@karapetsas.com>
7 *
8 * Copyright 2002 Sun Microsystems, Inc.
9 * 2012 Stefano Karapetsas
10 * Copyright (C) 2012-2021 MATE Developers
11 */
12
13#include <config.h>
14#include <glib/gi18n.h>
15#include <gtk/gtk.h>
16#include <gio/gio.h>
17
18#include <libpanel-util/panel-cleanup.h>
19#include <libmate-desktop/mate-dconf.h>
20
21#include <libmate-panel-applet-private/panel-applet-container.h>
22#include <libmate-panel-applet-private/panel-applets-manager-dbus.h>
23
24#include "panel-modules.h"
25
26G_GNUC_UNUSED__attribute__ ((__unused__)) void on_execute_button_clicked (GtkButton *button, gpointer dummy);
27
28static GtkWidget *win = NULL((void*)0);
29static GtkWidget *applet_combo = NULL((void*)0);
30static GtkWidget *prefs_path_entry = NULL((void*)0);
31static GtkWidget *orient_combo = NULL((void*)0);
32static GtkWidget *size_combo = NULL((void*)0);
33
34static char *cli_iid = NULL((void*)0);
35static char *cli_prefs_path = NULL((void*)0);
36static char *cli_size = NULL((void*)0);
37static char *cli_orient = NULL((void*)0);
38
39static const GOptionEntry options [] = {
40 { "iid", 0, 0, G_OPTION_ARG_STRING, &cli_iid, N_("Specify an applet IID to load")("Specify an applet IID to load"), NULL((void*)0)},
41 { "prefs-path", 0, 0, G_OPTION_ARG_STRING, &cli_prefs_path, N_("Specify a gsettings path in which the applet preferences should be stored")("Specify a gsettings path in which the applet preferences should be stored"
)
, NULL((void*)0)},
42 { "size", 0, 0, G_OPTION_ARG_STRING, &cli_size, N_("Specify the initial size of the applet (xx-small, medium, large etc.)")("Specify the initial size of the applet (xx-small, medium, large etc.)"
)
, NULL((void*)0)},
43 { "orient", 0, 0, G_OPTION_ARG_STRING, &cli_orient, N_("Specify the initial orientation of the applet (top, bottom, left or right)")("Specify the initial orientation of the applet (top, bottom, left or right)"
)
, NULL((void*)0)},
44 { NULL((void*)0), 0, 0, G_OPTION_ARG_NONE, NULL((void*)0), NULL((void*)0), NULL((void*)0) }
45};
46
47enum {
48 COLUMN_TEXT,
49 COLUMN_ITEM,
50 NUMBER_COLUMNS
51};
52
53typedef struct {
54 const char *name;
55 guint value;
56} ComboItem;
57
58static ComboItem orient_items [] = {
59 { NC_("Orientation", "Top")("Top"), PANEL_ORIENTATION_TOP },
60 { NC_("Orientation", "Bottom")("Bottom"), PANEL_ORIENTATION_BOTTOM },
61 { NC_("Orientation", "Left")("Left"), PANEL_ORIENTATION_LEFT },
62 { NC_("Orientation", "Right")("Right"), PANEL_ORIENTATION_RIGHT }
63};
64
65static ComboItem size_items [] = {
66 { NC_("Size", "XX Small")("XX Small"), 12 },
67 { NC_("Size", "X Small")("X Small"), 24 },
68 { NC_("Size", "Small")("Small"), 36 },
69 { NC_("Size", "Medium")("Medium"), 48 },
70 { NC_("Size", "Large")("Large"), 64 },
71 { NC_("Size", "X Large")("X Large"), 80 },
72 { NC_("Size", "XX Large")("XX Large"), 128 }
73};
74
75static guint
76get_combo_value (GtkWidget *combo_box)
77{
78 GtkTreeIter iter;
79 GtkTreeModel *model;
80 guint value;
81
82 if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo_box)((((GtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((combo_box)), ((gtk_combo_box_get_type ()))))))
, &iter))
83 return 0;
84
85 model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo_box)((((GtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((combo_box)), ((gtk_combo_box_get_type ()))))))
);
86 gtk_tree_model_get (model, &iter, COLUMN_ITEM, &value, -1);
87
88 return value;
89}
90
91static gchar *
92get_combo_applet_id (GtkWidget *combo_box)
93{
94 GtkTreeIter iter;
95 GtkTreeModel *model;
96 char *value;
97
98 if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo_box)((((GtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((combo_box)), ((gtk_combo_box_get_type ()))))))
, &iter))
99 return NULL((void*)0);
100
101 model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo_box)((((GtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((combo_box)), ((gtk_combo_box_get_type ()))))))
);
102 gtk_tree_model_get (model, &iter, COLUMN_ITEM, &value, -1);
103
104 return value;
105}
106
107static void
108applet_broken_cb (GtkWidget *container,
109 GtkWidget *window)
110{
111 gtk_widget_destroy (window);
112}
113
114static void
115applet_activated_cb (GObject *source_object,
116 GAsyncResult *res,
117 GtkWidget *applet_window)
118{
119 GError *error = NULL((void*)0);
120
121 if (!mate_panel_applet_container_add_finish (MATE_PANEL_APPLET_CONTAINER (source_object)((((MatePanelAppletContainer*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((source_object)), ((mate_panel_applet_container_get_type
()))))))
,
122 res, &error)) {
123 GtkWidget *dialog;
124
125 dialog = gtk_message_dialog_new (GTK_WINDOW (applet_window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet_window)), ((gtk_window_get_type ()))))))
,
126 GTK_DIALOG_MODAL|
127 GTK_DIALOG_DESTROY_WITH_PARENT,
128 GTK_MESSAGE_ERROR,
129 GTK_BUTTONS_CLOSE,
130 _("Failed to load applet %s")gettext ("Failed to load applet %s"),
131 error->message); /* FIXME */
132 gtk_dialog_run (GTK_DIALOG (dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_dialog_get_type ()))))))
);
133 gtk_widget_destroy (dialog);
134 return;
135 }
136
137 gtk_widget_show (applet_window);
138}
139
140static void
141load_applet_into_window (const char *title,
142 const char *prefs_path,
143 guint size,
144 guint orientation)
145{
146 GtkWidget *container;
147 GtkWidget *applet_window;
148 GVariantBuilder builder;
149
150 container = mate_panel_applet_container_new ();
151
152 applet_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
153 /* FIXME: we could set the window icon with the applet icon */
154 gtk_window_set_title (GTK_WINDOW (applet_window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet_window)), ((gtk_window_get_type ()))))))
, title);
155 gtk_container_add (GTK_CONTAINER (applet_window)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet_window)), ((gtk_container_get_type ()))))))
, container);
156 gtk_widget_show (container);
157
158 g_signal_connect (container, "applet-broken",g_signal_connect_data ((container), ("applet-broken"), (((GCallback
) (applet_broken_cb))), (applet_window), ((void*)0), (GConnectFlags
) 0)
159 G_CALLBACK (applet_broken_cb),g_signal_connect_data ((container), ("applet-broken"), (((GCallback
) (applet_broken_cb))), (applet_window), ((void*)0), (GConnectFlags
) 0)
160 applet_window)g_signal_connect_data ((container), ("applet-broken"), (((GCallback
) (applet_broken_cb))), (applet_window), ((void*)0), (GConnectFlags
) 0)
;
161
162 g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}")(g_variant_type_checked_ (("a{sv}"))));
163 g_variant_builder_add (&builder, "{sv}",
164 "prefs-path", g_variant_new_string (prefs_path));
165 g_variant_builder_add (&builder, "{sv}",
166 "size", g_variant_new_uint32 (size));
167 g_variant_builder_add (&builder, "{sv}",
168 "orient", g_variant_new_uint32 (orientation));
169 mate_panel_applet_container_add (MATE_PANEL_APPLET_CONTAINER (container)((((MatePanelAppletContainer*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((container)), ((mate_panel_applet_container_get_type
()))))))
,
170 gtk_widget_get_screen (applet_window),
171 title, NULL((void*)0),
172 (GAsyncReadyCallback)applet_activated_cb,
173 applet_window,
174 g_variant_builder_end (&builder));
175}
176
177static void
178load_applet_from_command_line (void)
179{
180 guint size = 24, orient = PANEL_ORIENTATION_TOP;
181
182 g_assert (cli_iid != NULL)do { if (cli_iid != ((void*)0)) ; else g_assertion_message_expr
(((gchar*) 0), "panel-test-applets.c", 182, ((const char*) (
__func__)), "cli_iid != NULL"); } while (0)
;
183
184 if (cli_size || cli_orient) {
185 if (cli_size) {
186 for (gsize i = 0; i < G_N_ELEMENTS (size_items)(sizeof (size_items) / sizeof ((size_items)[0])); i++) {
187 if (strcmp (g_dpgettext2 (NULL((void*)0), "Size", size_items[i].name), cli_size) == 0) {
188 size = size_items[i].value;
189 break;
190 }
191 }
192 }
193
194 if (cli_orient) {
195 for (gsize i = 0; i < G_N_ELEMENTS (orient_items)(sizeof (orient_items) / sizeof ((orient_items)[0])); i++) {
196 if (strcmp (g_dpgettext2 (NULL((void*)0), "Orientation", orient_items[i].name), cli_orient) == 0) {
197 orient = orient_items[i].value;
198 break;
199 }
200 }
201 }
202 }
203
204 g_print ("Loading %s\n", cli_iid);
205
206 load_applet_into_window (cli_iid, cli_prefs_path, size, orient);
207}
208
209G_GNUC_UNUSED__attribute__ ((__unused__)) void
210on_execute_button_clicked (GtkButton *button,
211 gpointer dummy)
212{
213 char *title;
214
215 title = get_combo_applet_id (applet_combo);
216
217 load_applet_into_window (title,
218 gtk_entry_get_text (GTK_ENTRY (prefs_path_entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((prefs_path_entry)), ((gtk_entry_get_type ()))))))
),
219 get_combo_value (size_combo),
220 get_combo_value (orient_combo));
221 g_free (title);
222}
223
224static void
225setup_combo (GtkWidget *combo_box,
226 ComboItem *items,
227 const char *context,
228 int nb_items)
229{
230 GtkListStore *model;
231 GtkTreeIter iter;
232 GtkCellRenderer *renderer;
233 int i;
234
235 model = gtk_list_store_new (NUMBER_COLUMNS,
236 G_TYPE_STRING((GType) ((16) << (2))),
237 G_TYPE_INT((GType) ((6) << (2))));
238
239 gtk_combo_box_set_model (GTK_COMBO_BOX (combo_box)((((GtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((combo_box)), ((gtk_combo_box_get_type ()))))))
,
240 GTK_TREE_MODEL (model)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_model_get_type ()))))))
);
241
242 for (i = 0; i < nb_items; i++) {
243 gtk_list_store_append (model, &iter);
244 gtk_list_store_set (model, &iter,
245 COLUMN_TEXT, g_dpgettext2 (NULL((void*)0), context, items [i].name),
246 COLUMN_ITEM, items [i].value,
247 -1);
248 }
249
250 renderer = gtk_cell_renderer_text_new ();
251 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box)((((GtkCellLayout*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((combo_box)), ((gtk_cell_layout_get_type ()))))))
,
252 renderer, TRUE(!(0)));
253 gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box)((((GtkCellLayout*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((combo_box)), ((gtk_cell_layout_get_type ()))))))
,
254 renderer, "text", COLUMN_TEXT, NULL((void*)0));
255
256 gtk_combo_box_set_active (GTK_COMBO_BOX (combo_box)((((GtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((combo_box)), ((gtk_combo_box_get_type ()))))))
, 0);
257}
258
259static void
260setup_options (void)
261{
262 MatePanelAppletsManager *manager;
263 GList *applet_list, *l;
264 int i;
265 int j;
266 char *prefs_path = NULL((void*)0);
267 char *unique_key = NULL((void*)0);
268 gboolean unique_key_found = FALSE(0);
269 GtkListStore *model;
270 GtkTreeIter iter;
271 GtkCellRenderer *renderer;
272
273 model = gtk_list_store_new (NUMBER_COLUMNS,
274 G_TYPE_STRING((GType) ((16) << (2))),
275 G_TYPE_STRING((GType) ((16) << (2))));
276
277 gtk_combo_box_set_model (GTK_COMBO_BOX (applet_combo)((((GtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet_combo)), ((gtk_combo_box_get_type ()))))))
,
278 GTK_TREE_MODEL (model)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_model_get_type ()))))))
);
279
280 manager = g_object_new (PANEL_TYPE_APPLETS_MANAGER_DBUS(mate_panel_applets_manager_dbus_get_type ()), NULL((void*)0));
281 applet_list = MATE_PANEL_APPLETS_MANAGER_GET_CLASS (manager)->get_applets (manager);
282 for (l = applet_list, i = 1; l; l = g_list_next (l)((l) ? (((GList *)(l))->next) : ((void*)0)), i++) {
283 MatePanelAppletInfo *info = (MatePanelAppletInfo *)l->data;
284
285 gtk_list_store_append (model, &iter);
286 gtk_list_store_set (model, &iter,
287 COLUMN_TEXT, mate_panel_applet_info_get_name (info),
288 COLUMN_ITEM, mate_panel_applet_info_get_iid (info),
289 -1);
290 }
291 g_list_free (applet_list);
292 g_object_unref (manager);
293
294 renderer = gtk_cell_renderer_text_new ();
295 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (applet_combo)((((GtkCellLayout*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet_combo)), ((gtk_cell_layout_get_type ()))))))
,
296 renderer, TRUE(!(0)));
297 gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (applet_combo)((((GtkCellLayout*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet_combo)), ((gtk_cell_layout_get_type ()))))))
,
298 renderer, "text", COLUMN_TEXT, NULL((void*)0));
299
300 gtk_combo_box_set_active (GTK_COMBO_BOX (applet_combo)((((GtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet_combo)), ((gtk_combo_box_get_type ()))))))
, 0);
301
302 setup_combo (size_combo, size_items, "Size",
303 G_N_ELEMENTS (size_items)(sizeof (size_items) / sizeof ((size_items)[0])));
304 setup_combo (orient_combo, orient_items, "Orientation",
305 G_N_ELEMENTS (orient_items)(sizeof (orient_items) / sizeof ((orient_items)[0])));
306
307 for (i = 0; !unique_key_found; i++)
308 {
309 g_free (unique_key);
310 unique_key = g_strdup_printf ("mate-panel-test-applet-%d", i);
311 unique_key_found = TRUE(!(0));
312 gchar **dconf_paths = mate_dconf_list_subdirs ("/tmp/", TRUE(!(0)));
313 for (j = 0; dconf_paths[j] != NULL((void*)0); j++)
314 {
315 if (g_strcmp0(unique_key, dconf_paths[j]) == 0) {
316 unique_key_found = FALSE(0);
317 break;
318 }
319 }
320 if (dconf_paths)
321 g_strfreev (dconf_paths);
322 }
323
324 prefs_path = g_strdup_printf ("/tmp/%s/", unique_key);
325 if (unique_key)
326 g_free (unique_key);
327 gtk_entry_set_text (GTK_ENTRY (prefs_path_entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((prefs_path_entry)), ((gtk_entry_get_type ()))))))
, prefs_path);
328 g_free (prefs_path);
329}
330
331int
332main (int argc, char **argv)
333{
334 GtkBuilder *builder;
335 GError *error;
336
337 bindtextdomain (GETTEXT_PACKAGE"mate-panel", MATELOCALEDIR"/usr/local/share/locale");
338 bind_textdomain_codeset (GETTEXT_PACKAGE"mate-panel", "UTF-8");
339 textdomain (GETTEXT_PACKAGE"mate-panel");
340
341 error = NULL((void*)0);
342 if (!gtk_init_with_args (&argc, &argv,
343 "", (GOptionEntry *) options, GETTEXT_PACKAGE"mate-panel",
344 &error)) {
345 if (error) {
346 g_printerr ("%s\n", error->message);
347 g_error_free (error);
348 } else
349 g_printerr ("Cannot initialize GTK+.\n");
350
351 return 1;
352 }
353
354 panel_modules_ensure_loaded ();
355
356 if (g_file_test ("../libmate-panel-applet", G_FILE_TEST_IS_DIR))
357 g_setenv ("MATE_PANEL_APPLETS_DIR", MATE_PANEL_APPLETS_DIR"/usr/local/share/mate-panel/applets" ":../libmate-panel-applet", FALSE(0));
358
359 if (cli_iid) {
360 load_applet_from_command_line ();
This statement is never executed
361 gtk_main ();
362 panel_cleanup_do ();
363
364 return 0;
365 }
366
367 builder = gtk_builder_new ();
368 gtk_builder_set_translation_domain (builder, GETTEXT_PACKAGE"mate-panel");
369 gtk_builder_add_from_resource (builder, "/org/mate/panel/test/panel-test-applets.ui", NULL((void*)0));
370
371 gtk_builder_connect_signals (builder, NULL((void*)0));
372
373 win = GTK_WIDGET (gtk_builder_get_object (builder,((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, "toplevel"))), ((gtk_widget_get_type
()))))))
374 "toplevel"))((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, "toplevel"))), ((gtk_widget_get_type
()))))))
;
375 applet_combo = GTK_WIDGET (gtk_builder_get_object (builder,((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, "applet-combo"))), ((gtk_widget_get_type
()))))))
376 "applet-combo"))((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, "applet-combo"))), ((gtk_widget_get_type
()))))))
;
377 prefs_path_entry = GTK_WIDGET (gtk_builder_get_object (builder,((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, "prefs-path-entry"))), (
(gtk_widget_get_type ()))))))
378 "prefs-path-entry"))((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, "prefs-path-entry"))), (
(gtk_widget_get_type ()))))))
;
379 orient_combo = GTK_WIDGET (gtk_builder_get_object (builder,((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, "orient-combo"))), ((gtk_widget_get_type
()))))))
380 "orient-combo"))((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, "orient-combo"))), ((gtk_widget_get_type
()))))))
;
381 size_combo = GTK_WIDGET (gtk_builder_get_object (builder,((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, "size-combo"))), ((gtk_widget_get_type
()))))))
382 "size-combo"))((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, "size-combo"))), ((gtk_widget_get_type
()))))))
;
383 g_object_unref (builder);
384
385 setup_options ();
386
387 gtk_widget_show (win);
388
389 gtk_main ();
390
391 panel_cleanup_do ();
392
393 return 0;
394}
diff --git a/2024-06-18-172109-13286-1@e182420b844f_master/report-2de153.html b/2024-06-18-172109-13286-1@e182420b844f_master/report-2de153.html new file mode 100644 index 00000000..93abe07c --- /dev/null +++ b/2024-06-18-172109-13286-1@e182420b844f_master/report-2de153.html @@ -0,0 +1,1980 @@ + + + +window-list.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:applets/wncklet/window-list.c
Warning:line 424, column 87
The left operand of '-' is a garbage value
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name window-list.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/applets/wncklet -fcoverage-compilation-dir=/rootdir/applets/wncklet -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I ../.. -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/gio-unix-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/libwnck-3.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/startup-notification-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/gio-unix-2.0 -I /usr/include/dconf -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I ../.. -I ../../applets/wncklet -I ../../libmate-panel-applet -I ../../libmate-panel-applet -D MATELOCALEDIR="/usr/local/share/locale" -I /usr/include/gtk-layer-shell -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/gtk-3.0 -I /usr/include/cloudproviders -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/atk-1.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/gio-unix-2.0 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -D PIC -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-18-172109-13286-1 -x c window-list.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* -*- mode: C; c-file-style: "linux" -*- */
2/*
3 * libwnck based tasklist applet.
4 * (C) 2001 Red Hat, Inc
5 * (C) 2001 Alexander Larsson
6 *
7 * Authors: Alexander Larsson
8 *
9 */
10
11#include <config.h>
12
13#include <string.h>
14
15#include <mate-panel-applet.h>
16#include <mate-panel-applet-gsettings.h>
17
18#include <glib/gi18n.h>
19#include <gtk/gtk.h>
20#include <gio/gio.h>
21
22#ifdef HAVE_X111
23#include <gdk/gdkx.h>
24#define WNCK_I_KNOW_THIS_IS_UNSTABLE
25#include <libwnck/libwnck.h>
26#endif /* HAVE_X11 */
27
28#ifdef HAVE_WAYLAND1
29#include <gdk/gdkwayland.h>
30#include "wayland-backend.h"
31#endif /* HAVE_WAYLAND */
32
33#define MATE_DESKTOP_USE_UNSTABLE_API
34#include <libmate-desktop/mate-desktop-utils.h>
35
36#include "wncklet.h"
37#include "window-list.h"
38
39#define WINDOW_LIST_ICON"mate-panel-window-list" "mate-panel-window-list"
40#define WINDOW_LIST_SCHEMA"org.mate.panel.applet.window-list" "org.mate.panel.applet.window-list"
41
42#ifdef HAVE_WINDOW_PREVIEWS1
43#define WINDOW_LIST_PREVIEW_SCHEMA"org.mate.panel.applet.window-list-previews" "org.mate.panel.applet.window-list-previews"
44#endif /* HAVE_WINDOW_PREVIEWS */
45
46typedef enum {
47 TASKLIST_NEVER_GROUP,
48 TASKLIST_AUTO_GROUP,
49 TASKLIST_ALWAYS_GROUP
50} TasklistGroupingType;
51
52typedef struct {
53 GtkWidget* applet;
54 GtkWidget* tasklist;
55#ifdef HAVE_WINDOW_PREVIEWS1
56 GtkWidget* preview;
57
58 gboolean show_window_thumbnails;
59 gint thumbnail_size;
60#endif
61 gboolean include_all_workspaces;
62
63 TasklistGroupingType grouping;
64 gboolean move_unminimized_windows;
65 gboolean scroll_enable;
66 gboolean middle_click_close;
67
68 GtkOrientation orientation;
69 int size;
70#if !defined(WNCKLET_INPROCESS1) && !GTK_CHECK_VERSION (3, 23, 0)((3) > (3) || ((3) == (3) && (24) > (23)) || ((
3) == (3) && (24) == (23) && (42) >= (0)))
71 gboolean needs_hints;
72#endif
73
74 /* Properties: */
75 GtkWidget* properties_dialog;
76 GtkWidget* wayland_info_label;
77 GtkWidget* show_current_radio;
78 GtkWidget* show_all_radio;
79#ifdef HAVE_WINDOW_PREVIEWS1
80 GtkWidget* window_thumbnail_box;
81 GtkWidget* show_thumbnails_check;
82 GtkWidget* thumbnail_size_label;
83 GtkWidget* thumbnail_size_spin;
84#endif
85 GtkWidget* never_group_radio;
86 GtkWidget* auto_group_radio;
87 GtkWidget* always_group_radio;
88 GtkWidget* move_minimized_radio;
89 GtkWidget* mouse_scroll_check;
90 GtkWidget* middle_click_close_check;
91 GtkWidget* change_workspace_radio;
92 GtkWidget* minimized_windows_box;
93 GtkWidget* window_grouping_box;
94 GtkWidget* window_list_content_box;
95
96 GSettings* settings;
97#ifdef HAVE_WINDOW_PREVIEWS1
98 GSettings* preview_settings;
99#endif
100} TasklistData;
101
102static void call_system_monitor(GtkAction* action, TasklistData* tasklist);
103static void display_properties_dialog(GtkAction* action, TasklistData* tasklist);
104static void display_help_dialog(GtkAction* action, TasklistData* tasklist);
105static void display_about_dialog(GtkAction* action, TasklistData* tasklist);
106static void destroy_tasklist(GtkWidget* widget, TasklistData* tasklist);
107
108static void tasklist_update(TasklistData* tasklist)
109{
110 if (tasklist->orientation == GTK_ORIENTATION_HORIZONTAL)
111 {
112 gtk_widget_set_size_request(GTK_WIDGET(tasklist->tasklist)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tasklist->tasklist)), ((gtk_widget_get_type ()))))))
, -1, tasklist->size);
113 }
114 else
115 {
116 gtk_widget_set_size_request(GTK_WIDGET(tasklist->tasklist)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tasklist->tasklist)), ((gtk_widget_get_type ()))))))
, tasklist->size, -1);
117 }
118
119#ifdef HAVE_X111
120 if (WNCK_IS_TASKLIST(tasklist->tasklist)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(tasklist->tasklist)); GType __t = ((wnck_tasklist_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; }))))
)
121 {
122 WnckTasklistGroupingType grouping;
123 switch (tasklist->grouping)
124 {
125 case TASKLIST_NEVER_GROUP:
126 grouping = WNCK_TASKLIST_NEVER_GROUP;
127 break;
128 case TASKLIST_AUTO_GROUP:
129 grouping = WNCK_TASKLIST_AUTO_GROUP;
130 break;
131 case TASKLIST_ALWAYS_GROUP:
132 grouping = WNCK_TASKLIST_ALWAYS_GROUP;
133 break;
134 default:
135 grouping = WNCK_TASKLIST_NEVER_GROUP;
136 }
137 wnck_tasklist_set_grouping(WNCK_TASKLIST(tasklist->tasklist)((((WnckTasklist*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tasklist->tasklist)), ((wnck_tasklist_get_type ()))))
))
, grouping);
138 wnck_tasklist_set_include_all_workspaces(WNCK_TASKLIST(tasklist->tasklist)((((WnckTasklist*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tasklist->tasklist)), ((wnck_tasklist_get_type ()))))
))
, tasklist->include_all_workspaces);
139 wnck_tasklist_set_switch_workspace_on_unminimize(WNCK_TASKLIST(tasklist->tasklist)((((WnckTasklist*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tasklist->tasklist)), ((wnck_tasklist_get_type ()))))
))
, tasklist->move_unminimized_windows);
140 wnck_tasklist_set_scroll_enabled (WNCK_TASKLIST(tasklist->tasklist)((((WnckTasklist*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tasklist->tasklist)), ((wnck_tasklist_get_type ()))))
))
, tasklist->scroll_enable);
141 wnck_tasklist_set_middle_click_close (WNCK_TASKLIST (tasklist->tasklist)((((WnckTasklist*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tasklist->tasklist)), ((wnck_tasklist_get_type ()))))
))
, tasklist->middle_click_close);
142 }
143#endif /* HAVE_X11 */
144
145 /* Not implemented for Wayland */
146}
147
148static void tasklist_apply_orientation(TasklistData* tasklist)
149{
150#ifdef HAVE_X111
151 if (WNCK_IS_TASKLIST(tasklist->tasklist)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(tasklist->tasklist)); GType __t = ((wnck_tasklist_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; }))))
)
152 {
153 wnck_tasklist_set_orientation(WNCK_TASKLIST(tasklist->tasklist)((((WnckTasklist*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tasklist->tasklist)), ((wnck_tasklist_get_type ()))))
))
, tasklist->orientation);
154 }
155#endif /* HAVE_X11 */
156
157#ifdef HAVE_WAYLAND1
158 if (GDK_IS_WAYLAND_DISPLAY(gdk_display_get_default())(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gdk_display_get_default())); GType __t = ((gdk_wayland_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
)
159 {
160 wayland_tasklist_set_orientation(tasklist->tasklist, tasklist->orientation);
161 }
162#endif
163}
164
165static void tasklist_set_button_relief(TasklistData* tasklist, GtkReliefStyle relief)
166{
167#ifdef HAVE_X111
168 if (WNCK_IS_TASKLIST(tasklist->tasklist)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(tasklist->tasklist)); GType __t = ((wnck_tasklist_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; }))))
)
169 {
170 wnck_tasklist_set_button_relief(WNCK_TASKLIST(tasklist->tasklist)((((WnckTasklist*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tasklist->tasklist)), ((wnck_tasklist_get_type ()))))
))
, relief);
171 }
172#endif /* HAVE_X11 */
173
174 /* Not implemented for Wayland */
175}
176
177static const int* tasklist_get_size_hint_list(TasklistData* tasklist, int* n_elements)
178{
179#ifdef HAVE_X111
180 if (WNCK_IS_TASKLIST(tasklist->tasklist)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(tasklist->tasklist)); GType __t = ((wnck_tasklist_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; }))))
)
181 {
182 return wnck_tasklist_get_size_hint_list(WNCK_TASKLIST(tasklist->tasklist)((((WnckTasklist*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tasklist->tasklist)), ((wnck_tasklist_get_type ()))))
))
, n_elements);
183 }
184 else
185#endif /* HAVE_X11 */
186
187 {
188 /* Not implemented for Wayland */
189 *n_elements = 0;
190 return NULL((void*)0);
191 }
192}
193
194static void response_cb(GtkWidget* widget, int id, TasklistData* tasklist)
195{
196 if (id == GTK_RESPONSE_HELP)
197 {
198 wncklet_display_help(widget, "mate-user-guide", "windowlist-prefs", WINDOW_LIST_ICON"mate-panel-window-list");
199 }
200 else
201 {
202 gtk_widget_hide(widget);
203 }
204}
205
206static void applet_change_orient(MatePanelApplet* applet, MatePanelAppletOrient orient, TasklistData* tasklist)
207{
208 GtkOrientation new_orient;
209
210 switch (orient)
211 {
212 case MATE_PANEL_APPLET_ORIENT_LEFT:
213 case MATE_PANEL_APPLET_ORIENT_RIGHT:
214 new_orient = GTK_ORIENTATION_VERTICAL;
215 break;
216 case MATE_PANEL_APPLET_ORIENT_UP:
217 case MATE_PANEL_APPLET_ORIENT_DOWN:
218 default:
219 new_orient = GTK_ORIENTATION_HORIZONTAL;
220 break;
221 }
222
223 if (new_orient == tasklist->orientation)
224 return;
225
226 tasklist->orientation = new_orient;
227 tasklist_apply_orientation (tasklist);
228
229 tasklist_update(tasklist);
230}
231
232static void applet_change_background(MatePanelApplet* applet, MatePanelAppletBackgroundType type, GdkColor* color, cairo_pattern_t* pattern, TasklistData* tasklist)
233{
234 switch (type)
235 {
236 case PANEL_NO_BACKGROUND:
237 case PANEL_COLOR_BACKGROUND:
238 case PANEL_PIXMAP_BACKGROUND:
239 tasklist_set_button_relief(tasklist, GTK_RELIEF_NONE);
240 break;
241 }
242}
243
244#ifdef HAVE_X111
245#ifdef HAVE_WINDOW_PREVIEWS1
246static cairo_surface_t*
247preview_window_thumbnail (WnckWindow *wnck_window,
248 TasklistData *tasklist,
249 int *thumbnail_width,
250 int *thumbnail_height,
251 int *thumbnail_scale)
252{
253 GdkWindow *window;
254 Window win;
255 cairo_surface_t *thumbnail;
256 cairo_t *cr;
257 double ratio;
258 int width, height, scale;
259
260 win = wnck_window_get_xid (wnck_window);
261
262 if ((window = gdk_x11_window_foreign_new_for_display (gdk_display_get_default (), win)) == NULL((void*)0))
263 {
264 return NULL((void*)0);
265 }
266
267 *thumbnail_scale = scale = gdk_window_get_scale_factor (window);
268 width = gdk_window_get_width (window) * scale;
269 height = gdk_window_get_height (window) * scale;
270
271 /* Scale to configured size while maintaining aspect ratio */
272 if (width > height)
273 {
274 int max_size = MIN (width, tasklist->thumbnail_size * scale)(((width) < (tasklist->thumbnail_size * scale)) ? (width
) : (tasklist->thumbnail_size * scale))
;
275 ratio = (double) max_size / (double) width;
276 *thumbnail_width = max_size;
277 *thumbnail_height = (int) ((double) height * ratio);
278 }
279 else
280 {
281 int max_size = MIN (height, tasklist->thumbnail_size * scale)(((height) < (tasklist->thumbnail_size * scale)) ? (height
) : (tasklist->thumbnail_size * scale))
;
282 ratio = (double) max_size / (double) height;
283 *thumbnail_height = max_size;
284 *thumbnail_width = (int) ((double) width * ratio);
285 }
286
287 gdk_x11_display_error_trap_push (gdk_window_get_display (window));
288
289 thumbnail = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
290 *thumbnail_width,
291 *thumbnail_height);
292 cairo_surface_set_device_scale (thumbnail, scale, scale);
293 cr = cairo_create (thumbnail);
294 cairo_scale (cr, ratio, ratio);
295 gdk_cairo_set_source_window (cr, window, 0, 0);
296 cairo_paint (cr);
297 cairo_destroy (cr);
298
299 if (gdk_x11_display_error_trap_pop (gdk_window_get_display (window)))
300 {
301 cairo_surface_destroy (thumbnail);
302 thumbnail = NULL((void*)0);
303 }
304
305 g_object_unref (window);
306
307 return thumbnail;
308}
309
310static int g_int_compare(gconstpointer a, gconstpointer b)
311{
312 gint a_val = GPOINTER_TO_INT(a)((gint) (glong) (a));
313 gint b_val = GPOINTER_TO_INT(b)((gint) (glong) (b));
314 if (a_val > b_val) return -1;
315 if (a_val == b_val) return 0;
316 return 1;
317}
318
319static int find_offset(GList *list, gdouble target)
320{
321 GList *node = list;
322 while (node != NULL((void*)0)) {
323 int value = GPOINTER_TO_INT(node->data)((gint) (glong) (node->data));
324 if (value <= target)
325 return value;
326 node = node->next;
327 }
328 return -1;
329}
330
331#define PREVIEW_PADDING5 5
332static void
333preview_window_reposition (WnckTasklist *tl,
334 TasklistData *tasklist,
335 int width,
336 int height,
337 int scale)
338{
339 /* Known issues:
340 * - When grouping is toggled the previews won't be centered correctly until a new window is opened or one is closed.
341 * - Previews are not shown at all for grouped windows, this function is not called when hovering over those.
342 */
343
344 GdkMonitor *monitor;
345 GdkRectangle monitor_geom;
346 MatePanelAppletOrient orient;
347 gdouble x_pos, y_pos;
348 int x_offset, y_offset;
349
350 /* Get mouse position */
351 gdk_device_get_position_double (gdk_seat_get_pointer (gdk_display_get_default_seat (gdk_display_get_default ())), NULL((void*)0), &x_pos, &y_pos);
352
353 /* Get geometry of monitor where tasklist is located to calculate correct position of preview */
354 monitor = gdk_display_get_monitor_at_point (gdk_display_get_default (), x_pos, y_pos);
355 gdk_monitor_get_geometry (monitor, &monitor_geom);
356
357 /* Get the position where the window list applet starts */
358 gdk_window_get_origin (gtk_widget_get_window (gtk_widget_get_parent (GTK_WIDGET(tl)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tl)), ((gtk_widget_get_type ()))))))
)), &x_offset, &y_offset);
359
360 /* Get panel orientation */
361 orient = mate_panel_applet_get_orient (MATE_PANEL_APPLET (tasklist->applet));
362
363 /* Add padding to clear the panel */
364 switch (orient)
15
Control jumps to 'case MATE_PANEL_APPLET_ORIENT_DOWN:' at line 375
365 {
366 case MATE_PANEL_APPLET_ORIENT_LEFT:
367 x_pos = monitor_geom.width + monitor_geom.x - width - tasklist->size - PREVIEW_PADDING5;
368 break;
369 case MATE_PANEL_APPLET_ORIENT_RIGHT:
370 x_pos = tasklist->size + PREVIEW_PADDING5;
371 break;
372 case MATE_PANEL_APPLET_ORIENT_UP:
373 y_pos = monitor_geom.height + monitor_geom.y - height - tasklist->size - PREVIEW_PADDING5;
374 break;
375 case MATE_PANEL_APPLET_ORIENT_DOWN:
376 default:
377 y_pos = tasklist->size + PREVIEW_PADDING5;
378 break;
379 }
380
381 /* Collect the allocation.x/y values of each button into lists.
382 * We need to iterate over all of them because grouped buttons will be the last children,
383 * even though they are positioned at the beginning. And not all buttons will have the exact same width.
384 * This allows us to avoid off-by-one errors that would cause the preview to be positioned over the adjacent button. */
385 GList *alloc_x_list = NULL((void*)0);
16
Execution continues on line 385
386 GList *alloc_y_list = NULL((void*)0);
387 GtkAllocation last_alloc;
388 GList* children = gtk_container_get_children (GTK_CONTAINER(tl)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tl)), ((gtk_container_get_type ()))))))
);
389 while (children != NULL((void*)0))
17
Assuming 'children' is equal to NULL
390 {
391 if (g_strcmp0 (gtk_widget_get_name (children->data), "tasklist-button") == 0) {
392 GtkAllocation alloc;
393 gtk_widget_get_allocation (children->data, &alloc);
394
395 /* Skip grouped buttons: these usually have alloc width/heigh=1, except right after grouping is toggled.
396 * Then simply open or close a new window to get the correct offset. */
397 if (alloc.width < 2 || alloc.height < 2)
398 {
399 children = children->next;
400 continue;
401 }
402
403 /* Keep x and y offsets in sorted lists */
404 alloc_x_list = g_list_insert_sorted (alloc_x_list, GINT_TO_POINTER(alloc.x)((gpointer) (glong) (alloc.x)), g_int_compare);
405 alloc_y_list = g_list_insert_sorted (alloc_y_list, GINT_TO_POINTER(alloc.y)((gpointer) (glong) (alloc.y)), g_int_compare);
406
407 /* The width/height from the last allocation will be used for centering the preview.
408 * It might be off by a pixel because not all buttons have the exact same width/height but this isn't critical. */
409 last_alloc = alloc;
410 }
411 children = children->next;
412 }
413
414 /* Center preview at the midpoint of the tasklist button */
415 if (orient
17.1
'orient' is not equal to MATE_PANEL_APPLET_ORIENT_LEFT
== MATE_PANEL_APPLET_ORIENT_LEFT || orient
17.2
'orient' is not equal to MATE_PANEL_APPLET_ORIENT_RIGHT
== MATE_PANEL_APPLET_ORIENT_RIGHT)
416 {
417 /* Vertical panel */
418 y_pos = y_offset + find_offset (alloc_y_list, y_pos - y_offset) + (last_alloc.height - height) / 2;
419 y_pos = y_pos < PREVIEW_PADDING5 ? PREVIEW_PADDING5 : y_pos;
420 }
421 else if (orient
17.3
'orient' is not equal to MATE_PANEL_APPLET_ORIENT_UP
== MATE_PANEL_APPLET_ORIENT_UP || orient
17.4
'orient' is equal to MATE_PANEL_APPLET_ORIENT_DOWN
== MATE_PANEL_APPLET_ORIENT_DOWN)
18
Taking true branch
422 {
423 /* Horizontal panel */
424 x_pos = x_offset + find_offset (alloc_x_list, x_pos - x_offset) + (last_alloc.width - width) / 2;
19
The left operand of '-' is a garbage value
425 x_pos = x_pos < PREVIEW_PADDING5 ? PREVIEW_PADDING5 : x_pos;
426 }
427
428 g_list_free (alloc_x_list);
429 g_list_free (alloc_y_list);
430
431 gtk_window_move (GTK_WINDOW (tasklist->preview)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tasklist->preview)), ((gtk_window_get_type ()))))))
, x_pos, y_pos);
432}
433
434static gboolean preview_window_draw (GtkWidget *widget, cairo_t *cr, cairo_surface_t *thumbnail)
435{
436 GtkStyleContext *context;
437
438 context = gtk_widget_get_style_context (widget);
439 gtk_render_icon_surface (context, cr, thumbnail, 0, 0);
440
441 return FALSE(0);
442}
443
444static gboolean applet_enter_notify_event (WnckTasklist *tl, GList *wnck_windows, TasklistData *tasklist)
445{
446 cairo_surface_t *thumbnail;
447 WnckWindow *wnck_window = NULL((void*)0);
448 int n_windows;
449 int thumbnail_width;
450 int thumbnail_height;
451 int thumbnail_scale;
452
453 if (tasklist->preview != NULL((void*)0))
1
Assuming field 'preview' is equal to NULL
454 {
455 gtk_widget_destroy (tasklist->preview);
456 tasklist->preview = NULL((void*)0);
457 }
458
459 if (!tasklist->show_window_thumbnails || wnck_windows == NULL((void*)0))
2
Assuming field 'show_window_thumbnails' is not equal to 0
3
Assuming 'wnck_windows' is not equal to NULL
4
Taking false branch
460 return FALSE(0);
461
462 n_windows = g_list_length (wnck_windows);
463 /* TODO: Display a list of stacked thumbnails for grouped windows. */
464 if (n_windows == 1)
5
Assuming 'n_windows' is equal to 1
6
Taking true branch
465 {
466 GList* l = wnck_windows;
467 if (l
6.1
'l' is not equal to NULL
!= NULL((void*)0))
7
Taking true branch
468 wnck_window = (WnckWindow*)l->data;
469 }
470
471 if (wnck_window == NULL((void*)0))
8
Assuming 'wnck_window' is not equal to NULL
9
Taking false branch
472 return FALSE(0);
473
474 /* Do not show preview if window is not visible nor in current workspace */
475 if (!wnck_window_is_visible_on_workspace (wnck_window,
10
Assuming the condition is false
11
Taking false branch
476 wnck_screen_get_active_workspace (wnck_screen_get_default ())))
477 return FALSE(0);
478
479 thumbnail = preview_window_thumbnail (wnck_window, tasklist, &thumbnail_width, &thumbnail_height, &thumbnail_scale);
480
481 if (thumbnail == NULL((void*)0))
12
Assuming 'thumbnail' is not equal to NULL
13
Taking false branch
482 return FALSE(0);
483
484 /* Create window to display preview */
485 tasklist->preview = gtk_window_new (GTK_WINDOW_POPUP);
486
487 gtk_widget_set_app_paintable (tasklist->preview, TRUE(!(0)));
488 gtk_window_set_default_size (GTK_WINDOW (tasklist->preview)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tasklist->preview)), ((gtk_window_get_type ()))))))
, thumbnail_width/thumbnail_scale, thumbnail_height/thumbnail_scale);
489 gtk_window_set_resizable (GTK_WINDOW (tasklist->preview)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tasklist->preview)), ((gtk_window_get_type ()))))))
, TRUE(!(0)));
490 preview_window_reposition (tl, tasklist, thumbnail_width/thumbnail_scale, thumbnail_height/thumbnail_scale, thumbnail_scale);
14
Calling 'preview_window_reposition'
491
492 gtk_widget_show (tasklist->preview);
493
494 g_signal_connect_data (tasklist->preview, "draw",
495 G_CALLBACK (preview_window_draw)((GCallback) (preview_window_draw)), thumbnail,
496 (GClosureNotify) G_CALLBACK (cairo_surface_destroy)((GCallback) (cairo_surface_destroy)),
497 0);
498
499 return FALSE(0);
500}
501
502static gboolean applet_leave_notify_event (WnckTasklist *tl, GList *wnck_windows, TasklistData *tasklist)
503{
504 if (tasklist->preview != NULL((void*)0))
505 {
506 gtk_widget_destroy (tasklist->preview);
507 tasklist->preview = NULL((void*)0);
508 }
509
510 return FALSE(0);
511}
512#endif /* HAVE_WINDOW_PREVIEWS */
513#endif /* HAVE_X11 */
514
515static void applet_change_pixel_size(MatePanelApplet* applet, gint size, TasklistData* tasklist)
516{
517 if (tasklist->size == size)
518 return;
519
520 tasklist->size = size;
521
522 tasklist_update(tasklist);
523}
524
525/* TODO: this is sad, should be used a function to retrieve applications from
526 * .desktop or some like that. */
527static const char* system_monitors[] = {
528 "mate-system-monitor",
529 "gnome-system-monitor",
530};
531
532static const GtkActionEntry tasklist_menu_actions[] = {
533 {
534 "TasklistSystemMonitor",
535 "utilities-system-monitor",
536 N_("_System Monitor")("_System Monitor"),
537 NULL((void*)0),
538 NULL((void*)0),
539 G_CALLBACK(call_system_monitor)((GCallback) (call_system_monitor))
540 },
541 {
542 "TasklistPreferences",
543 "document-properties",
544 N_("_Preferences")("_Preferences"),
545 NULL((void*)0),
546 NULL((void*)0),
547 G_CALLBACK(display_properties_dialog)((GCallback) (display_properties_dialog))
548 },
549 {
550 "TasklistHelp",
551 "help-browser",
552 N_("_Help")("_Help"),
553 NULL((void*)0),
554 NULL((void*)0),
555 G_CALLBACK(display_help_dialog)((GCallback) (display_help_dialog))
556 },
557 {
558 "TasklistAbout",
559 "help-about",
560 N_("_About")("_About"),
561 NULL((void*)0),
562 NULL((void*)0),
563 G_CALLBACK(display_about_dialog)((GCallback) (display_about_dialog))
564 }
565};
566
567static void tasklist_properties_update_content_radio(TasklistData* tasklist)
568{
569 GtkWidget* button;
570
571 if (tasklist->show_current_radio == NULL((void*)0))
572 return;
573
574 if (tasklist->include_all_workspaces)
575 {
576 button = tasklist->show_all_radio;
577 }
578 else
579 {
580 button = tasklist->show_current_radio;
581 }
582
583 if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), ((gtk_toggle_button_get_type ()))))))
))
584 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button)((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), ((gtk_toggle_button_get_type ()))))))
, TRUE(!(0)));
585
586 gtk_widget_set_sensitive(tasklist->minimized_windows_box, tasklist->include_all_workspaces);
587}
588
589static void display_all_workspaces_changed(GSettings* settings, gchar* key, TasklistData* tasklist)
590{
591 gboolean value;
592
593 value = g_settings_get_boolean(settings, key);
594
595 tasklist->include_all_workspaces = (value != 0);
596 tasklist_update(tasklist);
597
598 tasklist_properties_update_content_radio(tasklist);
599}
600
601#ifdef HAVE_WINDOW_PREVIEWS1
602static void tasklist_update_thumbnail_size_spin(TasklistData* tasklist)
603{
604 GtkWidget* button;
605
606 if (!tasklist->thumbnail_size)
607 return;
608
609 button = tasklist->thumbnail_size_spin;
610
611 gtk_spin_button_set_value(GTK_SPIN_BUTTON(button)((((GtkSpinButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), ((gtk_spin_button_get_type ()))))))
, (gdouble)tasklist->thumbnail_size);
612}
613
614static void show_thumbnails_changed(GSettings* settings, gchar* key, TasklistData* tasklist)
615{
616 tasklist->show_window_thumbnails = g_settings_get_boolean (settings, key);
617}
618
619static void thumbnail_size_changed(GSettings *settings, gchar* key, TasklistData* tasklist)
620{
621 tasklist->thumbnail_size = g_settings_get_int(settings, key);
622 tasklist_update_thumbnail_size_spin(tasklist);
623}
624#endif
625
626static GtkWidget* get_grouping_button(TasklistData* tasklist, TasklistGroupingType type)
627{
628 switch (type)
629 {
630 default:
631 case TASKLIST_NEVER_GROUP:
632 return tasklist->never_group_radio;
633 break;
634 case TASKLIST_AUTO_GROUP:
635 return tasklist->auto_group_radio;
636 break;
637 case TASKLIST_ALWAYS_GROUP:
638 return tasklist->always_group_radio;
639 break;
640 }
641}
642
643static void group_windows_changed(GSettings* settings, gchar* key, TasklistData* tasklist)
644{
645 TasklistGroupingType type;
646 GtkWidget* button;
647
648 type = g_settings_get_enum (settings, key);
649
650 tasklist->grouping = type;
651 tasklist_update(tasklist);
652
653 button = get_grouping_button(tasklist, type);
654
655 if (button && !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), ((gtk_toggle_button_get_type ()))))))
))
656 {
657 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button)((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), ((gtk_toggle_button_get_type ()))))))
, TRUE(!(0)));
658 }
659}
660
661static void tasklist_update_unminimization_radio(TasklistData* tasklist)
662{
663 GtkWidget* button;
664
665 if (tasklist->move_minimized_radio == NULL((void*)0))
666 return;
667
668 if (tasklist->move_unminimized_windows)
669 {
670 button = tasklist->move_minimized_radio;
671 }
672 else
673 {
674 button = tasklist->change_workspace_radio;
675 }
676
677 if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), ((gtk_toggle_button_get_type ()))))))
))
678 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button)((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), ((gtk_toggle_button_get_type ()))))))
, TRUE(!(0)));
679}
680
681static void move_unminimized_windows_changed(GSettings* settings, gchar* key, TasklistData* tasklist)
682{
683 gboolean value;
684
685 value = g_settings_get_boolean(settings, key);
686
687 tasklist->move_unminimized_windows = (value != 0);
688 tasklist_update(tasklist);
689
690 tasklist_update_unminimization_radio(tasklist);
691}
692
693static void scroll_enabled_changed (GSettings* settings, gchar* key, TasklistData* tasklist)
694{
695 tasklist->scroll_enable = g_settings_get_boolean (settings, key);
696 tasklist_update(tasklist);
697}
698
699static void middle_click_close_changed (GSettings* settings, gchar* key, TasklistData* tasklist)
700{
701 tasklist->middle_click_close = g_settings_get_boolean (settings, key);
702 tasklist_update(tasklist);
703}
704
705static void setup_gsettings(TasklistData* tasklist)
706{
707 tasklist->settings = mate_panel_applet_settings_new (MATE_PANEL_APPLET (tasklist->applet), WINDOW_LIST_SCHEMA"org.mate.panel.applet.window-list");
708
709 g_signal_connect (tasklist->settings,g_signal_connect_data ((tasklist->settings), ("changed::display-all-workspaces"
), (((GCallback) (display_all_workspaces_changed))), (tasklist
), ((void*)0), (GConnectFlags) 0)
710 "changed::display-all-workspaces",g_signal_connect_data ((tasklist->settings), ("changed::display-all-workspaces"
), (((GCallback) (display_all_workspaces_changed))), (tasklist
), ((void*)0), (GConnectFlags) 0)
711 G_CALLBACK (display_all_workspaces_changed),g_signal_connect_data ((tasklist->settings), ("changed::display-all-workspaces"
), (((GCallback) (display_all_workspaces_changed))), (tasklist
), ((void*)0), (GConnectFlags) 0)
712 tasklist)g_signal_connect_data ((tasklist->settings), ("changed::display-all-workspaces"
), (((GCallback) (display_all_workspaces_changed))), (tasklist
), ((void*)0), (GConnectFlags) 0)
;
713
714#ifdef HAVE_WINDOW_PREVIEWS1
715 tasklist->preview_settings = mate_panel_applet_settings_new (MATE_PANEL_APPLET (tasklist->applet), WINDOW_LIST_PREVIEW_SCHEMA"org.mate.panel.applet.window-list-previews");
716
717 g_signal_connect (tasklist->preview_settings,g_signal_connect_data ((tasklist->preview_settings), ("changed::show-window-thumbnails"
), (((GCallback) (show_thumbnails_changed))), (tasklist), ((void
*)0), (GConnectFlags) 0)
718 "changed::show-window-thumbnails",g_signal_connect_data ((tasklist->preview_settings), ("changed::show-window-thumbnails"
), (((GCallback) (show_thumbnails_changed))), (tasklist), ((void
*)0), (GConnectFlags) 0)
719 G_CALLBACK (show_thumbnails_changed),g_signal_connect_data ((tasklist->preview_settings), ("changed::show-window-thumbnails"
), (((GCallback) (show_thumbnails_changed))), (tasklist), ((void
*)0), (GConnectFlags) 0)
720 tasklist)g_signal_connect_data ((tasklist->preview_settings), ("changed::show-window-thumbnails"
), (((GCallback) (show_thumbnails_changed))), (tasklist), ((void
*)0), (GConnectFlags) 0)
;
721
722 g_signal_connect (tasklist->preview_settings,g_signal_connect_data ((tasklist->preview_settings), ("changed::thumbnail-window-size"
), (((GCallback) (thumbnail_size_changed))), (tasklist), ((void
*)0), (GConnectFlags) 0)
723 "changed::thumbnail-window-size",g_signal_connect_data ((tasklist->preview_settings), ("changed::thumbnail-window-size"
), (((GCallback) (thumbnail_size_changed))), (tasklist), ((void
*)0), (GConnectFlags) 0)
724 G_CALLBACK (thumbnail_size_changed),g_signal_connect_data ((tasklist->preview_settings), ("changed::thumbnail-window-size"
), (((GCallback) (thumbnail_size_changed))), (tasklist), ((void
*)0), (GConnectFlags) 0)
725 tasklist)g_signal_connect_data ((tasklist->preview_settings), ("changed::thumbnail-window-size"
), (((GCallback) (thumbnail_size_changed))), (tasklist), ((void
*)0), (GConnectFlags) 0)
;
726#endif
727 g_signal_connect (tasklist->settings,g_signal_connect_data ((tasklist->settings), ("changed::group-windows"
), (((GCallback) (group_windows_changed))), (tasklist), ((void
*)0), (GConnectFlags) 0)
728 "changed::group-windows",g_signal_connect_data ((tasklist->settings), ("changed::group-windows"
), (((GCallback) (group_windows_changed))), (tasklist), ((void
*)0), (GConnectFlags) 0)
729 G_CALLBACK (group_windows_changed),g_signal_connect_data ((tasklist->settings), ("changed::group-windows"
), (((GCallback) (group_windows_changed))), (tasklist), ((void
*)0), (GConnectFlags) 0)
730 tasklist)g_signal_connect_data ((tasklist->settings), ("changed::group-windows"
), (((GCallback) (group_windows_changed))), (tasklist), ((void
*)0), (GConnectFlags) 0)
;
731 g_signal_connect (tasklist->settings,g_signal_connect_data ((tasklist->settings), ("changed::move-unminimized-windows"
), (((GCallback) (move_unminimized_windows_changed))), (tasklist
), ((void*)0), (GConnectFlags) 0)
732 "changed::move-unminimized-windows",g_signal_connect_data ((tasklist->settings), ("changed::move-unminimized-windows"
), (((GCallback) (move_unminimized_windows_changed))), (tasklist
), ((void*)0), (GConnectFlags) 0)
733 G_CALLBACK (move_unminimized_windows_changed),g_signal_connect_data ((tasklist->settings), ("changed::move-unminimized-windows"
), (((GCallback) (move_unminimized_windows_changed))), (tasklist
), ((void*)0), (GConnectFlags) 0)
734 tasklist)g_signal_connect_data ((tasklist->settings), ("changed::move-unminimized-windows"
), (((GCallback) (move_unminimized_windows_changed))), (tasklist
), ((void*)0), (GConnectFlags) 0)
;
735 g_signal_connect (tasklist->settings,g_signal_connect_data ((tasklist->settings), ("changed::scroll-enabled"
), (((GCallback) (scroll_enabled_changed))), (tasklist), ((void
*)0), (GConnectFlags) 0)
736 "changed::scroll-enabled",g_signal_connect_data ((tasklist->settings), ("changed::scroll-enabled"
), (((GCallback) (scroll_enabled_changed))), (tasklist), ((void
*)0), (GConnectFlags) 0)
737 G_CALLBACK (scroll_enabled_changed),g_signal_connect_data ((tasklist->settings), ("changed::scroll-enabled"
), (((GCallback) (scroll_enabled_changed))), (tasklist), ((void
*)0), (GConnectFlags) 0)
738 tasklist)g_signal_connect_data ((tasklist->settings), ("changed::scroll-enabled"
), (((GCallback) (scroll_enabled_changed))), (tasklist), ((void
*)0), (GConnectFlags) 0)
;
739 g_signal_connect (tasklist->settings,g_signal_connect_data ((tasklist->settings), ("changed::middle-click-close"
), (((GCallback) (middle_click_close_changed))), (tasklist), (
(void*)0), (GConnectFlags) 0)
740 "changed::middle-click-close",g_signal_connect_data ((tasklist->settings), ("changed::middle-click-close"
), (((GCallback) (middle_click_close_changed))), (tasklist), (
(void*)0), (GConnectFlags) 0)
741 G_CALLBACK (middle_click_close_changed),g_signal_connect_data ((tasklist->settings), ("changed::middle-click-close"
), (((GCallback) (middle_click_close_changed))), (tasklist), (
(void*)0), (GConnectFlags) 0)
742 tasklist)g_signal_connect_data ((tasklist->settings), ("changed::middle-click-close"
), (((GCallback) (middle_click_close_changed))), (tasklist), (
(void*)0), (GConnectFlags) 0)
;
743}
744
745static void applet_size_allocate(GtkWidget *widget, GtkAllocation *allocation, TasklistData *tasklist)
746{
747 int len;
748 const int* size_hints;
749
750 size_hints = tasklist_get_size_hint_list (tasklist, &len);
751
752 g_assert(len % 2 == 0)do { if (len % 2 == 0) ; else g_assertion_message_expr (((gchar
*) 0), "window-list.c", 752, ((const char*) (__func__)), "len % 2 == 0"
); } while (0)
;
753
754#if !defined(WNCKLET_INPROCESS1) && !GTK_CHECK_VERSION (3, 23, 0)((3) > (3) || ((3) == (3) && (24) > (23)) || ((
3) == (3) && (24) == (23) && (42) >= (0)))
755 /* HACK: When loading the WnckTasklist initially, it reports size hints as though there were
756 * no elements in the Tasklist. This causes a rendering issue when built out-of-process in
757 * HiDPI displays. We keep a flag to skip size hinting until WnckTasklist has something to
758 * show. */
759 if (!tasklist->needs_hints)
760 {
761 int i;
762 for (i = 0; i < len; i++)
763 {
764 if (size_hints[i])
765 {
766 tasklist->needs_hints = TRUE(!(0));
767 break;
768 }
769 }
770 }
771
772 if (tasklist->needs_hints)
773#endif
774 mate_panel_applet_set_size_hints(MATE_PANEL_APPLET(tasklist->applet), size_hints, len, 0);
775}
776
777gboolean window_list_applet_fill(MatePanelApplet* applet)
778{
779 TasklistData* tasklist;
780 GtkActionGroup* action_group;
781 GtkCssProvider *provider;
782 GdkScreen *screen;
783
784 tasklist = g_new0(TasklistData, 1)((TasklistData *) g_malloc0_n ((1), sizeof (TasklistData)));
785
786 tasklist->applet = GTK_WIDGET(applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
;
787
788 provider = gtk_css_provider_new ();
789 screen = gdk_screen_get_default ();
790 gtk_css_provider_load_from_data (provider,
791 ".mate-panel-menu-bar button,\n"
792 " #tasklist-button {\n"
793 " padding: 0px;\n"
794 " margin: 0px;\n }",
795 -1, NULL((void*)0));
796 gtk_style_context_add_provider_for_screen (screen,
797 GTK_STYLE_PROVIDER (provider)((((GtkStyleProvider*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((provider)), ((gtk_style_provider_get_type (
)))))))
,
798 GTK_STYLE_PROVIDER_PRIORITY_APPLICATION600);
799 g_object_unref (provider);
800
801 mate_panel_applet_set_flags(MATE_PANEL_APPLET(tasklist->applet), MATE_PANEL_APPLET_EXPAND_MAJOR | MATE_PANEL_APPLET_EXPAND_MINOR | MATE_PANEL_APPLET_HAS_HANDLE);
802
803 setup_gsettings(tasklist);
804
805 tasklist->include_all_workspaces = g_settings_get_boolean (tasklist->settings, "display-all-workspaces");
806
807#ifdef HAVE_WINDOW_PREVIEWS1
808 tasklist->show_window_thumbnails = g_settings_get_boolean (tasklist->preview_settings, "show-window-thumbnails");
809
810 tasklist->thumbnail_size = g_settings_get_int (tasklist->preview_settings, "thumbnail-window-size");
811#endif
812
813 tasklist->grouping = g_settings_get_enum (tasklist->settings, "group-windows");
814
815 tasklist->move_unminimized_windows = g_settings_get_boolean (tasklist->settings, "move-unminimized-windows");
816
817 tasklist->scroll_enable = g_settings_get_boolean (tasklist->settings, "scroll-enabled");
818
819 tasklist->middle_click_close = g_settings_get_boolean (tasklist->settings, "middle-click-close");
820
821 tasklist->size = mate_panel_applet_get_size(applet);
822
823#if !defined(WNCKLET_INPROCESS1) && !GTK_CHECK_VERSION (3, 23, 0)((3) > (3) || ((3) == (3) && (24) > (23)) || ((
3) == (3) && (24) == (23) && (42) >= (0)))
824 tasklist->needs_hints = FALSE(0);
825#endif
826
827 switch (mate_panel_applet_get_orient(applet))
828 {
829 case MATE_PANEL_APPLET_ORIENT_LEFT:
830 case MATE_PANEL_APPLET_ORIENT_RIGHT:
831 tasklist->orientation = GTK_ORIENTATION_VERTICAL;
832 break;
833 case MATE_PANEL_APPLET_ORIENT_UP:
834 case MATE_PANEL_APPLET_ORIENT_DOWN:
835 default:
836 tasklist->orientation = GTK_ORIENTATION_HORIZONTAL;
837 break;
838 }
839
840#ifdef HAVE_X111
841 if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gdk_display_get_default ())); GType __t = ((gdk_x11_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
)
842 {
843 tasklist->tasklist = wnck_tasklist_new();
844
845#ifdef HAVE_WINDOW_PREVIEWS1
846 g_signal_connect (tasklist->tasklist, "task-enter-notify",g_signal_connect_data ((tasklist->tasklist), ("task-enter-notify"
), (((GCallback) (applet_enter_notify_event))), (tasklist), (
(void*)0), (GConnectFlags) 0)
847 G_CALLBACK (applet_enter_notify_event),g_signal_connect_data ((tasklist->tasklist), ("task-enter-notify"
), (((GCallback) (applet_enter_notify_event))), (tasklist), (
(void*)0), (GConnectFlags) 0)
848 tasklist)g_signal_connect_data ((tasklist->tasklist), ("task-enter-notify"
), (((GCallback) (applet_enter_notify_event))), (tasklist), (
(void*)0), (GConnectFlags) 0)
;
849 g_signal_connect (tasklist->tasklist, "task-leave-notify",g_signal_connect_data ((tasklist->tasklist), ("task-leave-notify"
), (((GCallback) (applet_leave_notify_event))), (tasklist), (
(void*)0), (GConnectFlags) 0)
850 G_CALLBACK (applet_leave_notify_event),g_signal_connect_data ((tasklist->tasklist), ("task-leave-notify"
), (((GCallback) (applet_leave_notify_event))), (tasklist), (
(void*)0), (GConnectFlags) 0)
851 tasklist)g_signal_connect_data ((tasklist->tasklist), ("task-leave-notify"
), (((GCallback) (applet_leave_notify_event))), (tasklist), (
(void*)0), (GConnectFlags) 0)
;
852#endif /* HAVE_WINDOW_PREVIEWS */
853 }
854 else
855#endif /* HAVE_X11 */
856
857#ifdef HAVE_WAYLAND1
858 if (GDK_IS_WAYLAND_DISPLAY (gdk_display_get_default ())(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gdk_display_get_default ())); GType __t = ((gdk_wayland_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
)
859 {
860 tasklist->tasklist = wayland_tasklist_new();
861 }
862 else
863#endif /* HAVE_WAYLAND */
864
865 {
866 tasklist->tasklist = gtk_label_new ("[Tasklist not supported on this platform]");
867 }
868
869 tasklist_apply_orientation(tasklist);
870
871 g_signal_connect (tasklist->tasklist, "destroy",g_signal_connect_data ((tasklist->tasklist), ("destroy"), (
((GCallback) (destroy_tasklist))), (tasklist), ((void*)0), (GConnectFlags
) 0)
872 G_CALLBACK (destroy_tasklist),g_signal_connect_data ((tasklist->tasklist), ("destroy"), (
((GCallback) (destroy_tasklist))), (tasklist), ((void*)0), (GConnectFlags
) 0)
873 tasklist)g_signal_connect_data ((tasklist->tasklist), ("destroy"), (
((GCallback) (destroy_tasklist))), (tasklist), ((void*)0), (GConnectFlags
) 0)
;
874 g_signal_connect (tasklist->applet, "size-allocate",g_signal_connect_data ((tasklist->applet), ("size-allocate"
), (((GCallback) (applet_size_allocate))), (tasklist), ((void
*)0), (GConnectFlags) 0)
875 G_CALLBACK (applet_size_allocate),g_signal_connect_data ((tasklist->applet), ("size-allocate"
), (((GCallback) (applet_size_allocate))), (tasklist), ((void
*)0), (GConnectFlags) 0)
876 tasklist)g_signal_connect_data ((tasklist->applet), ("size-allocate"
), (((GCallback) (applet_size_allocate))), (tasklist), ((void
*)0), (GConnectFlags) 0)
;
877
878 gtk_container_add(GTK_CONTAINER(tasklist->applet)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tasklist->applet)), ((gtk_container_get_type ()))))))
, tasklist->tasklist);
879
880 g_signal_connect (tasklist->applet, "change-orient",g_signal_connect_data ((tasklist->applet), ("change-orient"
), (((GCallback) (applet_change_orient))), (tasklist), ((void
*)0), (GConnectFlags) 0)
881 G_CALLBACK (applet_change_orient),g_signal_connect_data ((tasklist->applet), ("change-orient"
), (((GCallback) (applet_change_orient))), (tasklist), ((void
*)0), (GConnectFlags) 0)
882 tasklist)g_signal_connect_data ((tasklist->applet), ("change-orient"
), (((GCallback) (applet_change_orient))), (tasklist), ((void
*)0), (GConnectFlags) 0)
;
883 g_signal_connect (tasklist->applet, "change-size",g_signal_connect_data ((tasklist->applet), ("change-size")
, (((GCallback) (applet_change_pixel_size))), (tasklist), ((void
*)0), (GConnectFlags) 0)
884 G_CALLBACK (applet_change_pixel_size),g_signal_connect_data ((tasklist->applet), ("change-size")
, (((GCallback) (applet_change_pixel_size))), (tasklist), ((void
*)0), (GConnectFlags) 0)
885 tasklist)g_signal_connect_data ((tasklist->applet), ("change-size")
, (((GCallback) (applet_change_pixel_size))), (tasklist), ((void
*)0), (GConnectFlags) 0)
;
886 g_signal_connect (tasklist->applet, "change-background",g_signal_connect_data ((tasklist->applet), ("change-background"
), (((GCallback) (applet_change_background))), (tasklist), ((
void*)0), (GConnectFlags) 0)
887 G_CALLBACK(applet_change_background),g_signal_connect_data ((tasklist->applet), ("change-background"
), (((GCallback) (applet_change_background))), (tasklist), ((
void*)0), (GConnectFlags) 0)
888 tasklist)g_signal_connect_data ((tasklist->applet), ("change-background"
), (((GCallback) (applet_change_background))), (tasklist), ((
void*)0), (GConnectFlags) 0)
;
889
890 action_group = gtk_action_group_new("Tasklist Applet Actions");
891 gtk_action_group_set_translation_domain(action_group, GETTEXT_PACKAGE"mate-panel");
892 gtk_action_group_add_actions(action_group, tasklist_menu_actions, G_N_ELEMENTS(tasklist_menu_actions)(sizeof (tasklist_menu_actions) / sizeof ((tasklist_menu_actions
)[0]))
, tasklist);
893
894 /* disable the item of system monitor, if not exists.
895 * example, mate-system-monitor, o gnome-system-monitor */
896 char* programpath;
897 gsize i;
898
899 for (i = 0; i < G_N_ELEMENTS(system_monitors)(sizeof (system_monitors) / sizeof ((system_monitors)[0])); i += 1)
900 {
901 programpath = g_find_program_in_path(system_monitors[i]);
902
903 if (programpath != NULL((void*)0))
904 {
905 g_free(programpath);
906 /* we give up */
907 goto _system_monitor_found;
908 }
909
910 /* search another */
911 }
912
913 /* system monitor not found */
914 gtk_action_set_visible(gtk_action_group_get_action(action_group, "TasklistSystemMonitor"), FALSE(0));
915
916 _system_monitor_found:;
917 /* end of system monitor item */
918
919 mate_panel_applet_setup_menu_from_resource (MATE_PANEL_APPLET (tasklist->applet),
920 WNCKLET_RESOURCE_PATH"/org/mate/panel/applet/wncklet/" "window-list-menu.xml",
921 action_group);
922
923 if (mate_panel_applet_get_locked_down(MATE_PANEL_APPLET(tasklist->applet)))
924 {
925 GtkAction* action;
926
927 action = gtk_action_group_get_action(action_group, "TasklistPreferences");
928 gtk_action_set_visible(action, FALSE(0));
929 }
930
931 g_object_unref(action_group);
932
933 tasklist_update(tasklist);
934 gtk_widget_show(tasklist->tasklist);
935 gtk_widget_show(tasklist->applet);
936
937 return TRUE(!(0));
938}
939
940static void call_system_monitor(GtkAction* action, TasklistData* tasklist)
941{
942 gsize i;
943
944 for (i = 0; i < G_N_ELEMENTS(system_monitors)(sizeof (system_monitors) / sizeof ((system_monitors)[0])); i += 1)
945 {
946 char *programpath = g_find_program_in_path(system_monitors[i]);
947
948 if (programpath != NULL((void*)0))
949 {
950 g_free(programpath);
951
952 mate_gdk_spawn_command_line_on_screen(gtk_widget_get_screen(tasklist->applet),
953 system_monitors[i],
954 NULL((void*)0));
955 return;
956 }
957 }
958}
959
960static void display_help_dialog(GtkAction* action, TasklistData* tasklist)
961{
962 wncklet_display_help(tasklist->applet, "mate-user-guide", "windowlist", WINDOW_LIST_ICON"mate-panel-window-list");
963}
964
965static void display_about_dialog(GtkAction* action, TasklistData* tasklist)
966{
967 static const gchar* authors[] = {
968 "Perberos <perberos@gmail.com>",
969 "Steve Zesch <stevezesch2@gmail.com>",
970 "Stefano Karapetsas <stefano@karapetsas.com>",
971 "Alexander Larsson <alla@lysator.liu.se>",
972 NULL((void*)0)
973 };
974
975 const char* documenters [] = {
976 "Sun GNOME Documentation Team <gdocteam@sun.com>",
977 NULL((void*)0)
978 };
979
980 gtk_show_about_dialog(GTK_WINDOW(tasklist->applet)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tasklist->applet)), ((gtk_window_get_type ()))))))
,
981 "program-name", _("Window List")gettext ("Window List"),
982 "title", _("About Window List")gettext ("About Window List"),
983 "authors", authors,
984 "comments", _("The Window List shows a list of all windows in a set of buttons and lets you browse them.")gettext ("The Window List shows a list of all windows in a set of buttons and lets you browse them."
)
,
985 "copyright", _("Copyright \xc2\xa9 2002 Red Hat, Inc.\n"gettext ("Copyright \xc2\xa9 2002 Red Hat, Inc.\n" "Copyright \xc2\xa9 2011 Perberos\n"
"Copyright \xc2\xa9 2012-2021 MATE developers")
986 "Copyright \xc2\xa9 2011 Perberos\n"gettext ("Copyright \xc2\xa9 2002 Red Hat, Inc.\n" "Copyright \xc2\xa9 2011 Perberos\n"
"Copyright \xc2\xa9 2012-2021 MATE developers")
987 "Copyright \xc2\xa9 2012-2021 MATE developers")gettext ("Copyright \xc2\xa9 2002 Red Hat, Inc.\n" "Copyright \xc2\xa9 2011 Perberos\n"
"Copyright \xc2\xa9 2012-2021 MATE developers")
,
988 "documenters", documenters,
989 "icon-name", WINDOW_LIST_ICON"mate-panel-window-list",
990 "logo-icon-name", WINDOW_LIST_ICON"mate-panel-window-list",
991 "translator-credits", _("translator-credits")gettext ("translator-credits"),
992 "version", VERSION"1.29.0",
993 "website", PACKAGE_URL"https://mate-desktop.org",
994 NULL((void*)0));
995}
996
997static void group_windows_toggled(GtkToggleButton* button, TasklistData* tasklist)
998{
999 if (gtk_toggle_button_get_active(button))
1000 {
1001 gchar *value;
1002 value = g_object_get_data (G_OBJECT (button)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), (((GType) ((20) << (2))))))))
, "group_value");
1003 g_settings_set_string (tasklist->settings, "group-windows", value);
1004 }
1005}
1006
1007#ifdef HAVE_WINDOW_PREVIEWS1
1008static void thumbnail_size_spin_changed(GtkSpinButton* button, TasklistData* tasklist)
1009{
1010 g_settings_set_int(tasklist->preview_settings, "thumbnail-window-size", gtk_spin_button_get_value_as_int(button));
1011}
1012#endif
1013
1014static void move_minimized_toggled(GtkToggleButton* button, TasklistData* tasklist)
1015{
1016 g_settings_set_boolean(tasklist->settings, "move-unminimized-windows", gtk_toggle_button_get_active(button));
1017}
1018
1019static void display_all_workspaces_toggled(GtkToggleButton* button, TasklistData* tasklist)
1020{
1021 g_settings_set_boolean(tasklist->settings, "display-all-workspaces", gtk_toggle_button_get_active(button));
1022}
1023
1024#define WID(s)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object(builder, s))), ((gtk_widget_get_type
()))))))
GTK_WIDGET(gtk_builder_get_object(builder, s))((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object(builder, s))), ((gtk_widget_get_type
()))))))
1025
1026static void setup_sensitivity(TasklistData* tasklist, GtkBuilder* builder, const char* wid1, const char* wid2, const char* wid3, const char* key)
1027{
1028 GtkWidget* w;
1029
1030 if (g_settings_is_writable(tasklist->settings, key))
1031 {
1032 return;
1033 }
1034
1035 w = WID(wid1)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object(builder, wid1))), ((gtk_widget_get_type
()))))))
;
1036 g_assert(w != NULL)do { if (w != ((void*)0)) ; else g_assertion_message_expr (((
gchar*) 0), "window-list.c", 1036, ((const char*) (__func__))
, "w != NULL"); } while (0)
;
1037 gtk_widget_set_sensitive(w, FALSE(0));
1038
1039 if (wid2 != NULL((void*)0))
1040 {
1041 w = WID(wid2)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object(builder, wid2))), ((gtk_widget_get_type
()))))))
;
1042 g_assert(w != NULL)do { if (w != ((void*)0)) ; else g_assertion_message_expr (((
gchar*) 0), "window-list.c", 1042, ((const char*) (__func__))
, "w != NULL"); } while (0)
;
1043 gtk_widget_set_sensitive(w, FALSE(0));
1044 }
1045
1046 if (wid3 != NULL((void*)0))
1047 {
1048 w = WID(wid3)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object(builder, wid3))), ((gtk_widget_get_type
()))))))
;
1049 g_assert(w != NULL)do { if (w != ((void*)0)) ; else g_assertion_message_expr (((
gchar*) 0), "window-list.c", 1049, ((const char*) (__func__))
, "w != NULL"); } while (0)
;
1050 gtk_widget_set_sensitive(w, FALSE(0));
1051 }
1052}
1053
1054#ifdef HAVE_WAYLAND1
1055static void setup_dialog_wayland(TasklistData* tasklist)
1056{
1057 gtk_widget_show(tasklist->wayland_info_label);
1058
1059 gtk_widget_set_sensitive(tasklist->window_list_content_box, FALSE(0));
1060 gtk_widget_set_sensitive(tasklist->window_grouping_box, FALSE(0));
1061 gtk_widget_set_sensitive(tasklist->minimized_windows_box, FALSE(0));
1062
1063#ifdef HAVE_WINDOW_PREVIEWS1
1064 gtk_widget_set_sensitive(tasklist->window_thumbnail_box, FALSE(0));
1065#endif /* HAVE_WINDOW_PREVIEWS */
1066}
1067#endif /* HAVE_WAYLAND */
1068
1069static void setup_dialog(GtkBuilder* builder, TasklistData* tasklist)
1070{
1071 GtkWidget* button;
1072
1073 tasklist->wayland_info_label = WID("wayland_info_label")((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object(builder, "wayland_info_label"))),
((gtk_widget_get_type ()))))))
;
1074 tasklist->show_current_radio = WID("show_current_radio")((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object(builder, "show_current_radio"))),
((gtk_widget_get_type ()))))))
;
1075 tasklist->show_all_radio = WID("show_all_radio")((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object(builder, "show_all_radio"))), ((gtk_widget_get_type
()))))))
;
1076
1077 setup_sensitivity(tasklist, builder, "show_current_radio", "show_all_radio", NULL((void*)0), "display-all-workspaces" /* key */);
1078
1079 tasklist->never_group_radio = WID("never_group_radio")((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object(builder, "never_group_radio"))), (
(gtk_widget_get_type ()))))))
;
1080 tasklist->auto_group_radio = WID("auto_group_radio")((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object(builder, "auto_group_radio"))), (
(gtk_widget_get_type ()))))))
;
1081 tasklist->always_group_radio = WID("always_group_radio")((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object(builder, "always_group_radio"))),
((gtk_widget_get_type ()))))))
;
1082
1083 setup_sensitivity(tasklist, builder, "never_group_radio", "auto_group_radio", "always_group_radio", "group-windows" /* key */);
1084
1085#ifdef HAVE_WINDOW_PREVIEWS1
1086 tasklist->window_thumbnail_box = WID("window_thumbnail_box")((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object(builder, "window_thumbnail_box"))
), ((gtk_widget_get_type ()))))))
;
1087 tasklist->show_thumbnails_check = WID("show_thumbnails_check")((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object(builder, "show_thumbnails_check")
)), ((gtk_widget_get_type ()))))))
;
1088 tasklist->thumbnail_size_label = WID("thumbnail_size_label")((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object(builder, "thumbnail_size_label"))
), ((gtk_widget_get_type ()))))))
;
1089 tasklist->thumbnail_size_spin = WID("thumbnail_size_spin")((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object(builder, "thumbnail_size_spin")))
, ((gtk_widget_get_type ()))))))
;
1090
1091 g_settings_bind(tasklist->preview_settings, "show-window-thumbnails", tasklist->show_thumbnails_check, "active", G_SETTINGS_BIND_DEFAULT);
1092 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(tasklist->show_thumbnails_check)((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tasklist->show_thumbnails_check)), ((gtk_toggle_button_get_type
()))))))
)) {
1093 gtk_widget_set_sensitive (tasklist->thumbnail_size_label, TRUE(!(0)));
1094 gtk_widget_set_sensitive (tasklist->thumbnail_size_spin, TRUE(!(0)));
1095 } else {
1096 gtk_widget_set_sensitive (tasklist->thumbnail_size_label, FALSE(0));
1097 gtk_widget_set_sensitive (tasklist->thumbnail_size_spin, FALSE(0));
1098 }
1099 g_object_bind_property(tasklist->show_thumbnails_check, "active", tasklist->thumbnail_size_label, "sensitive", G_BINDING_DEFAULT);
1100 g_object_bind_property(tasklist->show_thumbnails_check, "active", tasklist->thumbnail_size_spin, "sensitive", G_BINDING_DEFAULT);
1101
1102#else
1103 gtk_widget_hide(WID("window_thumbnail_box")((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object(builder, "window_thumbnail_box"))
), ((gtk_widget_get_type ()))))))
);
1104#endif
1105
1106 tasklist->move_minimized_radio = WID("move_minimized_radio")((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object(builder, "move_minimized_radio"))
), ((gtk_widget_get_type ()))))))
;
1107 tasklist->change_workspace_radio = WID("change_workspace_radio")((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object(builder, "change_workspace_radio"
))), ((gtk_widget_get_type ()))))))
;
1108 tasklist->mouse_scroll_check = WID("mouse_scroll_check")((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object(builder, "mouse_scroll_check"))),
((gtk_widget_get_type ()))))))
;
1109 tasklist->middle_click_close_check = WID("middle_click_close_check")((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object(builder, "middle_click_close_check"
))), ((gtk_widget_get_type ()))))))
;
1110 tasklist->minimized_windows_box = WID("minimized_windows_box")((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object(builder, "minimized_windows_box")
)), ((gtk_widget_get_type ()))))))
;
1111 tasklist->window_grouping_box = WID("window_grouping_box")((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object(builder, "window_grouping_box")))
, ((gtk_widget_get_type ()))))))
;
1112 tasklist->window_list_content_box = WID("window_list_content_box")((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object(builder, "window_list_content_box"
))), ((gtk_widget_get_type ()))))))
;
1113
1114 setup_sensitivity(tasklist, builder, "move_minimized_radio", "change_workspace_radio", NULL((void*)0), "move-unminimized-windows" /* key */);
1115
1116 /* Window grouping: */
1117 button = get_grouping_button(tasklist, tasklist->grouping);
1118 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button)((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), ((gtk_toggle_button_get_type ()))))))
, TRUE(!(0)));
1119 g_object_set_data(G_OBJECT(tasklist->never_group_radio)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tasklist->never_group_radio)), (((GType) ((20) <<
(2))))))))
, "group_value", "never");
1120 g_object_set_data(G_OBJECT(tasklist->auto_group_radio)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tasklist->auto_group_radio)), (((GType) ((20) <<
(2))))))))
, "group_value", "auto");
1121 g_object_set_data(G_OBJECT(tasklist->always_group_radio)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tasklist->always_group_radio)), (((GType) ((20) <<
(2))))))))
, "group_value", "always");
1122
1123 g_signal_connect (tasklist->never_group_radio, "toggled",g_signal_connect_data ((tasklist->never_group_radio), ("toggled"
), ((GCallback) group_windows_toggled), (tasklist), ((void*)0
), (GConnectFlags) 0)
1124 (GCallback) group_windows_toggled,g_signal_connect_data ((tasklist->never_group_radio), ("toggled"
), ((GCallback) group_windows_toggled), (tasklist), ((void*)0
), (GConnectFlags) 0)
1125 tasklist)g_signal_connect_data ((tasklist->never_group_radio), ("toggled"
), ((GCallback) group_windows_toggled), (tasklist), ((void*)0
), (GConnectFlags) 0)
;
1126 g_signal_connect (tasklist->auto_group_radio, "toggled",g_signal_connect_data ((tasklist->auto_group_radio), ("toggled"
), ((GCallback) group_windows_toggled), (tasklist), ((void*)0
), (GConnectFlags) 0)
1127 (GCallback) group_windows_toggled,g_signal_connect_data ((tasklist->auto_group_radio), ("toggled"
), ((GCallback) group_windows_toggled), (tasklist), ((void*)0
), (GConnectFlags) 0)
1128 tasklist)g_signal_connect_data ((tasklist->auto_group_radio), ("toggled"
), ((GCallback) group_windows_toggled), (tasklist), ((void*)0
), (GConnectFlags) 0)
;
1129 g_signal_connect (tasklist->always_group_radio, "toggled",g_signal_connect_data ((tasklist->always_group_radio), ("toggled"
), ((GCallback) group_windows_toggled), (tasklist), ((void*)0
), (GConnectFlags) 0)
1130 (GCallback) group_windows_toggled,g_signal_connect_data ((tasklist->always_group_radio), ("toggled"
), ((GCallback) group_windows_toggled), (tasklist), ((void*)0
), (GConnectFlags) 0)
1131 tasklist)g_signal_connect_data ((tasklist->always_group_radio), ("toggled"
), ((GCallback) group_windows_toggled), (tasklist), ((void*)0
), (GConnectFlags) 0)
;
1132
1133 /* Mouse Scroll: */
1134 g_settings_bind (tasklist->settings,
1135 "scroll-enabled",
1136 tasklist->mouse_scroll_check,
1137 "active",
1138 G_SETTINGS_BIND_DEFAULT);
1139
1140 /* Middle mouse click to close window: */
1141 g_settings_bind (tasklist->settings,
1142 "middle-click-close",
1143 tasklist->middle_click_close_check,
1144 "active",
1145 G_SETTINGS_BIND_DEFAULT);
1146
1147#ifdef HAVE_WINDOW_PREVIEWS1
1148 /* change thumbnail size: */
1149 tasklist_update_thumbnail_size_spin(tasklist);
1150 g_signal_connect (tasklist->thumbnail_size_spin, "value-changed",g_signal_connect_data ((tasklist->thumbnail_size_spin), ("value-changed"
), ((GCallback) thumbnail_size_spin_changed), (tasklist), ((void
*)0), (GConnectFlags) 0)
1151 (GCallback) thumbnail_size_spin_changed,g_signal_connect_data ((tasklist->thumbnail_size_spin), ("value-changed"
), ((GCallback) thumbnail_size_spin_changed), (tasklist), ((void
*)0), (GConnectFlags) 0)
1152 tasklist)g_signal_connect_data ((tasklist->thumbnail_size_spin), ("value-changed"
), ((GCallback) thumbnail_size_spin_changed), (tasklist), ((void
*)0), (GConnectFlags) 0)
;
1153#endif
1154
1155 /* move window when unminimizing: */
1156 tasklist_update_unminimization_radio(tasklist);
1157 g_signal_connect (tasklist->move_minimized_radio, "toggled",g_signal_connect_data ((tasklist->move_minimized_radio), (
"toggled"), ((GCallback) move_minimized_toggled), (tasklist),
((void*)0), (GConnectFlags) 0)
1158 (GCallback) move_minimized_toggled,g_signal_connect_data ((tasklist->move_minimized_radio), (
"toggled"), ((GCallback) move_minimized_toggled), (tasklist),
((void*)0), (GConnectFlags) 0)
1159 tasklist)g_signal_connect_data ((tasklist->move_minimized_radio), (
"toggled"), ((GCallback) move_minimized_toggled), (tasklist),
((void*)0), (GConnectFlags) 0)
;
1160
1161 /* Tasklist content: */
1162 tasklist_properties_update_content_radio (tasklist);
1163 g_signal_connect (tasklist->show_all_radio, "toggled",g_signal_connect_data ((tasklist->show_all_radio), ("toggled"
), ((GCallback) display_all_workspaces_toggled), (tasklist), (
(void*)0), (GConnectFlags) 0)
1164 (GCallback) display_all_workspaces_toggled,g_signal_connect_data ((tasklist->show_all_radio), ("toggled"
), ((GCallback) display_all_workspaces_toggled), (tasklist), (
(void*)0), (GConnectFlags) 0)
1165 tasklist)g_signal_connect_data ((tasklist->show_all_radio), ("toggled"
), ((GCallback) display_all_workspaces_toggled), (tasklist), (
(void*)0), (GConnectFlags) 0)
;
1166
1167 g_signal_connect_swapped (WID ("done_button"), "clicked",g_signal_connect_data ((((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((gtk_builder_get_object(builder, "done_button"
))), ((gtk_widget_get_type ()))))))), ("clicked"), ((GCallback
) gtk_widget_hide), (tasklist->properties_dialog), ((void*
)0), G_CONNECT_SWAPPED)
1168 (GCallback) gtk_widget_hide,g_signal_connect_data ((((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((gtk_builder_get_object(builder, "done_button"
))), ((gtk_widget_get_type ()))))))), ("clicked"), ((GCallback
) gtk_widget_hide), (tasklist->properties_dialog), ((void*
)0), G_CONNECT_SWAPPED)
1169 tasklist->properties_dialog)g_signal_connect_data ((((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((gtk_builder_get_object(builder, "done_button"
))), ((gtk_widget_get_type ()))))))), ("clicked"), ((GCallback
) gtk_widget_hide), (tasklist->properties_dialog), ((void*
)0), G_CONNECT_SWAPPED)
;
1170 g_signal_connect (tasklist->properties_dialog, "response",g_signal_connect_data ((tasklist->properties_dialog), ("response"
), (((GCallback) (response_cb))), (tasklist), ((void*)0), (GConnectFlags
) 0)
1171 G_CALLBACK (response_cb),g_signal_connect_data ((tasklist->properties_dialog), ("response"
), (((GCallback) (response_cb))), (tasklist), ((void*)0), (GConnectFlags
) 0)
1172 tasklist)g_signal_connect_data ((tasklist->properties_dialog), ("response"
), (((GCallback) (response_cb))), (tasklist), ((void*)0), (GConnectFlags
) 0)
;
1173
1174#ifdef HAVE_WAYLAND1
1175 if (GDK_IS_WAYLAND_DISPLAY(gdk_display_get_default())(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gdk_display_get_default())); GType __t = ((gdk_wayland_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
) {
1176 setup_dialog_wayland(tasklist);
1177 }
1178#endif /* HAVE_WAYLAND */
1179}
1180
1181static void display_properties_dialog(GtkAction* action, TasklistData* tasklist)
1182{
1183 if (tasklist->properties_dialog == NULL((void*)0))
1184 {
1185 GtkBuilder* builder;
1186
1187 builder = gtk_builder_new();
1188 gtk_builder_set_translation_domain(builder, GETTEXT_PACKAGE"mate-panel");
1189 gtk_builder_add_from_resource (builder, WNCKLET_RESOURCE_PATH"/org/mate/panel/applet/wncklet/" "window-list.ui", NULL((void*)0));
1190
1191 tasklist->properties_dialog = WID("tasklist_properties_dialog")((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object(builder, "tasklist_properties_dialog"
))), ((gtk_widget_get_type ()))))))
;
1192
1193 g_object_add_weak_pointer(G_OBJECT(tasklist->properties_dialog)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tasklist->properties_dialog)), (((GType) ((20) <<
(2))))))))
, (void**) &tasklist->properties_dialog);
1194
1195 setup_dialog(builder, tasklist);
1196
1197 g_object_unref(builder);
1198 }
1199
1200 gtk_window_set_icon_name(GTK_WINDOW(tasklist->properties_dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tasklist->properties_dialog)), ((gtk_window_get_type (
)))))))
, WINDOW_LIST_ICON"mate-panel-window-list");
1201
1202 gtk_window_set_resizable(GTK_WINDOW(tasklist->properties_dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tasklist->properties_dialog)), ((gtk_window_get_type (
)))))))
, FALSE(0));
1203 gtk_window_set_screen(GTK_WINDOW(tasklist->properties_dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tasklist->properties_dialog)), ((gtk_window_get_type (
)))))))
, gtk_widget_get_screen(tasklist->applet));
1204 gtk_window_present(GTK_WINDOW(tasklist->properties_dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tasklist->properties_dialog)), ((gtk_window_get_type (
)))))))
);
1205}
1206
1207static void destroy_tasklist(GtkWidget* widget, TasklistData* tasklist)
1208{
1209 g_signal_handlers_disconnect_by_data (G_OBJECT (tasklist->applet), tasklist)g_signal_handlers_disconnect_matched ((((((GObject*) (void *)
g_type_check_instance_cast ((GTypeInstance*) ((tasklist->
applet)), (((GType) ((20) << (2))))))))), G_SIGNAL_MATCH_DATA
, 0, 0, ((void*)0), ((void*)0), (tasklist))
;
1210
1211#ifdef HAVE_WINDOW_PREVIEWS1
1212 g_signal_handlers_disconnect_by_data (G_OBJECT (tasklist->tasklist), tasklist)g_signal_handlers_disconnect_matched ((((((GObject*) (void *)
g_type_check_instance_cast ((GTypeInstance*) ((tasklist->
tasklist)), (((GType) ((20) << (2))))))))), G_SIGNAL_MATCH_DATA
, 0, 0, ((void*)0), ((void*)0), (tasklist))
;
1213 g_signal_handlers_disconnect_by_data (tasklist->preview_settings, tasklist)g_signal_handlers_disconnect_matched ((tasklist->preview_settings
), G_SIGNAL_MATCH_DATA, 0, 0, ((void*)0), ((void*)0), (tasklist
))
;
1214 g_object_unref(tasklist->preview_settings);
1215#endif
1216
1217 g_signal_handlers_disconnect_by_data (tasklist->settings, tasklist)g_signal_handlers_disconnect_matched ((tasklist->settings)
, G_SIGNAL_MATCH_DATA, 0, 0, ((void*)0), ((void*)0), (tasklist
))
;
1218
1219 g_object_unref(tasklist->settings);
1220
1221 if (tasklist->properties_dialog)
1222 gtk_widget_destroy(tasklist->properties_dialog);
1223
1224#ifdef HAVE_WINDOW_PREVIEWS1
1225 if (tasklist->preview)
1226 gtk_widget_destroy(tasklist->preview);
1227#endif
1228
1229 g_free(tasklist);
1230}
diff --git a/2024-06-18-172109-13286-1@e182420b844f_master/report-313d65.html b/2024-06-18-172109-13286-1@e182420b844f_master/report-313d65.html new file mode 100644 index 00000000..9fbd56a5 --- /dev/null +++ b/2024-06-18-172109-13286-1@e182420b844f_master/report-313d65.html @@ -0,0 +1,1077 @@ + + + +panel-launch.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:mate-panel/libpanel-util/panel-launch.c
Warning:line 72, column 45
Access to field 'message' results in a dereference of a null pointer (loaded from variable 'local_error')
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name panel-launch.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/mate-panel/libpanel-util -fcoverage-compilation-dir=/rootdir/mate-panel/libpanel-util -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I ../.. -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/startup-notification-1.0 -I /usr/include/mate-menus -I /usr/include/gio-unix-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/dconf -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/dconf -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I . -I . -I ../../mate-panel/libpanel-util -D DATADIR="/usr/local/share" -D PIC -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-18-172109-13286-1 -x c panel-launch.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * panel-launch.c: some helpers to launch desktop files
3 *
4 * Copyright (C) 2008 Novell, Inc.
5 * Copyright (C) 2012-2021 MATE Developers
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of the
10 * License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301, USA.
21 *
22 * Authors:
23 * Vincent Untz <vuntz@gnome.org>
24 */
25
26#include <glib/gi18n.h>
27#include <gio/gio.h>
28#include <gio/gdesktopappinfo.h>
29
30#include <gdk/gdk.h>
31#include <gtk/gtk.h>
32
33#include "panel-error.h"
34#include "panel-glib.h"
35
36#include "panel-launch.h"
37
38static void
39_panel_launch_error_dialog (const gchar *name,
40 GdkScreen *screen,
41 const gchar *message)
42{
43 char *primary;
44
45 if (name)
46 primary = g_markup_printf_escaped (_("Could not launch '%s'")gettext ("Could not launch '%s'"),
47 name);
48 else
49 primary = g_strdup (_("Could not launch application"))g_strdup_inline (gettext ("Could not launch application"));
50
51 panel_error_dialog (NULL((void*)0), screen, "cannot_launch", TRUE(!(0)),
52 primary, message);
53 g_free (primary);
54}
55
56static gboolean
57_panel_launch_handle_error (const gchar *name,
58 GdkScreen *screen,
59 GError *local_error,
60 GError **error)
61{
62 if (g_error_matches (local_error,
33
Assuming the condition is false
34
Taking false branch
63 G_IO_ERRORg_io_error_quark(), G_IO_ERROR_CANCELLED)) {
64 g_error_free (local_error);
65 return TRUE(!(0));
66 }
67
68 else if (error
34.1
'error' is equal to NULL
!= NULL((void*)0))
35
Taking false branch
69 g_propagate_error (error, local_error);
70
71 else {
72 _panel_launch_error_dialog (name, screen, local_error->message);
36
Access to field 'message' results in a dereference of a null pointer (loaded from variable 'local_error')
73 g_error_free (local_error);
74 }
75
76 return FALSE(0);
77}
78
79static void
80dummy_child_watch (GPid pid,
81 gint status,
82 gpointer user_data)
83{
84 /* Nothing, this is just to ensure we don't double fork
85 * and break pkexec:
86 * https://bugzilla.gnome.org/show_bug.cgi?id=675789
87 */
88}
89
90static void
91gather_pid_callback (GDesktopAppInfo *gapp,
92 GPid pid,
93 gpointer data)
94{
95 g_child_watch_add (pid, dummy_child_watch, NULL((void*)0));
96}
97
98gboolean
99panel_app_info_launch_uris (GDesktopAppInfo *appinfo,
100 GList *uris,
101 GdkScreen *screen,
102 const gchar *action,
103 guint32 timestamp,
104 GError **error)
105{
106 GdkAppLaunchContext *context;
107 GError *local_error;
108 gboolean retval;
109
110 g_return_val_if_fail (G_IS_DESKTOP_APP_INFO (appinfo), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((appinfo)); GType __t = ((g_desktop_app_info_get_type ())
); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0
), ((const char*) (__func__)), "G_IS_DESKTOP_APP_INFO (appinfo)"
); return ((0)); } } while (0)
;
15
Taking false branch
16
Assuming field 'g_class' is null
17
Assuming the condition is true
18
Taking true branch
19
Loop condition is false. Exiting loop
111 g_return_val_if_fail (GDK_IS_SCREEN (screen), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((screen)); GType __t = ((gdk_screen_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "GDK_IS_SCREEN (screen)"); return ((0)); } } while
(0)
;
20
Taking false branch
21
Assuming the condition is true
22
Taking true branch
112 g_return_val_if_fail (error == NULL || *error == NULL, FALSE)do { if ((error == ((void*)0) || *error == ((void*)0))) { } else
{ g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__
)), "error == NULL || *error == NULL"); return ((0)); } } while
(0)
;
23
Loop condition is false. Exiting loop
24
Loop condition is false. Exiting loop
113
114 GdkDisplay *display = gdk_display_get_default ();
115 context = gdk_display_get_app_launch_context (display);
116 gdk_app_launch_context_set_screen (context, screen);
117 gdk_app_launch_context_set_timestamp (context, timestamp);
118
119 local_error = NULL((void*)0);
120 if (action == NULL((void*)0)) {
25
Assuming 'action' is equal to NULL
26
Taking true branch
121 retval = g_desktop_app_info_launch_uris_as_manager (appinfo, uris,
27
Value assigned to 'local_error'
122 G_APP_LAUNCH_CONTEXT (context)((((GAppLaunchContext*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((context)), ((g_app_launch_context_get_type
()))))))
,
123 G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
124 NULL((void*)0), NULL((void*)0), gather_pid_callback, appinfo,
125 &local_error);
126 } else {
127 g_desktop_app_info_launch_action (appinfo, action, G_APP_LAUNCH_CONTEXT (context)((((GAppLaunchContext*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((context)), ((g_app_launch_context_get_type
()))))))
);
128 retval = TRUE(!(0));
129 }
130
131 g_object_unref (context);
132
133 if ((local_error == NULL((void*)0)) && (retval == TRUE(!(0))))
28
Assuming 'local_error' is equal to NULL
29
Assuming the condition is false
30
Taking false branch
134 return TRUE(!(0));
135
136 return _panel_launch_handle_error (g_app_info_get_name (G_APP_INFO(appinfo)((((GAppInfo*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((appinfo)), ((g_app_info_get_type ()))))))
),
32
Calling '_panel_launch_handle_error'
137 screen, local_error, error);
31
Passing null pointer value via 3rd parameter 'local_error'
138}
139
140gboolean
141panel_app_info_launch_uri (GDesktopAppInfo *appinfo,
142 const gchar *uri,
143 GdkScreen *screen,
144 guint32 timestamp,
145 GError **error)
146{
147 GList *uris;
148 gboolean retval;
149
150 g_return_val_if_fail (G_IS_APP_INFO (appinfo), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((appinfo)); GType __t = ((g_app_info_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "G_IS_APP_INFO (appinfo)"); return ((0)); } } while
(0)
;
151 g_return_val_if_fail (GDK_IS_SCREEN (screen), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((screen)); GType __t = ((gdk_screen_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "GDK_IS_SCREEN (screen)"); return ((0)); } } while
(0)
;
152 g_return_val_if_fail (error == NULL || *error == NULL, FALSE)do { if ((error == ((void*)0) || *error == ((void*)0))) { } else
{ g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__
)), "error == NULL || *error == NULL"); return ((0)); } } while
(0)
;
153
154 uris = NULL((void*)0);
155 if (uri)
156 uris = g_list_prepend (uris, (gpointer) uri);
157
158 retval = panel_app_info_launch_uris (appinfo, uris,
159 screen, NULL((void*)0), timestamp, error);
160
161 g_list_free (uris);
162
163 return retval;
164}
165
166gboolean
167panel_launch_key_file (GKeyFile *keyfile,
168 GList *uri_list,
169 GdkScreen *screen,
170 const gchar *action,
171 GError **error)
172{
173 GDesktopAppInfo *appinfo;
174 gboolean retval;
175
176 g_return_val_if_fail (keyfile != NULL, FALSE)do { if ((keyfile != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "keyfile != NULL"
); return ((0)); } } while (0)
;
1
Assuming 'keyfile' is not equal to null
2
Taking true branch
3
Loop condition is false. Exiting loop
177 g_return_val_if_fail (GDK_IS_SCREEN (screen), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((screen)); GType __t = ((gdk_screen_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "GDK_IS_SCREEN (screen)"); return ((0)); } } while
(0)
;
4
Assuming '__inst' is non-null
5
Taking false branch
6
Assuming field 'g_class' is null
7
Assuming the condition is true
8
Taking true branch
178 g_return_val_if_fail (error == NULL || *error == NULL, FALSE)do { if ((error == ((void*)0) || *error == ((void*)0))) { } else
{ g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__
)), "error == NULL || *error == NULL"); return ((0)); } } while
(0)
;
9
Loop condition is false. Exiting loop
10
Assuming 'error' is equal to null
11
Loop condition is false. Exiting loop
179
180 appinfo = g_desktop_app_info_new_from_keyfile (keyfile);
181 if (appinfo == NULL((void*)0))
12
Assuming 'appinfo' is not equal to NULL
13
Taking false branch
182 return FALSE(0);
183
184 retval = panel_app_info_launch_uris (appinfo,
14
Calling 'panel_app_info_launch_uris'
185 uri_list, screen, action,
186 gtk_get_current_event_time (),
187 error);
188
189 g_object_unref (appinfo);
190 return retval;
191}
192
193gboolean
194panel_launch_desktop_file (const char *desktop_file,
195 GdkScreen *screen,
196 GError **error)
197{
198 GDesktopAppInfo *appinfo;
199 gboolean retval;
200
201 g_return_val_if_fail (desktop_file != NULL, FALSE)do { if ((desktop_file != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "desktop_file != NULL"
); return ((0)); } } while (0)
;
202 g_return_val_if_fail (GDK_IS_SCREEN (screen), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((screen)); GType __t = ((gdk_screen_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "GDK_IS_SCREEN (screen)"); return ((0)); } } while
(0)
;
203 g_return_val_if_fail (error == NULL || *error == NULL, FALSE)do { if ((error == ((void*)0) || *error == ((void*)0))) { } else
{ g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__
)), "error == NULL || *error == NULL"); return ((0)); } } while
(0)
;
204
205 appinfo = NULL((void*)0);
206
207 if (g_path_is_absolute (desktop_file))
208 appinfo = g_desktop_app_info_new_from_filename (desktop_file);
209 else {
210 char *full;
211
212 full = panel_g_lookup_in_applications_dirs (desktop_file);
213 if (full) {
214 appinfo = g_desktop_app_info_new_from_filename (full);
215 g_free (full);
216 }
217 }
218
219 if (appinfo == NULL((void*)0))
220 return FALSE(0);
221
222 retval = panel_app_info_launch_uris (appinfo, NULL((void*)0), screen, NULL((void*)0),
223 gtk_get_current_event_time (),
224 error);
225
226 g_object_unref (appinfo);
227
228 return retval;
229}
230
231/*
232 * Set the DISPLAY variable, to be use by g_spawn_async.
233 */
234static void
235set_environment (gpointer display)
236{
237 g_setenv ("DISPLAY", display, TRUE(!(0)));
238}
239
240gboolean
241panel_launch_desktop_file_with_fallback (const char *desktop_file,
242 const char *fallback_exec,
243 GdkScreen *screen,
244 GError **error)
245{
246 char *argv[2] = { (char *) fallback_exec, NULL((void*)0) };
247 GError *local_error;
248 gboolean retval;
249 GPid pid;
250 GdkDisplay *display;
251 char *display_name;
252
253 g_return_val_if_fail (desktop_file != NULL, FALSE)do { if ((desktop_file != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "desktop_file != NULL"
); return ((0)); } } while (0)
;
254 g_return_val_if_fail (fallback_exec != NULL, FALSE)do { if ((fallback_exec != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "fallback_exec != NULL"
); return ((0)); } } while (0)
;
255 g_return_val_if_fail (GDK_IS_SCREEN (screen), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((screen)); GType __t = ((gdk_screen_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "GDK_IS_SCREEN (screen)"); return ((0)); } } while
(0)
;
256 g_return_val_if_fail (error == NULL || *error == NULL, FALSE)do { if ((error == ((void*)0) || *error == ((void*)0))) { } else
{ g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__
)), "error == NULL || *error == NULL"); return ((0)); } } while
(0)
;
257
258 /* need to pass a non-NULL error to avoid getting a dialog */
259 local_error = NULL((void*)0);
260 if (panel_launch_desktop_file (desktop_file, screen, &local_error))
261 return TRUE(!(0));
262
263 if (local_error) {
264 g_error_free (local_error);
265 local_error = NULL((void*)0);
266 }
267
268 display = gdk_screen_get_display (screen);
269 display_name = g_strdup (gdk_display_get_name (display))g_strdup_inline (gdk_display_get_name (display));
270 retval = g_spawn_async (NULL((void*)0), /* working directory */
271 argv,
272 NULL((void*)0), /* envp */
273 G_SPAWN_SEARCH_PATH,
274 set_environment,
275 &display_name,
276 &pid,
277 &local_error);
278 g_free (display_name);
279
280 if (local_error == NULL((void*)0) && retval == TRUE(!(0))) {
281 g_child_watch_add (pid, dummy_child_watch, NULL((void*)0));
282 }
283 return TRUE(!(0));
284
285 return _panel_launch_handle_error (fallback_exec,
286 screen, local_error, error);
287}
diff --git a/2024-06-18-172109-13286-1@e182420b844f_master/report-3bfab8.html b/2024-06-18-172109-13286-1@e182420b844f_master/report-3bfab8.html new file mode 100644 index 00000000..c945e3f8 --- /dev/null +++ b/2024-06-18-172109-13286-1@e182420b844f_master/report-3bfab8.html @@ -0,0 +1,868 @@ + + + +mate-panel-applet-gsettings.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:libmate-panel-applet/mate-panel-applet-gsettings.c
Warning:line 44, column 39
Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name mate-panel-applet-gsettings.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/libmate-panel-applet -fcoverage-compilation-dir=/rootdir/libmate-panel-applet -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I .. -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/gio-unix-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I ../libmate-panel-applet -D MATELOCALEDIR="/usr/local/share/locale" -D PIC -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-18-172109-13286-1 -x c mate-panel-applet-gsettings.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * mate-panel-applet-gsettings.c: panel applet preferences handling.
3 *
4 * Copyright (C) 2012 Stefano Karapetsas
5 * Copyright (C) 2012-2021 MATE Developers
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
16 *
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
21 *
22 * Authors:
23 * Stefano Karapetsas <stefano@karapetsas.com>
24 */
25
26#include <gtk/gtk.h>
27#include <gio/gio.h>
28
29#include "mate-panel-applet.h"
30#include "mate-panel-applet-gsettings.h"
31
32static GVariant *
33add_to_dict (GVariant *dict, const gchar *schema, const gchar *path)
34{
35 GVariantIter iter;
36 GVariantBuilder builder;
37 gboolean is_schema_found;
38 gboolean is_incorrect_schema;
39 gint path_counter;
40
41 gchar *key;
42 gchar *value;
43
44 g_variant_builder_init (&builder, (const GVariantType *) "a{ss}");
Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption
45 g_variant_iter_init (&iter, dict);
46
47 is_schema_found = FALSE(0);
48 is_incorrect_schema = FALSE(0);
49 path_counter = 0;
50
51 while (g_variant_iter_next (&iter, "{ss}", &key, &value)) {
52 gboolean path_is_found = FALSE(0);
53 if (g_strcmp0 (value, path) == 0) {
54 path_is_found = TRUE(!(0));
55 path_counter++;
56 if (g_strcmp0 (key, schema) == 0) {
57 is_schema_found = TRUE(!(0));
58 } else {
59 // skip incoorect schema for path
60 is_incorrect_schema = TRUE(!(0));
61 g_free (key);
62 g_free (value);
63 continue;
64 }
65 }
66
67 gboolean need_add_to_dict = !path_is_found || path_counter < 2;
68
69 if (need_add_to_dict) {
70 g_variant_builder_add (&builder, "{ss}", key, value);
71 }
72
73 g_free (key);
74 g_free (value);
75 }
76
77 if (!is_schema_found) {
78 g_variant_builder_add (&builder, "{ss}", schema, path);
79 }
80
81 if (!is_schema_found || is_incorrect_schema || (path_counter > 1)) {
82 return g_variant_ref_sink (g_variant_builder_end (&builder));
83 } else {
84 g_variant_builder_clear (&builder);
85 // no changes
86 return NULL((void*)0);
87 }
88}
89
90static void
91register_dconf_editor_relocatable_schema (const gchar *schema, const gchar *path)
92{
93 GSettings *dconf_editor_settings;
94 dconf_editor_settings = g_settings_new ("ca.desrt.dconf-editor.Settings");
95
96 if (dconf_editor_settings && g_settings_is_writable (dconf_editor_settings, "relocatable-schemas-user-paths")) {
97 GVariant *relocatable_schemas = g_settings_get_value (dconf_editor_settings, "relocatable-schemas-user-paths");
98
99 if (g_variant_is_of_type (relocatable_schemas, G_VARIANT_TYPE_DICTIONARY((const GVariantType *) "a{?*}"))) {
100 GVariant * new_relocatable_schemas = add_to_dict (relocatable_schemas, schema, path);
101 if (new_relocatable_schemas) {
102 g_settings_set_value (dconf_editor_settings, "relocatable-schemas-user-paths", new_relocatable_schemas);
103 g_variant_unref (new_relocatable_schemas);
104 }
105 }
106
107 g_variant_unref (relocatable_schemas);
108 }
109
110 g_object_unref (dconf_editor_settings);
111}
112
113GSettings *
114mate_panel_applet_settings_new (MatePanelApplet *applet, gchar *schema)
115{
116 GSettings *settings = NULL((void*)0);
117 gchar *path;
118
119 g_return_val_if_fail (MATE_PANEL_IS_APPLET (applet), NULL)do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return (((void*)0)); } } while (0)
;
120
121 path = mate_panel_applet_get_preferences_path (applet);
122
123 if (path) {
124 settings = g_settings_new_with_path (schema, path);
125 register_dconf_editor_relocatable_schema (schema, path);
126 g_free (path);
127 }
128
129 return settings;
130}
131
132GList*
133mate_panel_applet_settings_get_glist (GSettings *settings, gchar *key)
134{
135 gchar **array;
136 GList *list = NULL((void*)0);
137
138 array = g_settings_get_strv (settings, key);
139 if (array != NULL((void*)0)) {
140 for (gint i = 0; array[i]; i++) {
141 list = g_list_prepend (list, array[i]);
142 }
143 g_free (array);
144 }
145 return g_list_reverse (list);
146}
147
148void
149mate_panel_applet_settings_set_glist (GSettings *settings, gchar *key, GList *list)
150{
151 GArray *array;
152
153 array = g_array_new (TRUE(!(0)), TRUE(!(0)), sizeof (gchar *));
154 for (GList *l = list; l; l = l->next) {
155 array = g_array_append_val (array, l->data)g_array_append_vals (array, &(l->data), 1);
156 }
157 g_settings_set_strv (settings, key, (const gchar **) array->data);
158 g_array_free (array, TRUE(!(0)));
159}
160
161GSList*
162mate_panel_applet_settings_get_gslist (GSettings *settings, gchar *key)
163{
164 gchar **array;
165 GSList *list = NULL((void*)0);
166
167 array = g_settings_get_strv (settings, key);
168 if (array != NULL((void*)0)) {
169 for (gint i = 0; array[i]; i++) {
170 list = g_slist_prepend (list, array[i]);
171 }
172 g_free (array);
173 }
174 return g_slist_reverse (list);
175}
176
177void
178mate_panel_applet_settings_set_gslist (GSettings *settings, gchar *key, GSList *list)
179{
180 GArray *array;
181
182 array = g_array_new (TRUE(!(0)), TRUE(!(0)), sizeof (gchar *));
183 for (GSList *l = list; l; l = l->next) {
184 array = g_array_append_val (array, l->data)g_array_append_vals (array, &(l->data), 1);
185 }
186 g_settings_set_strv (settings, key, (const gchar **) array->data);
187 g_array_free (array, TRUE(!(0)));
188}
diff --git a/2024-06-18-172109-13286-1@e182420b844f_master/report-4646d6.html b/2024-06-18-172109-13286-1@e182420b844f_master/report-4646d6.html new file mode 100644 index 00000000..c75e39ee --- /dev/null +++ b/2024-06-18-172109-13286-1@e182420b844f_master/report-4646d6.html @@ -0,0 +1,1906 @@ + + + +launcher.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:mate-panel/launcher.c
Warning:line 951, column 8
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name launcher.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/mate-panel -fcoverage-compilation-dir=/rootdir/mate-panel -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I .. -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/startup-notification-1.0 -I /usr/include/mate-menus -I /usr/include/gio-unix-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/dconf -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/dconf -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I . -I . -I ../mate-panel -I ../mate-panel/mate-submodules -I ../mate-panel/libpanel-util -D MATELOCALEDIR="/usr/local/share/locale" -D PANELDATADIR="/usr/local/share/mate-panel" -I /usr/include/gtk-layer-shell -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/gtk-3.0 -I /usr/include/cloudproviders -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/atk-1.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/gio-unix-2.0 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -D PANEL_MODULES_DIR="/usr/local/lib/mate-panel/modules" -D MATEMENU_I_KNOW_THIS_IS_UNSTABLE -I /usr/include/gtk-layer-shell -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/gtk-3.0 -I /usr/include/cloudproviders -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/atk-1.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/gio-unix-2.0 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-18-172109-13286-1 -x c launcher.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * MATE panel launcher module.
3 * (C) 1997,1998,1999,2000 The Free Software Foundation
4 * (C) 2000 Eazel, Inc.
5 * Copyright (C) 2012-2021 MATE Developers
6 *
7 * Authors: Miguel de Icaza
8 * Federico Mena
9 * CORBAized by George Lebl
10 * de-CORBAized by George Lebl
11 *
12 */
13
14#include <config.h>
15#include <stdio.h>
16#include <sys/types.h>
17#include <sys/stat.h>
18#include <unistd.h>
19#include <dirent.h>
20#include <string.h>
21
22#include <glib/gi18n.h>
23#include <gio/gio.h>
24
25#include <libpanel-util/panel-error.h>
26#include <libpanel-util/panel-glib.h>
27#include <libpanel-util/panel-keyfile.h>
28#include <libpanel-util/panel-launch.h>
29#include <libpanel-util/panel-show.h>
30
31#include "launcher.h"
32
33#include "button-widget.h"
34#include "panel-util.h"
35#include "panel-config-global.h"
36#include "panel-profile.h"
37#ifdef HAVE_X111
38#include "xstuff.h"
39#endif
40#include "panel-toplevel.h"
41#include "panel-a11y.h"
42#include "panel-globals.h"
43#include "panel-lockdown.h"
44#include "panel-ditem-editor.h"
45#include "panel-icon-names.h"
46#include "panel-schemas.h"
47
48static gboolean
49launcher_properties_enabled (void);
50
51static GdkScreen *
52launcher_get_screen (Launcher *launcher)
53{
54 PanelWidget *panel_widget;
55
56 g_return_val_if_fail (launcher != NULL, NULL)do { if ((launcher != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "launcher != NULL"
); return (((void*)0)); } } while (0)
;
57 g_return_val_if_fail (launcher->info != NULL, NULL)do { if ((launcher->info != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "launcher->info != NULL"
); return (((void*)0)); } } while (0)
;
58 g_return_val_if_fail (launcher->info->widget != NULL, NULL)do { if ((launcher->info->widget != ((void*)0))) { } else
{ g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__
)), "launcher->info->widget != NULL"); return (((void*)
0)); } } while (0)
;
59
60 panel_widget = PANEL_WIDGET (gtk_widget_get_parent (launcher->info->widget))((((PanelWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_widget_get_parent (launcher->info->widget))), (
(panel_widget_get_type()))))))
;
61
62 return gtk_window_get_screen (GTK_WINDOW (panel_widget->toplevel)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((panel_widget->toplevel)), ((gtk_window_get_type ())))
)))
);
63}
64
65static void
66launcher_widget_open_dialog_destroyed (GtkWidget *dialog,
67 Launcher *launcher)
68{
69 g_return_if_fail (launcher->error_dialogs != NULL)do { if ((launcher->error_dialogs != ((void*)0))) { } else
{ g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__
)), "launcher->error_dialogs != NULL"); return; } } while (
0)
;
70
71 launcher->error_dialogs = g_slist_remove (launcher->error_dialogs, dialog);
72}
73
74static void
75launcher_widget_destroy_open_dialogs (Launcher *launcher)
76{
77 GSList *l, *list;
78
79 list = launcher->error_dialogs;
80 launcher->error_dialogs = NULL((void*)0);
81
82 for (l = list; l; l = l->next) {
83 g_signal_handlers_disconnect_by_func (G_OBJECT (l->data),g_signal_handlers_disconnect_matched ((((((GObject*) (void *)
g_type_check_instance_cast ((GTypeInstance*) ((l->data)),
(((GType) ((20) << (2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC
| G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0), (((GCallback) (launcher_widget_open_dialog_destroyed
))), (launcher))
84 G_CALLBACK (launcher_widget_open_dialog_destroyed),g_signal_handlers_disconnect_matched ((((((GObject*) (void *)
g_type_check_instance_cast ((GTypeInstance*) ((l->data)),
(((GType) ((20) << (2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC
| G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0), (((GCallback) (launcher_widget_open_dialog_destroyed
))), (launcher))
85 launcher)g_signal_handlers_disconnect_matched ((((((GObject*) (void *)
g_type_check_instance_cast ((GTypeInstance*) ((l->data)),
(((GType) ((20) << (2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC
| G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0), (((GCallback) (launcher_widget_open_dialog_destroyed
))), (launcher))
;
86 gtk_widget_destroy (l->data);
87 }
88 g_slist_free (list);
89}
90
91static void
92launcher_register_error_dialog (Launcher *launcher,
93 GtkWidget *dialog)
94{
95 launcher->error_dialogs = g_slist_append (launcher->error_dialogs,
96 dialog);
97 g_signal_connect (dialog, "destroy",g_signal_connect_data ((dialog), ("destroy"), (((GCallback) (
launcher_widget_open_dialog_destroyed))), (launcher), ((void*
)0), (GConnectFlags) 0)
98 G_CALLBACK (launcher_widget_open_dialog_destroyed),g_signal_connect_data ((dialog), ("destroy"), (((GCallback) (
launcher_widget_open_dialog_destroyed))), (launcher), ((void*
)0), (GConnectFlags) 0)
99 launcher)g_signal_connect_data ((dialog), ("destroy"), (((GCallback) (
launcher_widget_open_dialog_destroyed))), (launcher), ((void*
)0), (GConnectFlags) 0)
;
100}
101
102static void
103launch_url (Launcher *launcher)
104{
105 char *url;
106 GdkScreen *screen;
107
108 g_return_if_fail (launcher != NULL)do { if ((launcher != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "launcher != NULL"
); return; } } while (0)
;
109 g_return_if_fail (launcher->key_file != NULL)do { if ((launcher->key_file != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "launcher->key_file != NULL"
); return; } } while (0)
;
110
111 /* FIXME panel_ditem_launch() should be enough for this! */
112 url = panel_key_file_get_string (launcher->key_file, "URL")g_key_file_get_string (launcher->key_file, "Desktop Entry"
, "URL", ((void*)0))
;
113
114 screen = launcher_get_screen (launcher);
115
116 if (!url || *url == 0) {
117 GtkWidget *error_dialog;
118
119 error_dialog = panel_error_dialog (NULL((void*)0), screen,
120 "no_url_dialog", TRUE(!(0)),
121 _("Could not show this URL")gettext ("Could not show this URL"),
122 _("No URL was specified.")gettext ("No URL was specified."));
123 launcher_register_error_dialog (launcher, error_dialog);
124 g_free (url);
125 return;
126 }
127
128 panel_show_uri (screen, url, gtk_get_current_event_time (), NULL((void*)0));
129
130 g_free (url);
131}
132
133void
134launcher_launch (Launcher *launcher,
135 const gchar *action)
136{
137 char *type;
138
139 g_return_if_fail (launcher != NULL)do { if ((launcher != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "launcher != NULL"
); return; } } while (0)
;
140 g_return_if_fail (launcher->key_file != NULL)do { if ((launcher->key_file != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "launcher->key_file != NULL"
); return; } } while (0)
;
141
142 if (action == NULL((void*)0)) {
143 type = panel_key_file_get_string (launcher->key_file, "Type")g_key_file_get_string (launcher->key_file, "Desktop Entry"
, "Type", ((void*)0))
;
144 } else {
145 type = NULL((void*)0);
146 }
147
148 if (type && !strcmp (type, "Link"))
149 launch_url (launcher);
150 else {
151 GError *error = NULL((void*)0);
152
153 panel_launch_key_file (launcher->key_file, NULL((void*)0),
154 launcher_get_screen (launcher), action, &error);
155 if (error) {
156 GtkWidget *error_dialog;
157
158 error_dialog = panel_error_dialog (
159 NULL((void*)0),
160 launcher_get_screen (launcher),
161 "cannot_launch_application",
162 TRUE(!(0)),
163 _("Could not launch application")gettext ("Could not launch application"),
164 error->message);
165 launcher_register_error_dialog (launcher, error_dialog);
166 g_clear_error (&error);
167 }
168 }
169 g_free (type);
170}
171
172static void
173drag_data_received_cb (GtkWidget *widget,
174 GdkDragContext *context,
175 gint x,
176 gint y,
177 GtkSelectionData *selection_data,
178 guint info,
179 guint time,
180 Launcher *launcher)
181{
182 GError *error = NULL((void*)0);
183 char **uris;
184 int i;
185 GList *file_list;
186
187 /* The animation uses X specific functionality */
188#ifdef HAVE_X111
189 if (is_using_x11 () && panel_global_config_get_enable_animations ()) {
190 cairo_surface_t *surface;
191 surface = button_widget_get_surface (BUTTON_WIDGET (widget)((((ButtonWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((button_widget_get_type ()))))))
);
192 xstuff_zoom_animate (widget,
193 surface,
194 button_widget_get_orientation (BUTTON_WIDGET (widget)((((ButtonWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((button_widget_get_type ()))))))
),
195 NULL((void*)0));
196 cairo_surface_destroy (surface);
197 }
198#endif
199
200 file_list = NULL((void*)0);
201 uris = g_uri_list_extract_uris ((const char *) gtk_selection_data_get_data (selection_data));
202 for (i = 0; uris[i]; i++)
203 file_list = g_list_prepend (file_list, uris[i]);
204 file_list = g_list_reverse (file_list);
205
206 panel_launch_key_file (launcher->key_file, file_list,
207 launcher_get_screen (launcher), NULL((void*)0), &error);
208
209 g_list_free (file_list);
210 g_strfreev (uris);
211
212 if (error) {
213 GtkWidget *error_dialog;
214 error_dialog = panel_error_dialog (NULL((void*)0),
215 launcher_get_screen (launcher),
216 "cannot_use_dropped_item",
217 TRUE(!(0)),
218 _("Could not use dropped item")gettext ("Could not use dropped item"),
219 error->message);
220 launcher_register_error_dialog (launcher, error_dialog);
221 g_clear_error (&error);
222 }
223
224 gtk_drag_finish (context, TRUE(!(0)), FALSE(0), time);
225}
226
227static void
228destroy_launcher (GtkWidget *widget,
229 Launcher *launcher)
230{
231 launcher_properties_destroy (launcher);
232 launcher_widget_destroy_open_dialogs (launcher);
233}
234
235void
236launcher_properties_destroy (Launcher *launcher)
237{
238 GtkWidget *dialog;
239
240 dialog = launcher->prop_dialog;
241 launcher->prop_dialog = NULL((void*)0);
242
243 if (dialog)
244 gtk_widget_destroy (dialog);
245}
246
247static void
248free_launcher (gpointer data)
249{
250 Launcher *launcher = data;
251
252 if (launcher->key_file)
253 g_key_file_free (launcher->key_file);
254
255 g_free (launcher->location);
256
257 if (launcher->monitor != NULL((void*)0))
258 g_object_unref (launcher->monitor);
259
260 g_free (launcher);
261}
262
263void
264panel_launcher_delete (Launcher *launcher)
265{
266 if (!launcher->location)
267 return;
268
269 /* do not remove the file if it's not in the user's launchers path */
270 if (panel_launcher_is_in_personal_path (launcher->location)) {
271 GError *error;
272 GFile *file;
273
274 file = panel_launcher_get_gfile (launcher->location);
275
276 error = NULL((void*)0);
277 if (!g_file_delete (file, NULL((void*)0), &error)) {
278 char *path;
279
280 path = g_file_get_path (file);
281 g_warning ("Error deleting '%s': %s\n",
282 path, error->message);
283 g_free (path);
284 g_error_free (error);
285 }
286
287 g_object_unref (file);
288 }
289}
290
291static gboolean
292is_this_drop_ok (GtkWidget *widget,
293 GdkDragContext *context)
294{
295 static GdkAtom text_uri_list = GDK_NONE((GdkAtom)((gpointer) (gulong) (0)));
296 GList *l;
297 GtkWidget *source;
298
299 source = gtk_drag_get_source_widget (context);
300
301 if (source == widget)
302 return FALSE(0);
303
304 if (!(gdk_drag_context_get_actions (context) & GDK_ACTION_COPY))
305 return FALSE(0);
306
307 if (!text_uri_list)
308 text_uri_list = gdk_atom_intern_static_string ("text/uri-list");
309
310 for (l = gdk_drag_context_list_targets (context); l; l = l->next) {
311 if (GDK_POINTER_TO_ATOM (l->data)((GdkAtom)(l->data)) == text_uri_list)
312 break;
313 }
314
315 return l ? TRUE(!(0)) : FALSE(0);
316}
317
318static void
319drag_leave_cb(GtkWidget *widget,
320 GdkDragContext *context,
321 guint time,
322 Launcher *launcher)
323{
324 button_widget_set_dnd_highlight(BUTTON_WIDGET(widget)((((ButtonWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((button_widget_get_type ()))))))
, FALSE(0));
325}
326
327static gboolean
328drag_motion_cb(GtkWidget *widget,
329 GdkDragContext *context,
330 gint x,
331 gint y,
332 guint time,
333 Launcher *launcher)
334{
335 if ( ! is_this_drop_ok (widget, context))
336 return FALSE(0);
337
338 gdk_drag_status (context, GDK_ACTION_COPY, time);
339
340 button_widget_set_dnd_highlight(BUTTON_WIDGET(widget)((((ButtonWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((button_widget_get_type ()))))))
, TRUE(!(0)));
341
342 return TRUE(!(0));
343}
344
345static gboolean
346drag_drop_cb (GtkWidget *widget,
347 GdkDragContext *context,
348 gint x,
349 gint y,
350 guint time,
351 Launcher *launcher)
352{
353 static GdkAtom text_uri_list = NULL((void*)0);
354
355 if ( ! is_this_drop_ok (widget, context))
356 return FALSE(0);
357
358 if (text_uri_list == NULL((void*)0))
359 text_uri_list = gdk_atom_intern_static_string ("text/uri-list");
360
361 gtk_drag_get_data (widget, context, text_uri_list, time);
362
363 return TRUE(!(0));
364}
365
366enum {
367 TARGET_ICON_INTERNAL,
368 TARGET_URI_LIST
369};
370
371static void
372drag_data_get_cb (GtkWidget *widget,
373 GdkDragContext *context,
374 GtkSelectionData *selection_data,
375 guint info,
376 guint time,
377 Launcher *launcher)
378{
379 char *location;
380
381 g_return_if_fail (launcher != NULL)do { if ((launcher != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "launcher != NULL"
); return; } } while (0)
;
382
383 location = launcher->location;
384
385 if (info == TARGET_URI_LIST) {
386 char *uri[2];
387
388 uri[0] = panel_launcher_get_uri (location);
389 uri[1] = NULL((void*)0);
390
391 gtk_selection_data_set_uris (selection_data, uri);
392
393 g_free (uri[0]);
394 } else if (info == TARGET_ICON_INTERNAL)
395 gtk_selection_data_set (selection_data,
396 gtk_selection_data_get_target (selection_data), 8,
397 (unsigned char *) location,
398 strlen (location));
399
400}
401
402static void
403clicked_cb (Launcher *launcher,
404 GtkWidget *widget)
405{
406
407#ifdef HAVE_X111
408 if (is_using_x11 () && panel_global_config_get_enable_animations ()) {
409 cairo_surface_t *surface;
410 surface = button_widget_get_surface (BUTTON_WIDGET (widget)((((ButtonWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((button_widget_get_type ()))))))
);
411 xstuff_zoom_animate (widget,
412 surface,
413 button_widget_get_orientation (BUTTON_WIDGET (widget)((((ButtonWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((button_widget_get_type ()))))))
),
414 NULL((void*)0));
415 cairo_surface_destroy (surface);
416 }
417#endif
418
419 launcher_launch (launcher, NULL((void*)0));
420
421 if (panel_global_config_get_drawer_auto_close ()) {
422 PanelToplevel *toplevel;
423 PanelToplevel *parent;
424
425 toplevel = PANEL_WIDGET (gtk_widget_get_parent (launcher->button))((((PanelWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_widget_get_parent (launcher->button))), ((panel_widget_get_type
()))))))
->toplevel;
426
427 if (panel_toplevel_get_is_attached (toplevel)) {
428 parent = panel_toplevel_get_attach_toplevel (toplevel);
429
430 while (panel_toplevel_get_is_attached (parent)) {
431 toplevel = parent;
432 parent = panel_toplevel_get_attach_toplevel (toplevel);
433 }
434
435 panel_toplevel_hide (toplevel, FALSE(0), -1);
436 }
437 }
438}
439
440static Launcher *
441create_launcher (const char *location)
442{
443 GKeyFile *key_file;
444 g_autoptr(GFile)__attribute__((cleanup(glib_autoptr_cleanup_GFile))) GFile_autoptr file = NULL((void*)0);
445 gboolean loaded = FALSE(0);
446 Launcher *launcher;
447 GError *error = NULL((void*)0);
448 char *new_location;
449
450 if (!location) {
451 g_printerr (_("No URI provided for panel launcher desktop file\n")gettext ("No URI provided for panel launcher desktop file\n"));
452 return NULL((void*)0);
453 }
454
455 new_location = NULL((void*)0);
456 key_file = g_key_file_new ();
457
458 if (!strchr (location, G_DIR_SEPARATOR'/')) {
459 /* try to first load a file in our config directory, and if it
460 * doesn't exist there, try to find it in the xdg data dirs */
461 char *path;
462
463 path = panel_make_full_path (NULL((void*)0), location);
464
465 if (!g_file_test (path, G_FILE_TEST_EXISTS)) {
466 g_free (path);
467 path = panel_g_lookup_in_applications_dirs (location);
468 /* it's important to keep the full path if the desktop
469 * file comes from a data dir: when the user will edit
470 * it, we'll want to save it in PANEL_LAUNCHERS_PATH
471 * with a random name (and not evolution.desktop, eg)
472 * and having only a basename as location will make
473 * this impossible */
474 if (path)
475 new_location = g_strdup (path)g_strdup_inline (path);
476 }
477
478 if (path) {
479 loaded = g_key_file_load_from_file (key_file, path,
480 G_KEY_FILE_KEEP_COMMENTS|G_KEY_FILE_KEEP_TRANSLATIONS,
481 &error);
482 g_free (path);
483 }
484 } else
485 loaded = panel_key_file_load_from_uri (key_file, location,
486 G_KEY_FILE_KEEP_COMMENTS|G_KEY_FILE_KEEP_TRANSLATIONS,
487 &error);
488
489 if (!loaded) {
490 g_printerr (_("Unable to open desktop file %s for panel launcher%s%s\n")gettext ("Unable to open desktop file %s for panel launcher%s%s\n"
)
,
491 location,
492 error ? ": " : "",
493 error ? error->message : "");
494 if (error)
495 g_error_free (error);
496
497 g_key_file_free (key_file);
498 g_free (new_location);
499 return NULL((void*)0); /*button is null*/
500 }
501
502 if (!new_location)
503 new_location = g_strdup (location)g_strdup_inline (location);
504 file = g_file_new_for_path (new_location);
505
506 launcher = g_new0 (Launcher, 1)((Launcher *) g_malloc0_n ((1), sizeof (Launcher)));
507
508 launcher->info = NULL((void*)0);
509 launcher->button = NULL((void*)0);
510 launcher->location = new_location;
511 launcher->key_file = key_file;
512 launcher->prop_dialog = NULL((void*)0);
513 launcher->destroy_handler = 0;
514
515 /* Icon will be setup later */
516 launcher->button = button_widget_new (NULL((void*)0) /* icon */,
517 FALSE(0),
518 PANEL_ORIENTATION_TOP);
519
520 launcher->monitor = g_file_monitor_file (file,
521 G_FILE_MONITOR_NONE,
522 NULL((void*)0),
523 NULL((void*)0));
524 gtk_widget_show (launcher->button);
525
526 /*gtk_drag_dest_set (GTK_WIDGET (launcher->button),
527 GTK_DEST_DEFAULT_ALL,
528 dnd_targets, 2,
529 GDK_ACTION_COPY);*/
530 gtk_drag_dest_set (GTK_WIDGET (launcher->button)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((launcher->button)), ((gtk_widget_get_type ()))))))
,
531 0, NULL((void*)0), 0, 0);
532
533 g_signal_connect (launcher->button, "drag-data-get",g_signal_connect_data ((launcher->button), ("drag-data-get"
), (((GCallback) (drag_data_get_cb))), (launcher), ((void*)0)
, (GConnectFlags) 0)
534 G_CALLBACK (drag_data_get_cb), launcher)g_signal_connect_data ((launcher->button), ("drag-data-get"
), (((GCallback) (drag_data_get_cb))), (launcher), ((void*)0)
, (GConnectFlags) 0)
;
535 g_signal_connect (launcher->button, "drag-data-received",g_signal_connect_data ((launcher->button), ("drag-data-received"
), (((GCallback) (drag_data_received_cb))), (launcher), ((void
*)0), (GConnectFlags) 0)
536 G_CALLBACK (drag_data_received_cb), launcher)g_signal_connect_data ((launcher->button), ("drag-data-received"
), (((GCallback) (drag_data_received_cb))), (launcher), ((void
*)0), (GConnectFlags) 0)
;
537 g_signal_connect (launcher->button, "drag-motion",g_signal_connect_data ((launcher->button), ("drag-motion")
, (((GCallback) (drag_motion_cb))), (launcher), ((void*)0), (
GConnectFlags) 0)
538 G_CALLBACK (drag_motion_cb), launcher)g_signal_connect_data ((launcher->button), ("drag-motion")
, (((GCallback) (drag_motion_cb))), (launcher), ((void*)0), (
GConnectFlags) 0)
;
539 g_signal_connect (launcher->button, "drag-drop",g_signal_connect_data ((launcher->button), ("drag-drop"), (
((GCallback) (drag_drop_cb))), (launcher), ((void*)0), (GConnectFlags
) 0)
540 G_CALLBACK (drag_drop_cb), launcher)g_signal_connect_data ((launcher->button), ("drag-drop"), (
((GCallback) (drag_drop_cb))), (launcher), ((void*)0), (GConnectFlags
) 0)
;
541 g_signal_connect (launcher->button, "drag-leave",g_signal_connect_data ((launcher->button), ("drag-leave"),
(((GCallback) (drag_leave_cb))), (launcher), ((void*)0), (GConnectFlags
) 0)
542 G_CALLBACK (drag_leave_cb), launcher)g_signal_connect_data ((launcher->button), ("drag-leave"),
(((GCallback) (drag_leave_cb))), (launcher), ((void*)0), (GConnectFlags
) 0)
;
543 g_signal_connect_swapped (launcher->button, "clicked",g_signal_connect_data ((launcher->button), ("clicked"), ((
(GCallback) (clicked_cb))), (launcher), ((void*)0), G_CONNECT_SWAPPED
)
544 G_CALLBACK (clicked_cb), launcher)g_signal_connect_data ((launcher->button), ("clicked"), ((
(GCallback) (clicked_cb))), (launcher), ((void*)0), G_CONNECT_SWAPPED
)
;
545
546 launcher->destroy_handler =
547 g_signal_connect (launcher->button, "destroy",g_signal_connect_data ((launcher->button), ("destroy"), ((
(GCallback) (destroy_launcher))), (launcher), ((void*)0), (GConnectFlags
) 0)
548 G_CALLBACK (destroy_launcher),g_signal_connect_data ((launcher->button), ("destroy"), ((
(GCallback) (destroy_launcher))), (launcher), ((void*)0), (GConnectFlags
) 0)
549 launcher)g_signal_connect_data ((launcher->button), ("destroy"), ((
(GCallback) (destroy_launcher))), (launcher), ((void*)0), (GConnectFlags
) 0)
;
550
551 return launcher;
552}
553
554static void
555setup_actions (Launcher *launcher)
556{
557 GDesktopAppInfo *app_info;
558 const gchar * const *actions;
559 const gchar * const *ptr;
560
561 app_info = g_desktop_app_info_new_from_keyfile (launcher->key_file);
562 if (app_info == NULL((void*)0))
563 return;
564
565 actions = g_desktop_app_info_list_actions (app_info);
566 ptr = actions;
567 for(; *ptr != NULL((void*)0); ptr++) {
568 const gchar *action = *ptr;
569 gchar *callback = g_strdup_printf("launch-action_%s", action);
570 gchar *action_name = g_desktop_app_info_get_action_name (app_info, action);
571 mate_panel_applet_add_callback (launcher->info,
572 callback,
573 NULL((void*)0),
574 action_name,
575 NULL((void*)0));
576 g_free (callback);
577 g_free (action_name);
578 }
579
580 g_object_unref (app_info);
581}
582
583static void
584setup_button (Launcher *launcher)
585{
586 char *comment;
587 char *name;
588 char *str;
589 char *icon;
590 char *unescaped_str;
591
592 g_return_if_fail (launcher != NULL)do { if ((launcher != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "launcher != NULL"
); return; } } while (0)
;
593
594 mate_panel_applet_clear_user_menu (launcher->info);
595
596 mate_panel_applet_add_callback (launcher->info,
597 "launch",
598 "system-run",
599 _("_Launch")gettext ("_Launch"),
600 NULL((void*)0));
601
602 setup_actions (launcher);
603
604 mate_panel_applet_add_callback (launcher->info,
605 "properties",
606 "document-properties",
607 _("_Properties")gettext ("_Properties"),
608 launcher_properties_enabled);
609
610 name = panel_key_file_get_locale_string (launcher->key_file, "Name")g_key_file_get_locale_string(launcher->key_file, "Desktop Entry"
, "Name", ((void*)0), ((void*)0))
;
611 comment = panel_key_file_get_locale_string (launcher->key_file,g_key_file_get_locale_string(launcher->key_file, "Desktop Entry"
, "Comment", ((void*)0), ((void*)0))
612 "Comment")g_key_file_get_locale_string(launcher->key_file, "Desktop Entry"
, "Comment", ((void*)0), ((void*)0))
;
613
614 /* Setup tooltip */
615 if (!PANEL_GLIB_STR_EMPTY (name)((name) == ((void*)0) || (name)[0] == '\0') && !PANEL_GLIB_STR_EMPTY (comment)((comment) == ((void*)0) || (comment)[0] == '\0'))
616 str = g_strdup_printf ("%s\n%s", name, comment);
617 else if (!PANEL_GLIB_STR_EMPTY (name)((name) == ((void*)0) || (name)[0] == '\0'))
618 str = g_strdup (name)g_strdup_inline (name);
619 else
620 str = g_strdup (comment)g_strdup_inline (comment);
621
622 /* If we can unescape the string, then we probably have an escaped
623 * string (a location e.g.). If we can't, then it most probably means
624 * we have a % that is not here to encode a character, and we don't
625 * want to unescape in this case. See bug #170516 for details. */
626 unescaped_str = g_uri_unescape_string (str, NULL((void*)0));
627 if (unescaped_str) {
628 g_free (str);
629 str = unescaped_str;
630 }
631
632 panel_util_set_tooltip_text (launcher->button, str);
633
634 /* Setup accessible name */
635 panel_a11y_set_atk_name_desc (launcher->button, str, NULL((void*)0));
636
637 g_free (str);
638
639 /* Setup icon */
640 icon = panel_key_file_get_locale_string (launcher->key_file, "Icon")g_key_file_get_locale_string(launcher->key_file, "Desktop Entry"
, "Icon", ((void*)0), ((void*)0))
;
641 if (icon && icon[0] == '\0')
642 g_clear_pointer (&icon, g_free)do { _Static_assert (sizeof *(&icon) == sizeof (gpointer)
, "Expression evaluates to false"); __typeof__ ((&icon)) _pp
= (&icon); __typeof__ (*(&icon)) _ptr = *_pp; *_pp =
((void*)0); if (_ptr) (g_free) (_ptr); } while (0)
;
643
644 if (!icon) {
645 gchar *exec;
646 exec = panel_key_file_get_string (launcher->key_file, "Exec")g_key_file_get_string (launcher->key_file, "Desktop Entry"
, "Exec", ((void*)0))
;
647 if (exec && exec[0] != '\0') {
648 icon = guess_icon_from_exec (button_widget_get_icon_theme (BUTTON_WIDGET (launcher->button)((((ButtonWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((launcher->button)), ((button_widget_get_type ()))))))
),
649 exec);
650 }
651
652 g_free (exec);
653 }
654
655 if (!icon)
656 icon = g_strdup (PANEL_ICON_LAUNCHER)g_strdup_inline ("mate-panel-launcher");
657
658 button_widget_set_icon_name (BUTTON_WIDGET (launcher->button)((((ButtonWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((launcher->button)), ((button_widget_get_type ()))))))
, icon);
659 g_free (icon);
660 g_free (name);
661 g_free (comment);
662}
663
664static char *
665panel_launcher_find_writable_uri (const char *launcher_location,
666 const char *source)
667{
668 if (!launcher_location)
669 return panel_make_unique_desktop_uri (NULL((void*)0), source);
670
671 if (!strchr (launcher_location, G_DIR_SEPARATOR'/')) {
672 char *path = panel_make_full_path (NULL((void*)0), launcher_location);
673 char *uri = g_filename_to_uri (path, NULL((void*)0), NULL((void*)0));
674 g_free (path);
675 return uri;
676 }
677
678 char *filename = panel_launcher_get_filename (launcher_location);
679 if (filename != NULL((void*)0)) {
680 g_free (filename);
681 /* we have a file in the user directory. We either have a path
682 * or an URI */
683 if (g_path_is_absolute (launcher_location))
684 return g_filename_to_uri (launcher_location,
685 NULL((void*)0), NULL((void*)0));
686 else
687 return g_strdup (launcher_location)g_strdup_inline (launcher_location);
688 }
689
690 return panel_make_unique_desktop_uri (NULL((void*)0), source);
691}
692
693static void
694launcher_changed (PanelDItemEditor *dialog,
695 Launcher *launcher)
696{
697 /* Setup the button look */
698 setup_button (launcher);
699}
700
701static void
702launcher_command_changed (PanelDItemEditor *dialog,
703 const char *command,
704 Launcher *launcher)
705{
706 GKeyFile *revert_key_file = panel_ditem_editor_get_revert_key_file (dialog);
707 if (revert_key_file) {
708 char *exec = panel_key_file_get_string (launcher->key_file, "Exec")g_key_file_get_string (launcher->key_file, "Desktop Entry"
, "Exec", ((void*)0))
;
709 char *old_exec = panel_key_file_get_string (revert_key_file, "Exec")g_key_file_get_string (revert_key_file, "Desktop Entry", "Exec"
, ((void*)0))
;
710
711 if (!old_exec || !exec || strcmp (old_exec, exec))
712 panel_key_file_remove_key (launcher->key_file,g_key_file_remove_key (launcher->key_file, "Desktop Entry"
, "StartupNotify", ((void*)0))
713 "StartupNotify")g_key_file_remove_key (launcher->key_file, "Desktop Entry"
, "StartupNotify", ((void*)0))
;
714
715 g_free (exec);
716 g_free (old_exec);
717 }
718}
719
720static char *
721launcher_save_uri (PanelDItemEditor *dialog,
722 gpointer data)
723{
724 GKeyFile *key_file;
725 char *type;
726 char *exec_or_uri;
727 Launcher *launcher;
728 char *new_uri;
729 const char *uri;
730
731 key_file = panel_ditem_editor_get_key_file (dialog);
732 type = panel_key_file_get_string (key_file, "Type")g_key_file_get_string (key_file, "Desktop Entry", "Type", ((void
*)0))
;
733 if (type && !strcmp (type, "Application"))
734 exec_or_uri = panel_key_file_get_string (key_file, "Exec")g_key_file_get_string (key_file, "Desktop Entry", "Exec", ((void
*)0))
;
735 else if (type && !strcmp (type, "Link"))
736 exec_or_uri = panel_key_file_get_string (key_file, "URL")g_key_file_get_string (key_file, "Desktop Entry", "URL", ((void
*)0))
;
737 else
738 exec_or_uri = panel_key_file_get_string (key_file, "Name")g_key_file_get_string (key_file, "Desktop Entry", "Name", ((void
*)0))
;
739 g_free (type);
740
741 launcher = (Launcher *) data;
742
743 if (launcher) {
744 new_uri = panel_launcher_find_writable_uri (launcher->location,
745 exec_or_uri);
746 }
747 else
748 new_uri = panel_launcher_find_writable_uri (NULL((void*)0), exec_or_uri);
749
750 g_free (exec_or_uri);
751
752 uri = panel_ditem_editor_get_uri (dialog);
753
754 if (!uri || (new_uri && strcmp (new_uri, uri)))
755 return new_uri;
756
757 g_free (new_uri);
758
759 return NULL((void*)0);
760}
761
762static void
763launcher_saved (GtkWidget *dialog,
764 Launcher *launcher)
765{
766 const char *uri;
767 char *filename;
768
769 uri = panel_ditem_editor_get_uri (PANEL_DITEM_EDITOR (dialog)((((PanelDItemEditor*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((dialog)), ((panel_ditem_editor_get_type ())
)))))
);
770 filename = panel_launcher_get_filename(uri);
771 if (filename)
772 uri = filename;
773
774 if (uri && launcher->location && strcmp (uri, launcher->location)) {
775 g_settings_set_string (launcher->info->settings, PANEL_OBJECT_LAUNCHER_LOCATION_KEY"launcher-location", uri);
776
777 if (launcher->location)
778 g_free (launcher->location);
779
780 launcher->location = g_strdup (uri)g_strdup_inline (uri);
781 }
782
783 if (filename)
784 g_free (filename);
785}
786
787static void
788launcher_error_reported (GtkWidget *dialog,
789 const char *primary,
790 const char *secondary,
791 gpointer data)
792{
793 panel_error_dialog (GTK_WINDOW (dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_window_get_type ()))))))
, NULL((void*)0),
794 "error_editing_launcher", TRUE(!(0)),
795 primary, secondary);
796}
797
798void
799launcher_properties (Launcher *launcher)
800{
801 if (launcher->prop_dialog != NULL((void*)0)) {
802 gtk_window_set_screen (GTK_WINDOW (launcher->prop_dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((launcher->prop_dialog)), ((gtk_window_get_type ()))))
))
,
803 gtk_widget_get_screen (launcher->button));
804 gtk_window_present (GTK_WINDOW (launcher->prop_dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((launcher->prop_dialog)), ((gtk_window_get_type ()))))
))
);
805 return;
806 }
807
808 launcher->prop_dialog = panel_ditem_editor_new (NULL((void*)0),
809 launcher->key_file,
810 launcher->location,
811 _("Launcher Properties")gettext ("Launcher Properties"));
812
813 panel_widget_register_open_dialog (PANEL_WIDGET((((PanelWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_widget_get_parent (launcher->info->widget))), (
(panel_widget_get_type()))))))
814 (gtk_widget_get_parent (launcher->info->widget))((((PanelWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_widget_get_parent (launcher->info->widget))), (
(panel_widget_get_type()))))))
,
815 launcher->prop_dialog);
816
817 panel_ditem_register_save_uri_func (PANEL_DITEM_EDITOR (launcher->prop_dialog)((((PanelDItemEditor*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((launcher->prop_dialog)), ((panel_ditem_editor_get_type
()))))))
,
818 launcher_save_uri,
819 launcher);
820
821 g_signal_connect (launcher->prop_dialog, "changed",g_signal_connect_data ((launcher->prop_dialog), ("changed"
), (((GCallback) (launcher_changed))), (launcher), ((void*)0)
, (GConnectFlags) 0)
822 G_CALLBACK (launcher_changed), launcher)g_signal_connect_data ((launcher->prop_dialog), ("changed"
), (((GCallback) (launcher_changed))), (launcher), ((void*)0)
, (GConnectFlags) 0)
;
823
824 g_signal_connect (launcher->prop_dialog, "command-changed",g_signal_connect_data ((launcher->prop_dialog), ("command-changed"
), (((GCallback) (launcher_command_changed))), (launcher), ((
void*)0), (GConnectFlags) 0)
825 G_CALLBACK (launcher_command_changed), launcher)g_signal_connect_data ((launcher->prop_dialog), ("command-changed"
), (((GCallback) (launcher_command_changed))), (launcher), ((
void*)0), (GConnectFlags) 0)
;
826
827 g_signal_connect (launcher->prop_dialog, "saved",g_signal_connect_data ((launcher->prop_dialog), ("saved"),
(((GCallback) (launcher_saved))), (launcher), ((void*)0), (GConnectFlags
) 0)
828 G_CALLBACK (launcher_saved), launcher)g_signal_connect_data ((launcher->prop_dialog), ("saved"),
(((GCallback) (launcher_saved))), (launcher), ((void*)0), (GConnectFlags
) 0)
;
829
830 g_signal_connect (launcher->prop_dialog, "error-reported",g_signal_connect_data ((launcher->prop_dialog), ("error-reported"
), (((GCallback) (launcher_error_reported))), (((void*)0)), (
(void*)0), (GConnectFlags) 0)
831 G_CALLBACK (launcher_error_reported), NULL)g_signal_connect_data ((launcher->prop_dialog), ("error-reported"
), (((GCallback) (launcher_error_reported))), (((void*)0)), (
(void*)0), (GConnectFlags) 0)
;
832
833 g_signal_connect (launcher->prop_dialog, "destroy",g_signal_connect_data ((launcher->prop_dialog), ("destroy"
), (((GCallback) (gtk_widget_destroyed))), (&launcher->
prop_dialog), ((void*)0), (GConnectFlags) 0)
834 G_CALLBACK (gtk_widget_destroyed),g_signal_connect_data ((launcher->prop_dialog), ("destroy"
), (((GCallback) (gtk_widget_destroyed))), (&launcher->
prop_dialog), ((void*)0), (GConnectFlags) 0)
835 &launcher->prop_dialog)g_signal_connect_data ((launcher->prop_dialog), ("destroy"
), (((GCallback) (gtk_widget_destroyed))), (&launcher->
prop_dialog), ((void*)0), (GConnectFlags) 0)
;
836
837 gtk_widget_show (launcher->prop_dialog);
838}
839
840static gboolean
841launcher_properties_enabled (void)
842{
843 if (panel_lockdown_get_locked_down () ||
844 panel_lockdown_get_disable_command_line ())
845 return FALSE(0);
846
847 return TRUE(!(0));
848}
849
850static void
851app_desktop_file_changed (GFileMonitor *monitor,
852 GFile *file,
853 GFile *other_file,
854 GFileMonitorEvent event_type,
855 Launcher *launcher)
856{
857 if (event_type != G_FILE_MONITOR_EVENT_CHANGED &&
858 event_type != G_FILE_MONITOR_EVENT_CREATED)
859 {
860 return;
861 }
862
863 if (!strchr (launcher->location, G_DIR_SEPARATOR'/'))
864 {
865 g_key_file_load_from_file (launcher->key_file, launcher->location,
866 G_KEY_FILE_KEEP_COMMENTS|G_KEY_FILE_KEEP_TRANSLATIONS,
867 NULL((void*)0));
868 }
869 else
870 {
871 panel_key_file_load_from_uri (launcher->key_file, launcher->location,
872 G_KEY_FILE_KEEP_COMMENTS|G_KEY_FILE_KEEP_TRANSLATIONS,
873 NULL((void*)0));
874 }
875 setup_button (launcher);
876}
877
878static Launcher *
879load_launcher_applet (const char *location,
880 PanelWidget *panel,
881 gboolean locked,
882 int pos,
883 gboolean exactpos,
884 const char *id)
885{
886 Launcher *launcher;
887
888 launcher = create_launcher (location);
889
890 if (!launcher)
891 return NULL((void*)0);
892
893 launcher->info = mate_panel_applet_register (launcher->button, launcher,
894 free_launcher,
895 panel, locked, pos, exactpos,
896 PANEL_OBJECT_LAUNCHER, id);
897 if (!launcher->info) {
898 free_launcher (launcher);
899 return NULL((void*)0);
900 }
901
902 panel_widget_set_applet_expandable (panel, GTK_WIDGET (launcher->button)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((launcher->button)), ((gtk_widget_get_type ()))))))
, FALSE(0), TRUE(!(0)));
903 panel_widget_set_applet_size_constrained (panel, GTK_WIDGET (launcher->button)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((launcher->button)), ((gtk_widget_get_type ()))))))
, TRUE(!(0)));
904
905 g_signal_connect (launcher->monitor,g_signal_connect_data ((launcher->monitor), ("changed"), (
((GCallback) (app_desktop_file_changed))), (launcher), ((void
*)0), (GConnectFlags) 0)
906 "changed",g_signal_connect_data ((launcher->monitor), ("changed"), (
((GCallback) (app_desktop_file_changed))), (launcher), ((void
*)0), (GConnectFlags) 0)
907 G_CALLBACK (app_desktop_file_changed),g_signal_connect_data ((launcher->monitor), ("changed"), (
((GCallback) (app_desktop_file_changed))), (launcher), ((void
*)0), (GConnectFlags) 0)
908 launcher)g_signal_connect_data ((launcher->monitor), ("changed"), (
((GCallback) (app_desktop_file_changed))), (launcher), ((void
*)0), (GConnectFlags) 0)
;
909
910 /* setup button according to ditem */
911 setup_button (launcher);
912
913 return launcher;
914}
915
916void
917launcher_load_from_gsettings (PanelWidget *panel_widget,
918 gboolean locked,
919 int position,
920 const char *id)
921{
922 GSettings *settings;
923 char *path;
924 Launcher *launcher;
925 char *launcher_location;
926
927 g_return_if_fail (panel_widget != NULL)do { if ((panel_widget != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "panel_widget != NULL"
); return; } } while (0)
;
928 g_return_if_fail (id != NULL)do { if ((id != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "id != NULL"); return
; } } while (0)
;
929
930 path = g_strdup_printf ("%s%s/", PANEL_OBJECT_PATH"/org/mate/panel/objects/", id);
931 settings = g_settings_new_with_path (PANEL_OBJECT_SCHEMA"org.mate.panel.object", path);
932 g_free (path);
933
934 launcher_location = g_settings_get_string (settings, PANEL_OBJECT_LAUNCHER_LOCATION_KEY"launcher-location");
935
936 if (!launcher_location) {
937 g_printerr (_("Key %s is not set, cannot load launcher\n")gettext ("Key %s is not set, cannot load launcher\n"),
938 PANEL_OBJECT_LAUNCHER_LOCATION_KEY"launcher-location");
939 g_object_unref (settings);
940 return;
941 }
942
943 launcher = load_launcher_applet (launcher_location,
944 panel_widget,
945 locked,
946 position,
947 TRUE(!(0)),
948 id);
949
950 if (launcher) {
951 if (!g_settings_is_writable (settings, PANEL_OBJECT_LAUNCHER_LOCATION_KEY"launcher-location")) {
This statement is never executed
952 AppletUserMenu *menu;
953
954 menu = mate_panel_applet_get_callback (launcher->info->user_menu,
955 "properties");
956 if (menu != NULL((void*)0))
957 menu->sensitive = FALSE(0);
958 }
959 }
960
961 g_free (launcher_location);
962 g_object_unref (settings);
963}
964
965static void
966launcher_new_saved (GtkWidget *dialog,
967 gpointer data)
968{
969 PanelWidget *panel;
970 int pos;
971 const char *uri;
972 char *filename;
973
974 pos = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (dialog), "pos"))((gint) (glong) (g_object_get_data (((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((dialog)), (((GType) ((20) << (2)))
))))), "pos")))
;
975 panel = g_object_get_data (G_OBJECT (dialog)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), (((GType) ((20) << (2))))))))
, "panel");
976
977 uri = panel_ditem_editor_get_uri (PANEL_DITEM_EDITOR (dialog)((((PanelDItemEditor*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((dialog)), ((panel_ditem_editor_get_type ())
)))))
);
978 filename = panel_launcher_get_filename (uri);
979 if (filename)
980 uri = filename;
981
982 panel_launcher_create (panel->toplevel, pos, uri);
983
984 if (filename)
985 g_free (filename);
986}
987
988void
989ask_about_launcher (const char *file,
990 PanelWidget *panel,
991 int pos,
992 gboolean exactpos)
993{
994 GtkWidget *dialog;
995 GKeyFile *key_file;
996
997 if (panel_lockdown_get_disable_command_line ())
998 return;
999
1000 dialog = panel_ditem_editor_new (NULL((void*)0), NULL((void*)0), NULL((void*)0),
1001 _("Create Launcher")gettext ("Create Launcher"));
1002 panel_widget_register_open_dialog (panel, dialog);
1003
1004 key_file = panel_ditem_editor_get_key_file (PANEL_DITEM_EDITOR (dialog)((((PanelDItemEditor*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((dialog)), ((panel_ditem_editor_get_type ())
)))))
);
1005 if (file != NULL((void*)0))
1006 panel_key_file_set_string (key_file, "Exec", file)g_key_file_set_string (key_file, "Desktop Entry", "Exec", file
)
;
1007 panel_key_file_set_string (key_file, "Type", "Application")g_key_file_set_string (key_file, "Desktop Entry", "Type", "Application"
)
;
1008 panel_ditem_editor_sync_display (PANEL_DITEM_EDITOR (dialog)((((PanelDItemEditor*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((dialog)), ((panel_ditem_editor_get_type ())
)))))
);
1009
1010 panel_ditem_register_save_uri_func (PANEL_DITEM_EDITOR (dialog)((((PanelDItemEditor*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((dialog)), ((panel_ditem_editor_get_type ())
)))))
,
1011 launcher_save_uri,
1012 NULL((void*)0));
1013
1014 g_signal_connect (dialog, "saved",g_signal_connect_data ((dialog), ("saved"), (((GCallback) (launcher_new_saved
))), (((void*)0)), ((void*)0), (GConnectFlags) 0)
1015 G_CALLBACK (launcher_new_saved),g_signal_connect_data ((dialog), ("saved"), (((GCallback) (launcher_new_saved
))), (((void*)0)), ((void*)0), (GConnectFlags) 0)
1016 NULL)g_signal_connect_data ((dialog), ("saved"), (((GCallback) (launcher_new_saved
))), (((void*)0)), ((void*)0), (GConnectFlags) 0)
;
1017
1018 g_signal_connect (dialog, "error-reported",g_signal_connect_data ((dialog), ("error-reported"), (((GCallback
) (launcher_error_reported))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
1019 G_CALLBACK (launcher_error_reported),g_signal_connect_data ((dialog), ("error-reported"), (((GCallback
) (launcher_error_reported))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
1020 NULL)g_signal_connect_data ((dialog), ("error-reported"), (((GCallback
) (launcher_error_reported))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
1021
1022 gtk_window_set_screen (GTK_WINDOW (dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_window_get_type ()))))))
,
1023 gtk_widget_get_screen (GTK_WIDGET (panel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((panel)), ((gtk_widget_get_type ()))))))
));
1024
1025 g_object_set_data (G_OBJECT (dialog)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), (((GType) ((20) << (2))))))))
, "pos", GINT_TO_POINTER (pos)((gpointer) (glong) (pos)));
1026 g_object_set_data (G_OBJECT (dialog)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), (((GType) ((20) << (2))))))))
, "panel", panel);
1027
1028 gtk_widget_show (dialog);
1029}
1030
1031void
1032panel_launcher_create_from_info (PanelToplevel *toplevel,
1033 int position,
1034 gboolean exec_info,
1035 const char *exec_or_uri,
1036 const char *name,
1037 const char *comment,
1038 const char *icon)
1039{
1040 GKeyFile *key_file;
1041 char *location;
1042 GError *error;
1043
1044 key_file = panel_key_file_new_desktop ();
1045
1046 /* set current language and the "C" locale to this name,
1047 * this is kind of evil... */
1048 panel_key_file_set_string (key_file, "Name", name)g_key_file_set_string (key_file, "Desktop Entry", "Name", name
)
;
1049 panel_key_file_set_string (key_file, "Comment", comment)g_key_file_set_string (key_file, "Desktop Entry", "Comment", comment
)
;
1050 panel_key_file_set_string (key_file, "Icon", icon)g_key_file_set_string (key_file, "Desktop Entry", "Icon", icon
)
;
1051 panel_key_file_set_locale_string (key_file, "Name", name);
1052 panel_key_file_set_locale_string (key_file, "Comment", comment);
1053 panel_key_file_set_locale_string (key_file, "Icon", icon);
1054
1055 if (exec_info) {
1056 panel_key_file_set_string (key_file, "Exec", exec_or_uri)g_key_file_set_string (key_file, "Desktop Entry", "Exec", exec_or_uri
)
;
1057 panel_key_file_set_string (key_file, "Type", "Application")g_key_file_set_string (key_file, "Desktop Entry", "Type", "Application"
)
;
1058 } else {
1059 panel_key_file_set_string (key_file, "URL", exec_or_uri)g_key_file_set_string (key_file, "Desktop Entry", "URL", exec_or_uri
)
;
1060 panel_key_file_set_string (key_file, "Type", "Link")g_key_file_set_string (key_file, "Desktop Entry", "Type", "Link"
)
;
1061 }
1062
1063 location = panel_make_unique_desktop_uri (NULL((void*)0), exec_or_uri);
1064
1065 error = NULL((void*)0);
1066 if (panel_key_file_to_file (key_file, location, &error)) {
1067 panel_launcher_create (toplevel, position, location);
1068 } else {
1069 panel_error_dialog (GTK_WINDOW (toplevel)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_window_get_type ()))))))
,
1070 gtk_window_get_screen (GTK_WINDOW (toplevel)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_window_get_type ()))))))
),
1071 "cannot_save_launcher", TRUE(!(0)),
1072 _("Could not save launcher")gettext ("Could not save launcher"),
1073 error->message);
1074 g_error_free (error);
1075 }
1076
1077 g_free (location);
1078 g_key_file_free (key_file);
1079}
1080
1081void
1082panel_launcher_create_with_id (const char *toplevel_id,
1083 int position,
1084 const char *location)
1085{
1086 GSettings *settings;
1087 char *path;
1088 char *id;
1089 char *no_uri;
1090 char *new_location;
1091
1092 g_return_if_fail (location != NULL)do { if ((location != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "location != NULL"
); return; } } while (0)
;
1093
1094 id = panel_profile_prepare_object_with_id (PANEL_OBJECT_LAUNCHER,
1095 toplevel_id,
1096 position,
1097 FALSE(0));
1098
1099 path = g_strdup_printf ("%s%s/", PANEL_OBJECT_PATH"/org/mate/panel/objects/", id);
1100 settings = g_settings_new_with_path (PANEL_OBJECT_SCHEMA"org.mate.panel.object", path);
1101 g_free (path);
1102
1103 no_uri = NULL((void*)0);
1104 /* if we have an URI, it might contain escaped characters (? : etc)
1105 * that might get unescaped on disk */
1106 if (!g_ascii_strncasecmp (location, "file:", strlen ("file:")))
1107 no_uri = g_filename_from_uri (location, NULL((void*)0), NULL((void*)0));
1108 if (!no_uri)
1109 no_uri = g_strdup (location)g_strdup_inline (location);
1110
1111 new_location = panel_launcher_get_filename (no_uri);
1112 if (new_location == NULL((void*)0))
1113 new_location = g_strdup (no_uri)g_strdup_inline (no_uri);
1114
1115 g_settings_set_string (settings, PANEL_OBJECT_LAUNCHER_LOCATION_KEY"launcher-location", new_location);
1116
1117 panel_profile_add_to_list (PANEL_GSETTINGS_OBJECTS, id);
1118
1119 g_free (no_uri);
1120 g_free (new_location);
1121 g_free (id);
1122 g_object_unref (settings);
1123}
1124
1125void
1126panel_launcher_create (PanelToplevel *toplevel,
1127 int position,
1128 const char *location)
1129{
1130 panel_launcher_create_with_id (panel_profile_get_toplevel_id (toplevel),
1131 position,
1132 location);
1133}
1134
1135gboolean
1136panel_launcher_create_copy (PanelToplevel *toplevel,
1137 int position,
1138 const char *location)
1139{
1140 char *new_location;
1141 GFile *source;
1142 GFile *dest;
1143 gboolean copied;
1144
1145 new_location = panel_make_unique_desktop_uri (NULL((void*)0), location);
1146
1147 source = panel_launcher_get_gfile (location);
1148 dest = g_file_new_for_uri (new_location);
1149
1150 copied = g_file_copy (source, dest, G_FILE_COPY_OVERWRITE,
1151 NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0));
1152
1153 if (copied) {
1154 gchar *filename;
1155
1156 filename = panel_launcher_get_filename (new_location);
1157 panel_launcher_create (toplevel, position, filename);
1158 g_free (filename);
1159 }
1160
1161 g_object_unref (source);
1162 g_object_unref (dest);
1163 g_free (new_location);
1164
1165 return copied;
1166}
1167
1168Launcher *
1169find_launcher (const char *path)
1170{
1171 GSList *l;
1172
1173 g_return_val_if_fail (path != NULL, NULL)do { if ((path != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "path != NULL"); return
(((void*)0)); } } while (0)
;
1174
1175 for (l = mate_panel_applet_list_applets (); l; l = l->next) {
1176 AppletInfo *info = l->data;
1177 Launcher *launcher;
1178
1179 if (info->type != PANEL_OBJECT_LAUNCHER)
1180 continue;
1181
1182 launcher = info->data;
1183
1184 if (launcher->key_file == NULL((void*)0))
1185 continue;
1186
1187 if (launcher->location != NULL((void*)0) &&
1188 strcmp (launcher->location, path) == 0)
1189 return launcher;
1190 }
1191
1192 return NULL((void*)0);
1193}
1194
1195void
1196panel_launcher_set_dnd_enabled (Launcher *launcher,
1197 gboolean dnd_enabled)
1198{
1199 if (dnd_enabled) {
1200 static GtkTargetEntry dnd_targets[] = {
1201 { "application/x-panel-icon-internal", 0, TARGET_ICON_INTERNAL },
1202 { "text/uri-list", 0, TARGET_URI_LIST }
1203 };
1204
1205 gtk_widget_set_has_window (launcher->button, TRUE(!(0)));
1206 gtk_drag_source_set (launcher->button,
1207 GDK_BUTTON1_MASK,
1208 dnd_targets, 2,
1209 GDK_ACTION_COPY | GDK_ACTION_MOVE);
1210 cairo_surface_t *surface = button_widget_get_surface (BUTTON_WIDGET (launcher->button)((((ButtonWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((launcher->button)), ((button_widget_get_type ()))))))
);
1211 if (surface) {
1212 GdkPixbuf *pixbuf;
1213 pixbuf = gdk_pixbuf_get_from_surface (surface,
1214 0,
1215 0,
1216 cairo_image_surface_get_width (surface),
1217 cairo_image_surface_get_height (surface));
1218 gtk_drag_source_set_icon_pixbuf (launcher->button,
1219 pixbuf);
1220 g_object_unref (pixbuf);
1221 cairo_surface_destroy (surface);
1222 }
1223 gtk_widget_set_has_window (launcher->button, FALSE(0));
1224 } else
1225 gtk_drag_source_unset (launcher->button);
1226}
diff --git a/2024-06-18-172109-13286-1@e182420b844f_master/report-51a1d8.html b/2024-06-18-172109-13286-1@e182420b844f_master/report-51a1d8.html new file mode 100644 index 00000000..ae073711 --- /dev/null +++ b/2024-06-18-172109-13286-1@e182420b844f_master/report-51a1d8.html @@ -0,0 +1,3246 @@ + + + +mate-panel-applet.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:libmate-panel-applet/mate-panel-applet.c
Warning:line 228, column 37
Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name mate-panel-applet.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/libmate-panel-applet -fcoverage-compilation-dir=/rootdir/libmate-panel-applet -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I .. -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/gio-unix-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I ../libmate-panel-applet -D MATELOCALEDIR="/usr/local/share/locale" -D PIC -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-18-172109-13286-1 -x c mate-panel-applet.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * mate-panel-applet.c: panel applet writing library.
3 *
4 * Copyright (c) 2010 Carlos Garcia Campos <carlosgc@gnome.org>
5 * Copyright (C) 2001 Sun Microsystems, Inc.
6 * Copyright (C) 2012-2021 MATE Developers
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
17 *
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the
20 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22 *
23 * Authors:
24 * Mark McLoughlin <mark@skynet.ie>
25 */
26
27#ifdef HAVE_CONFIG_H1
28#include <config.h>
29#endif
30
31#include <unistd.h>
32#include <stdlib.h>
33#include <string.h>
34
35#include <glib/gi18n-lib.h>
36#include <cairo.h>
37#include <gdk/gdk.h>
38#include <gdk/gdkkeysyms.h>
39#include <gtk/gtk.h>
40
41#ifdef HAVE_X111
42#include <cairo-xlib.h>
43#include <gdk/gdkx.h>
44#include <gtk/gtkx.h>
45#include <X11/Xatom.h>
46#include "panel-plug-private.h"
47#endif
48
49#include "mate-panel-applet.h"
50#include "panel-applet-private.h"
51#include "mate-panel-applet-factory.h"
52#include "mate-panel-applet-marshal.h"
53#include "mate-panel-applet-enums.h"
54
55typedef struct {
56 GtkWidget *plug;
57 GDBusConnection *connection;
58
59 gboolean out_of_process;
60
61 char *id;
62 GClosure *closure;
63 char *object_path;
64 guint object_id;
65 char *prefs_path;
66
67 GtkUIManager *ui_manager;
68 GtkActionGroup *applet_action_group;
69 GtkActionGroup *panel_action_group;
70
71 MatePanelAppletFlags flags;
72 MatePanelAppletOrient orient;
73 guint size;
74 char *background;
75
76 int previous_width;
77 int previous_height;
78
79 int *size_hints;
80 int size_hints_len;
81
82 gboolean moving_focus_out;
83
84 gboolean locked;
85 gboolean locked_down;
86} MatePanelAppletPrivate;
87
88enum {
89 CHANGE_ORIENT,
90 CHANGE_SIZE,
91 CHANGE_BACKGROUND,
92 MOVE_FOCUS_OUT_OF_APPLET,
93 LAST_SIGNAL
94};
95
96static guint mate_panel_applet_signals[LAST_SIGNAL] = { 0 };
97
98enum {
99 PROP_0,
100 PROP_OUT_OF_PROCESS,
101 PROP_ID,
102 PROP_CLOSURE,
103 PROP_CONNECTION,
104 PROP_PREFS_PATH,
105 PROP_ORIENT,
106 PROP_SIZE,
107 PROP_BACKGROUND,
108 PROP_FLAGS,
109 PROP_SIZE_HINTS,
110 PROP_LOCKED,
111 PROP_LOCKED_DOWN
112};
113
114static void mate_panel_applet_handle_background (MatePanelApplet *applet);
115static GtkAction *mate_panel_applet_menu_get_action (MatePanelApplet *applet,
116 const gchar *action);
117static void mate_panel_applet_menu_update_actions (MatePanelApplet *applet);
118static void mate_panel_applet_menu_cmd_remove (GtkAction *action,
119 MatePanelApplet *applet);
120static void mate_panel_applet_menu_cmd_move (GtkAction *action,
121 MatePanelApplet *applet);
122static void mate_panel_applet_menu_cmd_lock (GtkAction *action,
123 MatePanelApplet *applet);
124static void mate_panel_applet_register_object (MatePanelApplet *applet);
125void _mate_panel_applet_apply_css (GtkWidget* widget, MatePanelAppletBackgroundType type);
126
127static const gchar panel_menu_ui[] =
128 "<ui>\n"
129 " <popup name=\"MatePanelAppletPopup\" action=\"PopupAction\">\n"
130 " <placeholder name=\"AppletItems\"/>\n"
131 " <separator/>\n"
132 " <menuitem name=\"RemoveItem\" action=\"Remove\"/>\n"
133 " <menuitem name=\"MoveItem\" action=\"Move\"/>\n"
134 " <separator/>\n"
135 " <menuitem name=\"LockItem\" action=\"Lock\"/>\n"
136 " </popup>\n"
137 "</ui>\n";
138
139static const GtkActionEntry menu_entries[] = {
140 { "Remove", "list-remove", N_("_Remove From Panel")("_Remove From Panel"),
141 NULL((void*)0), NULL((void*)0),
142 G_CALLBACK (mate_panel_applet_menu_cmd_remove)((GCallback) (mate_panel_applet_menu_cmd_remove)) },
143 { "Move", NULL((void*)0), N_("_Move")("_Move"),
144 NULL((void*)0), NULL((void*)0),
145 G_CALLBACK (mate_panel_applet_menu_cmd_move)((GCallback) (mate_panel_applet_menu_cmd_move)) }
146};
147
148static const GtkToggleActionEntry menu_toggle_entries[] = {
149 { "Lock", NULL((void*)0), N_("Loc_k To Panel")("Loc_k To Panel"),
150 NULL((void*)0), NULL((void*)0),
151 G_CALLBACK (mate_panel_applet_menu_cmd_lock)((GCallback) (mate_panel_applet_menu_cmd_lock)),
152 FALSE(0) }
153};
154
155G_DEFINE_TYPE_WITH_PRIVATE (MatePanelApplet, mate_panel_applet, GTK_TYPE_EVENT_BOX)static void mate_panel_applet_init (MatePanelApplet *self); static
void mate_panel_applet_class_init (MatePanelAppletClass *klass
); static GType mate_panel_applet_get_type_once (void); static
gpointer mate_panel_applet_parent_class = ((void*)0); static
gint MatePanelApplet_private_offset; static void mate_panel_applet_class_intern_init
(gpointer klass) { mate_panel_applet_parent_class = g_type_class_peek_parent
(klass); if (MatePanelApplet_private_offset != 0) g_type_class_adjust_private_offset
(klass, &MatePanelApplet_private_offset); mate_panel_applet_class_init
((MatePanelAppletClass*) klass); } __attribute__ ((__unused__
)) static inline gpointer mate_panel_applet_get_instance_private
(MatePanelApplet *self) { return (((gpointer) ((guint8*) (self
) + (glong) (MatePanelApplet_private_offset)))); } GType mate_panel_applet_get_type
(void) { static GType static_g_define_type_id = 0; if ((__extension__
({ _Static_assert (sizeof *(&static_g_define_type_id) ==
sizeof (gpointer), "Expression evaluates to false"); (void) (
0 ? (gpointer) * (&static_g_define_type_id) : ((void*)0))
; (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter_pointer (
&static_g_define_type_id)); })) ) { GType g_define_type_id
= mate_panel_applet_get_type_once (); (__extension__ ({ _Static_assert
(sizeof *(&static_g_define_type_id) == sizeof (gpointer)
, "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id
) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer
((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id
)); })) ; } return static_g_define_type_id; } __attribute__ (
(__noinline__)) static GType mate_panel_applet_get_type_once (
void) { GType g_define_type_id = g_type_register_static_simple
((gtk_event_box_get_type ()), g_intern_static_string ("MatePanelApplet"
), sizeof (MatePanelAppletClass), (GClassInitFunc)(void (*)(void
)) mate_panel_applet_class_intern_init, sizeof (MatePanelApplet
), (GInstanceInitFunc)(void (*)(void)) mate_panel_applet_init
, (GTypeFlags) 0); { {{ MatePanelApplet_private_offset = g_type_add_instance_private
(g_define_type_id, sizeof (MatePanelAppletPrivate)); };} } return
g_define_type_id; }
156
157#define MATE_PANEL_APPLET_INTERFACE"org.mate.panel.applet.Applet" "org.mate.panel.applet.Applet"
158#define MATE_PANEL_APPLET_OBJECT_PATH"/org/mate/panel/applet/%s/%d" "/org/mate/panel/applet/%s/%d"
159
160char *
161mate_panel_applet_get_preferences_path (MatePanelApplet *applet)
162{
163 MatePanelAppletPrivate *priv;
164
165 g_return_val_if_fail (MATE_PANEL_IS_APPLET (applet), NULL)do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return (((void*)0)); } } while (0)
;
166
167 priv = mate_panel_applet_get_instance_private (applet);
168 if (!priv->prefs_path)
169 return NULL((void*)0);
170
171 return g_strdup (priv->prefs_path)g_strdup_inline (priv->prefs_path);
172}
173
174static void
175mate_panel_applet_set_preferences_path (MatePanelApplet *applet,
176 const char *prefs_path)
177{
178 MatePanelAppletPrivate *priv;
179
180 priv = mate_panel_applet_get_instance_private (applet);
181
182 if (priv->prefs_path == prefs_path)
183 return;
184
185 if (g_strcmp0 (priv->prefs_path, prefs_path) == 0)
186 return;
187
188 if (prefs_path)
189 priv->prefs_path = g_strdup (prefs_path)g_strdup_inline (prefs_path);
190
191 g_object_notify (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
, "prefs-path");
192}
193
194MatePanelAppletFlags
195mate_panel_applet_get_flags (MatePanelApplet *applet)
196{
197 MatePanelAppletPrivate *priv;
198
199 g_return_val_if_fail (MATE_PANEL_IS_APPLET (applet), MATE_PANEL_APPLET_FLAGS_NONE)do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return (MATE_PANEL_APPLET_FLAGS_NONE); } } while (0)
;
200
201 priv = mate_panel_applet_get_instance_private (applet);
202
203 return priv->flags;
204}
205
206void
207mate_panel_applet_set_flags (MatePanelApplet *applet,
208 MatePanelAppletFlags flags)
209{
210 MatePanelAppletPrivate *priv;
211
212 g_return_if_fail (MATE_PANEL_IS_APPLET (applet))do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return; } } while (0)
;
213
214 priv = mate_panel_applet_get_instance_private (applet);
215
216 if (priv->flags == flags)
217 return;
218
219 priv->flags = flags;
220
221 g_object_notify (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
, "flags");
222
223 if (priv->connection) {
224 GVariantBuilder builder;
225 GVariantBuilder invalidated_builder;
226 GError *error = NULL((void*)0);
227
228 g_variant_builder_init (&builder, G_VARIANT_TYPE_ARRAY((const GVariantType *) "a*"));
Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption
229 g_variant_builder_init (&invalidated_builder, G_VARIANT_TYPE ("as")(g_variant_type_checked_ (("as"))));
230
231 g_variant_builder_add (&builder, "{sv}", "Flags",
232 g_variant_new_uint32 (priv->flags));
233
234 g_dbus_connection_emit_signal (priv->connection,
235 NULL((void*)0),
236 priv->object_path,
237 "org.freedesktop.DBus.Properties",
238 "PropertiesChanged",
239 g_variant_new ("(sa{sv}as)",
240 MATE_PANEL_APPLET_INTERFACE"org.mate.panel.applet.Applet",
241 &builder,
242 &invalidated_builder),
243 &error);
244 if (error) {
245 g_printerr ("Failed to send signal PropertiesChanged::Flags: %s\n",
246 error->message);
247 g_error_free (error);
248 }
249 g_variant_builder_clear (&builder);
250 g_variant_builder_clear (&invalidated_builder);
251 }
252}
253
254static void
255mate_panel_applet_size_hints_ensure (MatePanelApplet *applet,
256 int new_size)
257{
258 MatePanelAppletPrivate *priv;
259
260 priv = mate_panel_applet_get_instance_private (applet);
261 if (priv->size_hints && priv->size_hints_len < new_size) {
262 g_free (priv->size_hints);
263 priv->size_hints = g_new (gint, new_size)((gint *) g_malloc_n ((new_size), sizeof (gint)));
264 } else if (!priv->size_hints) {
265 priv->size_hints = g_new (gint, new_size)((gint *) g_malloc_n ((new_size), sizeof (gint)));
266 }
267 priv->size_hints_len = new_size;
268}
269
270static gboolean
271mate_panel_applet_size_hints_changed (MatePanelApplet *applet,
272 const int *size_hints,
273 int n_elements,
274 int base_size)
275{
276 MatePanelAppletPrivate *priv;
277 gint i;
278
279 priv = mate_panel_applet_get_instance_private (applet);
280
281 if (!priv->size_hints)
282 return TRUE(!(0));
283
284 if (priv->size_hints_len != n_elements)
285 return TRUE(!(0));
286
287 for (i = 0; i < n_elements; i++) {
288 if (size_hints[i] + base_size != priv->size_hints[i])
289 return TRUE(!(0));
290 }
291
292 return FALSE(0);
293}
294
295/**
296 * mate_panel_applet_set_size_hints:
297 * @applet: applet
298 * @size_hints: (array length=n_elements): List of integers
299 * @n_elements: Length of @size_hints
300 * @base_size: base_size
301 */
302void
303mate_panel_applet_set_size_hints (MatePanelApplet *applet,
304 const int *size_hints,
305 int n_elements,
306 int base_size)
307{
308 MatePanelAppletPrivate *priv;
309 gint i;
310
311 /* Make sure property has really changed to avoid bus traffic */
312 if (!mate_panel_applet_size_hints_changed (applet, size_hints, n_elements, base_size))
313 return;
314
315 priv = mate_panel_applet_get_instance_private (applet);
316
317 mate_panel_applet_size_hints_ensure (applet, n_elements);
318 for (i = 0; i < n_elements; i++)
319 priv->size_hints[i] = size_hints[i] + base_size;
320
321 g_object_notify (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
, "size-hints");
322
323 if (priv->connection) {
324 GVariantBuilder builder;
325 GVariantBuilder invalidated_builder;
326 GVariant **children;
327 GError *error = NULL((void*)0);
328
329 g_variant_builder_init (&builder, G_VARIANT_TYPE_ARRAY((const GVariantType *) "a*"));
330 g_variant_builder_init (&invalidated_builder, G_VARIANT_TYPE ("as")(g_variant_type_checked_ (("as"))));
331
332 children = g_new (GVariant *, priv->size_hints_len)((GVariant * *) g_malloc_n ((priv->size_hints_len), sizeof
(GVariant *)))
;
333 for (i = 0; i < n_elements; i++)
334 children[i] = g_variant_new_int32 (priv->size_hints[i]);
335 g_variant_builder_add (&builder, "{sv}", "SizeHints",
336 g_variant_new_array (G_VARIANT_TYPE_INT32((const GVariantType *) "i"),
337 children, priv->size_hints_len));
338 g_free (children);
339
340 g_dbus_connection_emit_signal (priv->connection,
341 NULL((void*)0),
342 priv->object_path,
343 "org.freedesktop.DBus.Properties",
344 "PropertiesChanged",
345 g_variant_new ("(sa{sv}as)",
346 MATE_PANEL_APPLET_INTERFACE"org.mate.panel.applet.Applet",
347 &builder,
348 &invalidated_builder),
349 &error);
350 if (error) {
351 g_printerr ("Failed to send signal PropertiesChanged::SizeHints: %s\n",
352 error->message);
353 g_error_free (error);
354 }
355 g_variant_builder_clear (&builder);
356 g_variant_builder_clear (&invalidated_builder);
357 }
358}
359
360guint
361mate_panel_applet_get_size (MatePanelApplet *applet)
362{
363 MatePanelAppletPrivate *priv;
364
365 g_return_val_if_fail (MATE_PANEL_IS_APPLET (applet), 0)do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return (0); } } while (0)
;
366
367 priv = mate_panel_applet_get_instance_private (applet);
368
369 return priv->size;
370}
371
372/* Applets cannot set their size, so API is not public. */
373static void
374mate_panel_applet_set_size (MatePanelApplet *applet,
375 guint size)
376{
377 MatePanelAppletPrivate *priv;
378
379 g_return_if_fail (MATE_PANEL_IS_APPLET (applet))do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return; } } while (0)
;
380
381 priv = mate_panel_applet_get_instance_private (applet);
382
383 if (priv->size == size)
384 return;
385
386 priv->size = size;
387 g_signal_emit (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
,
388 mate_panel_applet_signals [CHANGE_SIZE],
389 0, size);
390
391 g_object_notify (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
, "size");
392}
393
394MatePanelAppletOrient
395mate_panel_applet_get_orient (MatePanelApplet *applet)
396{
397 MatePanelAppletPrivate *priv;
398
399 g_return_val_if_fail (MATE_PANEL_IS_APPLET (applet), 0)do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return (0); } } while (0)
;
400
401 priv = mate_panel_applet_get_instance_private (applet);
402
403 return priv->orient;
404}
405
406/* Applets cannot set their orientation, so API is not public. */
407static void
408mate_panel_applet_set_orient (MatePanelApplet *applet,
409 MatePanelAppletOrient orient)
410{
411 MatePanelAppletPrivate *priv;
412
413 g_return_if_fail (MATE_PANEL_IS_APPLET (applet))do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return; } } while (0)
;
414
415 priv = mate_panel_applet_get_instance_private (applet);
416
417 if (priv->orient == orient)
418 return;
419
420 priv->orient = orient;
421 g_signal_emit (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
,
422 mate_panel_applet_signals [CHANGE_ORIENT],
423 0, orient);
424
425 g_object_notify (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
, "orient");
426}
427
428static void
429mate_panel_applet_set_locked (MatePanelApplet *applet,
430 gboolean locked)
431{
432 MatePanelAppletPrivate *priv;
433 GtkAction *action;
434
435 g_return_if_fail (MATE_PANEL_IS_APPLET (applet))do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return; } } while (0)
;
436
437 priv = mate_panel_applet_get_instance_private (applet);
438
439 if (priv->locked == locked)
440 return;
441
442 priv->locked = locked;
443
444 action = mate_panel_applet_menu_get_action (applet, "Lock");
445 g_signal_handlers_block_by_func (action,g_signal_handlers_block_matched ((action), (GSignalMatchType)
(G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0
), (mate_panel_applet_menu_cmd_lock), (applet))
446 mate_panel_applet_menu_cmd_lock,g_signal_handlers_block_matched ((action), (GSignalMatchType)
(G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0
), (mate_panel_applet_menu_cmd_lock), (applet))
447 applet)g_signal_handlers_block_matched ((action), (GSignalMatchType)
(G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0
), (mate_panel_applet_menu_cmd_lock), (applet))
;
448 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action)((((GtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((gtk_toggle_action_get_type ()))))))
, locked);
449 g_signal_handlers_unblock_by_func (action,g_signal_handlers_unblock_matched ((action), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (mate_panel_applet_menu_cmd_lock), (applet))
450 mate_panel_applet_menu_cmd_lock,g_signal_handlers_unblock_matched ((action), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (mate_panel_applet_menu_cmd_lock), (applet))
451 applet)g_signal_handlers_unblock_matched ((action), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (mate_panel_applet_menu_cmd_lock), (applet))
;
452
453 mate_panel_applet_menu_update_actions (applet);
454
455 g_object_notify (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
, "locked");
456
457 if (priv->connection) {
458 GError *error = NULL((void*)0);
459
460 g_dbus_connection_emit_signal (priv->connection,
461 NULL((void*)0),
462 priv->object_path,
463 MATE_PANEL_APPLET_INTERFACE"org.mate.panel.applet.Applet",
464 locked ? "Lock" : "Unlock",
465 NULL((void*)0), &error);
466 if (error) {
467 g_printerr ("Failed to send signal %s: %s\n",
468 locked ? "Lock" : "Unlock",
469 error->message);
470 g_error_free (error);
471 }
472 }
473}
474
475gboolean
476mate_panel_applet_get_locked_down (MatePanelApplet *applet)
477{
478 MatePanelAppletPrivate *priv;
479
480 g_return_val_if_fail (MATE_PANEL_IS_APPLET (applet), FALSE)do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return ((0)); } } while (0)
;
481
482 priv = mate_panel_applet_get_instance_private (applet);
483
484 return priv->locked_down;
485}
486
487/* Applets cannot set the lockdown state, so API is not public. */
488static void
489mate_panel_applet_set_locked_down (MatePanelApplet *applet,
490 gboolean locked_down)
491{
492 MatePanelAppletPrivate *priv;
493
494 g_return_if_fail (MATE_PANEL_IS_APPLET (applet))do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return; } } while (0)
;
495
496 priv = mate_panel_applet_get_instance_private (applet);
497
498 if (priv->locked_down == locked_down)
499 return;
500
501 priv->locked_down = locked_down;
502 mate_panel_applet_menu_update_actions (applet);
503
504 g_object_notify (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
, "locked-down");
505}
506
507#ifdef HAVE_X111
508
509static Atom _net_wm_window_type = None0L;
510static Atom _net_wm_window_type_dock = None0L;
511static Atom _net_active_window = None0L;
512
513static void
514mate_panel_applet_init_atoms (Display *xdisplay)
515{
516 if (_net_wm_window_type == None0L)
517 _net_wm_window_type = XInternAtom (xdisplay,
518 "_NET_WM_WINDOW_TYPE",
519 False0);
520
521 if (_net_wm_window_type_dock == None0L)
522 _net_wm_window_type_dock = XInternAtom (xdisplay,
523 "_NET_WM_WINDOW_TYPE_DOCK",
524 False0);
525
526 if (_net_active_window == None0L)
527 _net_active_window = XInternAtom (xdisplay,
528 "_NET_ACTIVE_WINDOW",
529 False0);
530}
531
532static Window
533mate_panel_applet_find_toplevel_dock_window (MatePanelApplet *applet,
534 Display *xdisplay)
535{
536 GtkWidget *toplevel;
537 Window xwin;
538 Window root, parent, *child;
539 int num_children;
540
541 toplevel = gtk_widget_get_toplevel (GTK_WIDGET (applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
);
542 if (!gtk_widget_get_realized (toplevel))
543 return None0L;
544
545 xwin = GDK_WINDOW_XID (gtk_widget_get_window (toplevel))(gdk_x11_window_get_xid (gtk_widget_get_window (toplevel)));
546
547 child = NULL((void*)0);
548 parent = root = None0L;
549 do {
550 Atom type_return;
551 Atom window_type;
552 int format_return;
553 gulong number_return, bytes_after_return;
554 guchar *data_return;
555
556 XGetWindowProperty (xdisplay,
557 xwin,
558 _net_wm_window_type,
559 0, 1, False0,
560 XA_ATOM((Atom) 4),
561 &type_return, &format_return,
562 &number_return,
563 &bytes_after_return,
564 &data_return);
565
566 if (type_return == XA_ATOM((Atom) 4)) {
567 window_type = *(Atom *) data_return;
568
569 XFree (data_return);
570 data_return = NULL((void*)0);
571
572 if (window_type == _net_wm_window_type_dock)
573 return xwin;
574 }
575
576 if (!XQueryTree (xdisplay,
577 xwin,
578 &root, &parent, &child,
579 (guint *) &num_children)) {
580 return None0L;
581 }
582
583 if (child && num_children > 0)
584 XFree (child);
585
586 xwin = parent;
587
588 } while (xwin != None0L && xwin != root);
589
590 return None0L;
591}
592
593#endif /* HAVE_X11 */
594
595/* This function
596 * 1) Gets the window id of the panel that contains the applet
597 * using XQueryTree and XGetWindowProperty to find an ancestor
598 * window with the _NET_WM_WINDOW_TYPE_DOCK window type.
599 * 2) Sends a _NET_ACTIVE_WINDOW message to get that panel focused
600 */
601void
602mate_panel_applet_request_focus (MatePanelApplet *applet,
603 guint32 timestamp)
604{
605#ifdef HAVE_X111
606 GdkScreen *screen;
607 GdkWindow *root;
608 GdkDisplay *display;
609 Display *xdisplay;
610 Window dock_xwindow;
611 Window xroot;
612 XEvent xev;
613
614 if (!GDK_IS_X11_DISPLAY (gdk_display_get_default ())(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gdk_display_get_default ())); GType __t = ((gdk_x11_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
)
615 return;
616
617 g_return_if_fail (MATE_PANEL_IS_APPLET (applet))do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return; } } while (0)
;
618
619 screen = gdk_screen_get_default(); /*There is only one screen since GTK 3.22*/
620 root = gdk_screen_get_root_window (screen);
621 display = gdk_screen_get_display (screen);
622
623 xdisplay = GDK_DISPLAY_XDISPLAY (display)(gdk_x11_display_get_xdisplay (display));
624 xroot = GDK_WINDOW_XID (root)(gdk_x11_window_get_xid (root));
625
626 mate_panel_applet_init_atoms (xdisplay);
627
628 dock_xwindow = mate_panel_applet_find_toplevel_dock_window (applet, xdisplay);
629 if (dock_xwindow == None0L)
630 return;
631
632 xev.xclient.type = ClientMessage33;
633 xev.xclient.serial = 0;
634 xev.xclient.send_event = True1;
635 xev.xclient.window = dock_xwindow;
636 xev.xclient.message_type = _net_active_window;
637 xev.xclient.format = 32;
638 xev.xclient.data.l[0] = 1; /* requestor type; we're an app, I guess */
639 xev.xclient.data.l[1] = timestamp;
640 xev.xclient.data.l[2] = None0L; /* "currently active window", supposedly */
641 xev.xclient.data.l[3] = 0;
642 xev.xclient.data.l[4] = 0;
643
644 XSendEvent (xdisplay,
645 xroot, False0,
646 SubstructureRedirectMask(1L<<20) | SubstructureNotifyMask(1L<<19),
647 &xev);
648#endif
649}
650
651static GtkAction *
652mate_panel_applet_menu_get_action (MatePanelApplet *applet,
653 const gchar *action)
654{
655 MatePanelAppletPrivate *priv;
656
657 priv = mate_panel_applet_get_instance_private (applet);
658
659 return gtk_action_group_get_action (priv->panel_action_group, action);
660}
661
662static void
663mate_panel_applet_menu_update_actions (MatePanelApplet *applet)
664{
665 MatePanelAppletPrivate *priv;
666
667 priv = mate_panel_applet_get_instance_private (applet);
668 g_object_set (mate_panel_applet_menu_get_action (applet, "Lock"),
669 "visible", !priv->locked_down,
670 NULL((void*)0));
671 g_object_set (mate_panel_applet_menu_get_action (applet, "Move"),
672 "sensitive", !priv->locked,
673 "visible", !priv->locked_down,
674 NULL((void*)0));
675 g_object_set (mate_panel_applet_menu_get_action (applet, "Remove"),
676 "sensitive", !priv->locked,
677 "visible", !priv->locked_down,
678 NULL((void*)0));
679}
680
681static void
682mate_panel_applet_menu_cmd_remove (GtkAction *action,
683 MatePanelApplet *applet)
684{
685 MatePanelAppletPrivate *priv;
686 GError *error = NULL((void*)0);
687
688 priv = mate_panel_applet_get_instance_private (applet);
689
690 if (!priv->connection)
691 return;
692
693 g_dbus_connection_emit_signal (priv->connection,
694 NULL((void*)0),
695 priv->object_path,
696 MATE_PANEL_APPLET_INTERFACE"org.mate.panel.applet.Applet",
697 "RemoveFromPanel",
698 NULL((void*)0), &error);
699 if (error) {
700 g_printerr ("Failed to send signal RemoveFromPanel: %s\n",
701 error->message);
702 g_error_free (error);
703 }
704}
705
706static void
707mate_panel_applet_menu_cmd_move (GtkAction *action,
708 MatePanelApplet *applet)
709{
710 MatePanelAppletPrivate *priv;
711 GError *error = NULL((void*)0);
712
713 priv = mate_panel_applet_get_instance_private (applet);
714
715 if (!priv->connection)
716 return;
717
718 g_dbus_connection_emit_signal (priv->connection,
719 NULL((void*)0),
720 priv->object_path,
721 MATE_PANEL_APPLET_INTERFACE"org.mate.panel.applet.Applet",
722 "Move",
723 NULL((void*)0), &error);
724 if (error) {
725 g_printerr ("Failed to send signal RemoveFromPanel: %s\n",
726 error->message);
727 g_error_free (error);
728 }
729}
730
731static void
732mate_panel_applet_menu_cmd_lock (GtkAction *action,
733 MatePanelApplet *applet)
734{
735 gboolean locked;
736
737 locked = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)((((GtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((gtk_toggle_action_get_type ()))))))
);
738 mate_panel_applet_set_locked (applet, locked);
739}
740
741void
742mate_panel_applet_setup_menu (MatePanelApplet *applet,
743 const gchar *xml,
744 GtkActionGroup *applet_action_group)
745{
746 MatePanelAppletPrivate *priv;
747 gchar *new_xml;
748 GError *error = NULL((void*)0);
749
750 g_return_if_fail (MATE_PANEL_IS_APPLET (applet))do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return; } } while (0)
;
751 g_return_if_fail (xml != NULL)do { if ((xml != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "xml != NULL"); return
; } } while (0)
;
752
753 priv = mate_panel_applet_get_instance_private (applet);
754
755 if (priv->applet_action_group)
756 return;
757
758 priv->applet_action_group = g_object_ref (applet_action_group)((__typeof__ (applet_action_group)) (g_object_ref) (applet_action_group
))
;
759 gtk_ui_manager_insert_action_group (priv->ui_manager,
760 applet_action_group, 0);
761
762 new_xml = g_strdup_printf ("<ui><popup name=\"MatePanelAppletPopup\" action=\"AppletItems\">"
763 "<placeholder name=\"AppletItems\">%s\n</placeholder>\n"
764 "</popup></ui>\n", xml);
765 gtk_ui_manager_add_ui_from_string (priv->ui_manager, new_xml, -1, &error);
766 g_free (new_xml);
767 gtk_ui_manager_ensure_update (priv->ui_manager);
768 if (error) {
769 g_warning ("Error merging menus: %s\n", error->message);
770 g_error_free (error);
771 }
772}
773
774void
775mate_panel_applet_setup_menu_from_file (MatePanelApplet *applet,
776 const gchar *filename,
777 GtkActionGroup *applet_action_group)
778{
779 gchar *xml = NULL((void*)0);
780 GError *error = NULL((void*)0);
781
782 if (g_file_get_contents (filename, &xml, NULL((void*)0), &error)) {
783 mate_panel_applet_setup_menu (applet, xml, applet_action_group);
784 } else {
785 g_warning ("%s", error->message);
786 g_error_free (error);
787 }
788
789 g_free (xml);
790}
791
792/**
793 * mate_panel_applet_setup_menu_from_resource:
794 * @applet: a #MatePanelApplet.
795 * @resource_path: a resource path
796 * @action_group: a #GtkActionGroup.
797 *
798 * Sets up the context menu of @applet. @filename is a resource path to a menu
799 * XML file, containing a #GtkUIManager UI definition that describes how to
800 * display the menu items. @action_group contains the various #GtkAction that
801 * are referenced in @xml.
802 *
803 * See also the <link linkend="getting-started.context-menu">Context
804 * Menu</link> section.
805 *
806 * Since: 1.20.1
807 **/
808void
809mate_panel_applet_setup_menu_from_resource (MatePanelApplet *applet,
810 const gchar *resource_path,
811 GtkActionGroup *action_group)
812{
813 GBytes *bytes;
814 GError *error = NULL((void*)0);
815
816 bytes = g_resources_lookup_data (resource_path,
817 G_RESOURCE_LOOKUP_FLAGS_NONE,
818 &error);
819
820 if (bytes) {
821 mate_panel_applet_setup_menu (applet,
822 g_bytes_get_data (bytes, NULL((void*)0)),
823 action_group);
824 } else {
825 g_warning ("%s", error->message);
826 g_error_free (error);
827 }
828
829 g_bytes_unref (bytes);
830}
831
832static void
833mate_panel_applet_finalize (GObject *object)
834{
835 MatePanelApplet *applet;
836 MatePanelAppletPrivate *priv;
837
838 applet = MATE_PANEL_APPLET (object);
839 priv = mate_panel_applet_get_instance_private (applet);
840
841 if (priv->connection) {
842 if (priv->object_id)
843 g_dbus_connection_unregister_object (priv->connection,
844 priv->object_id);
845 priv->object_id = 0;
846 g_clear_object (&priv->connection)do { _Static_assert (sizeof *((&priv->connection)) == sizeof
(gpointer), "Expression evaluates to false"); __typeof__ (((
&priv->connection))) _pp = ((&priv->connection)
); __typeof__ (*((&priv->connection))) _ptr = *_pp; *_pp
= ((void*)0); if (_ptr) (g_object_unref) (_ptr); } while (0)
;
847 }
848
849 g_clear_pointer (&priv->object_path, g_free)do { _Static_assert (sizeof *(&priv->object_path) == sizeof
(gpointer), "Expression evaluates to false"); __typeof__ ((&
priv->object_path)) _pp = (&priv->object_path); __typeof__
(*(&priv->object_path)) _ptr = *_pp; *_pp = ((void*)0
); if (_ptr) (g_free) (_ptr); } while (0)
;
850
851 mate_panel_applet_set_preferences_path (applet, NULL((void*)0));
852
853 g_clear_object (&priv->applet_action_group)do { _Static_assert (sizeof *((&priv->applet_action_group
)) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(((&priv->applet_action_group))) _pp = ((&priv->
applet_action_group)); __typeof__ (*((&priv->applet_action_group
))) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (g_object_unref
) (_ptr); } while (0)
;
854 g_clear_object (&priv->panel_action_group)do { _Static_assert (sizeof *((&priv->panel_action_group
)) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(((&priv->panel_action_group))) _pp = ((&priv->
panel_action_group)); __typeof__ (*((&priv->panel_action_group
))) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (g_object_unref
) (_ptr); } while (0)
;
855 g_clear_object (&priv->ui_manager)do { _Static_assert (sizeof *((&priv->ui_manager)) == sizeof
(gpointer), "Expression evaluates to false"); __typeof__ (((
&priv->ui_manager))) _pp = ((&priv->ui_manager)
); __typeof__ (*((&priv->ui_manager))) _ptr = *_pp; *_pp
= ((void*)0); if (_ptr) (g_object_unref) (_ptr); } while (0)
;
856
857 g_clear_pointer (&priv->size_hints, g_free)do { _Static_assert (sizeof *(&priv->size_hints) == sizeof
(gpointer), "Expression evaluates to false"); __typeof__ ((&
priv->size_hints)) _pp = (&priv->size_hints); __typeof__
(*(&priv->size_hints)) _ptr = *_pp; *_pp = ((void*)0)
; if (_ptr) (g_free) (_ptr); } while (0)
;
858 g_clear_pointer (&priv->prefs_path, g_free)do { _Static_assert (sizeof *(&priv->prefs_path) == sizeof
(gpointer), "Expression evaluates to false"); __typeof__ ((&
priv->prefs_path)) _pp = (&priv->prefs_path); __typeof__
(*(&priv->prefs_path)) _ptr = *_pp; *_pp = ((void*)0)
; if (_ptr) (g_free) (_ptr); } while (0)
;
859 g_clear_pointer (&priv->background, g_free)do { _Static_assert (sizeof *(&priv->background) == sizeof
(gpointer), "Expression evaluates to false"); __typeof__ ((&
priv->background)) _pp = (&priv->background); __typeof__
(*(&priv->background)) _ptr = *_pp; *_pp = ((void*)0)
; if (_ptr) (g_free) (_ptr); } while (0)
;
860 g_clear_pointer (&priv->id, g_free)do { _Static_assert (sizeof *(&priv->id) == sizeof (gpointer
), "Expression evaluates to false"); __typeof__ ((&priv->
id)) _pp = (&priv->id); __typeof__ (*(&priv->id
)) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (g_free) (_ptr);
} while (0)
;
861
862 /* closure is owned by the factory */
863 priv->closure = NULL((void*)0);
864
865 G_OBJECT_CLASS (mate_panel_applet_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((mate_panel_applet_parent_class)), (((GType) ((20) <<
(2))))))))
->finalize (object);
866}
867
868static gboolean
869container_has_focusable_child (GtkContainer *container)
870{
871 GList *list;
872 GList *t;
873 gboolean retval = FALSE(0);
874
875 list = gtk_container_get_children (container);
876
877 for (t = list; t; t = t->next) {
878 GtkWidget *child = GTK_WIDGET (t->data)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((t->data)), ((gtk_widget_get_type ()))))))
;
879 if (gtk_widget_get_can_focus (child)) {
880 retval = TRUE(!(0));
881 break;
882 } else if (GTK_IS_CONTAINER (child)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(child)); GType __t = ((gtk_container_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; }))))
) {
883 retval = container_has_focusable_child (GTK_CONTAINER (child)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((child)), ((gtk_container_get_type ()))))))
);
884 if (retval)
885 break;
886 }
887 }
888 g_list_free (list);
889 return retval;
890}
891
892static void
893mate_panel_applet_menu_popup (MatePanelApplet *applet,
894 GdkEvent *event)
895{
896 MatePanelAppletPrivate *priv;
897 GtkWidget *menu;
898
899 priv = mate_panel_applet_get_instance_private (applet);
900 menu = gtk_ui_manager_get_widget (priv->ui_manager,
901 "/MatePanelAppletPopup");
902
903/* Set up theme and transparency support */
904 GtkWidget *toplevel = gtk_widget_get_toplevel (menu);
905/* Fix any failures of compiz/other wm's to communicate with gtk for transparency */
906 GdkScreen *screen = gtk_widget_get_screen(GTK_WIDGET(toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
907 GdkVisual *visual = gdk_screen_get_rgba_visual(screen);
908 gtk_widget_set_visual(GTK_WIDGET(toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
, visual);
909/* Set menu and it's toplevel window to follow panel theme */
910 GtkStyleContext *context;
911 context = gtk_widget_get_style_context (GTK_WIDGET(toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
912 gtk_style_context_add_class(context,"gnome-panel-menu-bar");
913 gtk_style_context_add_class(context,"mate-panel-menu-bar");
914 GdkGravity widget_anchor = GDK_GRAVITY_NORTH_WEST;
915 GdkGravity menu_anchor = GDK_GRAVITY_NORTH_WEST;
916 switch (priv->orient) {
917 case MATE_PANEL_APPLET_ORIENT_UP:
918 menu_anchor = GDK_GRAVITY_SOUTH_WEST;
919 break;
920 case MATE_PANEL_APPLET_ORIENT_DOWN:
921 widget_anchor = GDK_GRAVITY_SOUTH_WEST;
922 break;
923 case MATE_PANEL_APPLET_ORIENT_LEFT:
924 menu_anchor = GDK_GRAVITY_NORTH_EAST;
925 break;
926 case MATE_PANEL_APPLET_ORIENT_RIGHT:
927 widget_anchor = GDK_GRAVITY_NORTH_EAST;
928 break;
929 }
930 gtk_menu_popup_at_widget (GTK_MENU (menu)((((GtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((menu)), ((gtk_menu_get_type ()))))))
,
931 GTK_WIDGET (applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
,
932 widget_anchor,
933 menu_anchor,
934 event);
935}
936
937static gboolean
938mate_panel_applet_can_focus (GtkWidget *widget)
939{
940 /*
941 * A MatePanelApplet widget can focus if it has a tooltip or it does
942 * not have any focusable children.
943 */
944 if (gtk_widget_get_has_tooltip (widget))
945 return TRUE(!(0));
946
947 if (!MATE_PANEL_IS_APPLET (widget))
948 return FALSE(0);
949
950 return !container_has_focusable_child (GTK_CONTAINER (widget)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_container_get_type ()))))))
);
951}
952
953/* Taken from libmatecomponentui/matecomponent/matecomponent-plug.c */
954static gboolean
955mate_panel_applet_button_event (MatePanelApplet *applet,
956 GdkEventButton *event)
957{
958#ifdef HAVE_X111
959 MatePanelAppletPrivate *priv;
960 GtkWidget *widget;
961 GdkWindow *window;
962 GdkWindow *socket_window;
963 XEvent xevent;
964 GdkDisplay *display;
965
966 priv = mate_panel_applet_get_instance_private (applet);
967
968 if (!priv->out_of_process)
969 return FALSE(0);
970
971 widget = priv->plug;
972
973 if (!gtk_widget_is_toplevel (widget))
974 return FALSE(0);
975
976 window = gtk_widget_get_window (widget);
977 socket_window = gtk_plug_get_socket_window (GTK_PLUG (widget)((((GtkPlug*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_plug_get_type ()))))))
);
978
979 display = gdk_display_get_default ();
980
981 if (!GDK_IS_X11_DISPLAY (display)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(display)); GType __t = ((gdk_x11_display_get_type())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
)
982 return FALSE(0);
983
984 if (event->type == GDK_BUTTON_PRESS) {
985 GdkSeat *seat;
986
987 xevent.xbutton.type = ButtonPress4;
988
989 seat = gdk_display_get_default_seat (display);
990
991 /* X does an automatic pointer grab on button press
992 * if we have both button press and release events
993 * selected.
994 * We don't want to hog the pointer on our parent.
995 */
996 gdk_seat_ungrab (seat);
997 } else {
998 xevent.xbutton.type = ButtonRelease5;
999 }
1000
1001 xevent.xbutton.display = GDK_WINDOW_XDISPLAY (window)((gdk_x11_display_get_xdisplay (gdk_window_get_display (window
))))
;
1002 xevent.xbutton.window = GDK_WINDOW_XID (socket_window)(gdk_x11_window_get_xid (socket_window));
1003 xevent.xbutton.root = GDK_WINDOW_XID (gdk_screen_get_root_window(gdk_x11_window_get_xid (gdk_screen_get_root_window (gdk_window_get_screen
(window))))
1004 (gdk_window_get_screen (window)))(gdk_x11_window_get_xid (gdk_screen_get_root_window (gdk_window_get_screen
(window))))
;
1005 /*
1006 * FIXME: the following might cause
1007 * big problems for non-GTK apps
1008 */
1009 xevent.xbutton.x = 0;
1010 xevent.xbutton.y = 0;
1011 xevent.xbutton.x_root = 0;
1012 xevent.xbutton.y_root = 0;
1013 xevent.xbutton.state = event->state;
1014 xevent.xbutton.button = event->button;
1015 xevent.xbutton.same_screen = TRUE(!(0)); /* FIXME ? */
1016
1017 gdk_x11_display_error_trap_push (display);
1018
1019 XSendEvent (GDK_WINDOW_XDISPLAY (window)((gdk_x11_display_get_xdisplay (gdk_window_get_display (window
))))
,
1020 GDK_WINDOW_XID (socket_window)(gdk_x11_window_get_xid (socket_window)),
1021 False0, NoEventMask0L, &xevent);
1022
1023 gdk_display_flush (display);
1024 gdk_x11_display_error_trap_pop_ignored (display);
1025
1026 return TRUE(!(0));
1027#else
1028 return FALSE(0);
1029#endif
1030}
1031
1032static gboolean
1033mate_panel_applet_button_press (GtkWidget *widget,
1034 GdkEventButton *event)
1035{
1036 MatePanelApplet *applet = MATE_PANEL_APPLET (widget);
1037
1038 if (!container_has_focusable_child (GTK_CONTAINER (applet)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_container_get_type ()))))))
)) {
1039 if (!gtk_widget_has_focus (widget)) {
1040 gtk_widget_set_can_focus (widget, TRUE(!(0)));
1041 gtk_widget_grab_focus (widget);
1042 }
1043 }
1044
1045#ifdef HAVE_WAYLAND1
1046 /*Limit the window list's applet menu to the handle area*/
1047 if (!(GDK_IS_X11_DISPLAY (gdk_display_get_default ())(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gdk_display_get_default ())); GType __t = ((gdk_x11_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
))
1048 {
1049 MatePanelAppletFlags flags;
1050 flags = mate_panel_applet_get_flags (applet);
1051 if (flags & MATE_PANEL_APPLET_EXPAND_MAJOR)
1052 return FALSE(0);
1053 }
1054#endif
1055
1056 if (event->button == 3) {
1057 mate_panel_applet_menu_popup (applet, (GdkEvent *) event);
1058
1059 return TRUE(!(0));
1060 }
1061 return mate_panel_applet_button_event (applet, event);
1062}
1063
1064static gboolean
1065mate_panel_applet_button_release (GtkWidget *widget,
1066 GdkEventButton *event)
1067{
1068 MatePanelApplet *applet = MATE_PANEL_APPLET (widget);
1069
1070 return mate_panel_applet_button_event (applet, event);
1071}
1072
1073/*Open the applet context menu only on Menu key
1074 *Do not open it on Return or some applets won't work
1075 */
1076static gboolean
1077mate_panel_applet_key_press_event (GtkWidget *widget,
1078 GdkEventKey *event)
1079{
1080 if (event->keyval == GDK_KEY_Menu0xff67) {
1081 mate_panel_applet_menu_popup (MATE_PANEL_APPLET (widget), (GdkEvent *) event);
1082 return TRUE(!(0));
1083 }
1084 else
1085 return FALSE(0);
1086}
1087
1088static void
1089mate_panel_applet_get_preferred_width (GtkWidget *widget,
1090 int *minimum_width,
1091 int *natural_width)
1092{
1093 GTK_WIDGET_CLASS (mate_panel_applet_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((mate_panel_applet_parent_class)), ((gtk_widget_get_type (
)))))))
->get_preferred_width (widget,
1094 minimum_width,
1095 natural_width);
1096
1097#if !GTK_CHECK_VERSION (3, 23, 0)((3) > (3) || ((3) == (3) && (24) > (23)) || ((
3) == (3) && (24) == (23) && (42) >= (0)))
1098 MatePanelAppletPrivate *priv;
1099
1100 priv = mate_panel_applet_get_instance_private (MATE_PANEL_APPLET (widget));
1101 if (priv->out_of_process) {
1102 /* Out-of-process applets end up scaled up doubly with GTK 3.22.
1103 * For these builds divide by the scale factor to ensure
1104 * they are back at their own intended size.
1105 */
1106 gint scale;
1107 scale = gtk_widget_get_scale_factor (widget);
1108 *minimum_width /= scale;
1109 *natural_width /= scale;
1110 }
1111#endif
1112}
1113
1114static void
1115mate_panel_applet_get_preferred_height (GtkWidget *widget,
1116 int *minimum_height,
1117 int *natural_height)
1118{
1119 GTK_WIDGET_CLASS (mate_panel_applet_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((mate_panel_applet_parent_class)), ((gtk_widget_get_type (
)))))))
->get_preferred_height (widget,
1120 minimum_height,
1121 natural_height);
1122
1123#if !GTK_CHECK_VERSION (3, 23, 0)((3) > (3) || ((3) == (3) && (24) > (23)) || ((
3) == (3) && (24) == (23) && (42) >= (0)))
1124 MatePanelAppletPrivate *priv;
1125
1126 priv = mate_panel_applet_get_instance_private (MATE_PANEL_APPLET (widget));
1127 if (priv->out_of_process) {
1128 gint scale;
1129 /* Out-of-process applets end up scaled up doubly with GTK 3.22.
1130 * For these builds divide by the scale factor to ensure
1131 * they are back at their own intended size.
1132 */
1133 scale = gtk_widget_get_scale_factor (widget);
1134 *minimum_height /= scale;
1135 *natural_height /= scale;
1136 }
1137#endif
1138}
1139
1140static GtkSizeRequestMode
1141mate_panel_applet_get_request_mode (GtkWidget *widget)
1142{
1143 /* Do not use GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH
1144 * or GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT
1145 * to avoid problems with in-process applets
1146 * when the panel is not expanded
1147 * See https://github.com/mate-desktop/mate-panel/issues/797
1148 * and https://github.com/mate-desktop/mate-panel/issues/799
1149 * Out of process applets already use GTK_SIZE_REQUEST_CONSTANT_SIZE
1150 */
1151 return GTK_SIZE_REQUEST_CONSTANT_SIZE;
1152}
1153
1154static void
1155mate_panel_applet_size_allocate (GtkWidget *widget,
1156 GtkAllocation *allocation)
1157{
1158 MatePanelAppletPrivate *priv;
1159 GtkAllocation child_allocation;
1160 MatePanelApplet *applet;
1161
1162 if (!mate_panel_applet_can_focus (widget)) {
1163 GTK_WIDGET_CLASS (mate_panel_applet_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((mate_panel_applet_parent_class)), ((gtk_widget_get_type (
)))))))
->size_allocate (widget, allocation);
1164 } else {
1165 int border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_container_get_type ()))))))
);
1166
1167 gtk_widget_set_allocation (widget, allocation);
1168 GtkBin *bin = GTK_BIN (widget)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_bin_get_type ()))))))
;
1169
1170 child_allocation.x = 0;
1171 child_allocation.y = 0;
1172
1173 child_allocation.width = MAX (allocation->width - border_width * 2, 0)(((allocation->width - border_width * 2) > (0)) ? (allocation
->width - border_width * 2) : (0))
;
1174 child_allocation.height = MAX (allocation->height - border_width * 2, 0)(((allocation->height - border_width * 2) > (0)) ? (allocation
->height - border_width * 2) : (0))
;
1175
1176 if (gtk_widget_get_realized (widget))
1177 gdk_window_move_resize (gtk_widget_get_window (widget),
1178 allocation->x + border_width,
1179 allocation->y + border_width,
1180 child_allocation.width,
1181 child_allocation.height);
1182
1183 GtkWidget *child = gtk_bin_get_child (bin);
1184 if (child)
1185 gtk_widget_size_allocate (child, &child_allocation);
1186 }
1187
1188 applet = MATE_PANEL_APPLET (widget);
1189 priv = mate_panel_applet_get_instance_private (applet);
1190
1191 if ((priv->previous_height != allocation->height) ||
1192 (priv->previous_width != allocation->width)) {
1193 priv->previous_height = allocation->height;
1194 priv->previous_width = allocation->width;
1195 mate_panel_applet_handle_background (applet);
1196 }
1197}
1198
1199static gboolean mate_panel_applet_draw(GtkWidget* widget, cairo_t* cr)
1200{
1201 GtkStyleContext *context;
1202 int border_width;
1203 gdouble x, y, width, height;
1204
1205 GTK_WIDGET_CLASS (mate_panel_applet_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((mate_panel_applet_parent_class)), ((gtk_widget_get_type (
)))))))
->draw(widget, cr);
1206
1207 if (!gtk_widget_has_focus (widget))
1208 return FALSE(0);
1209
1210 width = gtk_widget_get_allocated_width (widget);
1211 height = gtk_widget_get_allocated_height (widget);
1212
1213 border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_container_get_type ()))))))
);
1214
1215 x = 0;
1216 y = 0;
1217
1218 width -= 2 * border_width;
1219 height -= 2 * border_width;
1220
1221 context = gtk_widget_get_style_context (widget);
1222 gtk_style_context_save (context);
1223
1224 cairo_save (cr);
1225 gtk_render_focus (context, cr, x, y, width, height);
1226 cairo_restore (cr);
1227
1228 gtk_style_context_restore (context);
1229
1230 return FALSE(0);
1231}
1232
1233static gboolean
1234mate_panel_applet_focus (GtkWidget *widget,
1235 GtkDirectionType dir)
1236{
1237 MatePanelAppletPrivate *priv;
1238 gboolean ret;
1239 GtkWidget *previous_focus_child;
1240
1241 g_return_val_if_fail (MATE_PANEL_IS_APPLET (widget), FALSE)do { if ((MATE_PANEL_IS_APPLET (widget))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (widget)"
); return ((0)); } } while (0)
;
1242
1243 priv = mate_panel_applet_get_instance_private (MATE_PANEL_APPLET (widget));
1244 if (priv->moving_focus_out) {
1245 /*
1246 * Applet will retain focus if there is nothing else on the
1247 * panel to get focus
1248 */
1249 priv->moving_focus_out = FALSE(0);
1250 return FALSE(0);
1251 }
1252
1253 previous_focus_child = gtk_container_get_focus_child (GTK_CONTAINER (widget)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_container_get_type ()))))))
);
1254 if (!previous_focus_child && !gtk_widget_has_focus (widget)) {
1255 if (gtk_widget_get_has_tooltip (widget)) {
1256 gtk_widget_set_can_focus (widget, TRUE(!(0)));
1257 gtk_widget_grab_focus (widget);
1258 gtk_widget_set_can_focus (widget, FALSE(0));
1259 return TRUE(!(0));
1260 }
1261 }
1262 ret = GTK_WIDGET_CLASS (mate_panel_applet_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((mate_panel_applet_parent_class)), ((gtk_widget_get_type (
)))))))
->focus (widget, dir);
1263
1264 if (!ret && !previous_focus_child) {
1265 if (!gtk_widget_has_focus (widget)) {
1266 /*
1267 * Applet does not have a widget which can focus so set
1268 * the focus on the applet unless it already had focus
1269 * because it had a tooltip.
1270 */
1271 gtk_widget_set_can_focus (widget, TRUE(!(0)));
1272 gtk_widget_grab_focus (widget);
1273 gtk_widget_set_can_focus (widget, FALSE(0));
1274 ret = TRUE(!(0));
1275 }
1276 }
1277
1278 return ret;
1279}
1280
1281static gboolean
1282mate_panel_applet_parse_color (const gchar *color_str,
1283 GdkRGBA *color)
1284{
1285 g_assert (color_str && color)do { if (color_str && color) ; else g_assertion_message_expr
(((gchar*) 0), "mate-panel-applet.c", 1285, ((const char*) (
__func__)), "color_str && color"); } while (0)
;
1286
1287 return gdk_rgba_parse (color, color_str);
1288}
1289
1290#ifdef HAVE_X111
1291static gboolean
1292mate_panel_applet_parse_pixmap_str (const char *str,
1293 Window *xid,
1294 int *x,
1295 int *y)
1296{
1297 char **elements;
1298 char *tmp;
1299
1300 g_return_val_if_fail (str != NULL, FALSE)do { if ((str != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "str != NULL"); return
((0)); } } while (0)
;
1301 g_return_val_if_fail (xid != NULL, FALSE)do { if ((xid != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "xid != NULL"); return
((0)); } } while (0)
;
1302 g_return_val_if_fail (x != NULL, FALSE)do { if ((x != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "x != NULL"); return
((0)); } } while (0)
;
1303 g_return_val_if_fail (y != NULL, FALSE)do { if ((y != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "y != NULL"); return
((0)); } } while (0)
;
1304
1305 elements = g_strsplit (str, ",", -1);
1306
1307 if (!elements)
1308 return FALSE(0);
1309
1310 if (!elements [0] || !*elements [0] ||
1311 !elements [1] || !*elements [1] ||
1312 !elements [2] || !*elements [2])
1313 goto ERROR_AND_FREE;
1314
1315 *xid = strtol (elements [0], &tmp, 10);
1316 if (tmp == elements [0])
1317 goto ERROR_AND_FREE;
1318
1319 *x = strtol (elements [1], &tmp, 10);
1320 if (tmp == elements [1])
1321 goto ERROR_AND_FREE;
1322
1323 *y = strtol (elements [2], &tmp, 10);
1324 if (tmp == elements [2])
1325 goto ERROR_AND_FREE;
1326
1327 g_strfreev (elements);
1328 return TRUE(!(0));
1329
1330ERROR_AND_FREE:
1331 g_strfreev (elements);
1332 return FALSE(0);
1333}
1334
1335static cairo_surface_t *
1336mate_panel_applet_create_foreign_surface_for_display (GdkDisplay *display,
1337 GdkVisual *visual,
1338 Window xid)
1339{
1340 Statusint result = 0;
1341 Window window;
1342 gint x, y;
1343 guint width, height, border, depth;
1344
1345 gdk_x11_display_error_trap_push (display);
1346 result = XGetGeometry (GDK_DISPLAY_XDISPLAY (display)(gdk_x11_display_get_xdisplay (display)), xid, &window,
1347 &x, &y, &width, &height, &border, &depth);
1348 gdk_x11_display_error_trap_pop_ignored (display);
1349
1350 if (result == 0)
1351 return NULL((void*)0);
1352
1353 return cairo_xlib_surface_create (GDK_DISPLAY_XDISPLAY (display)(gdk_x11_display_get_xdisplay (display)),
1354 xid, gdk_x11_visual_get_xvisual (visual),
1355 width, height);
1356}
1357
1358static cairo_pattern_t *
1359mate_panel_applet_get_pattern_from_pixmap (MatePanelApplet *applet,
1360 Window xid,
1361 int x,
1362 int y)
1363{
1364 cairo_surface_t *background;
1365 cairo_surface_t *surface;
1366 GdkWindow *window;
1367 int width;
1368 int height;
1369 GdkDisplay *display;
1370 cairo_t *cr;
1371 cairo_pattern_t *pattern;
1372
1373 g_return_val_if_fail (MATE_PANEL_IS_APPLET (applet), NULL)do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return (((void*)0)); } } while (0)
;
1374
1375 if (!gtk_widget_get_realized (GTK_WIDGET (applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
))
1376 return NULL((void*)0);
1377
1378 window = gtk_widget_get_window (GTK_WIDGET (applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
);
1379 display = gdk_window_get_display (window);
1380
1381 background = mate_panel_applet_create_foreign_surface_for_display (display,
1382 gdk_window_get_visual (window),
1383 xid);
1384
1385 /* background can be NULL if the user changes the background very fast.
1386 * We'll get the next update, so it's not a big deal. */
1387 if (!background || cairo_surface_status (background) != CAIRO_STATUS_SUCCESS) {
1388 if (background)
1389 cairo_surface_destroy (background);
1390 return NULL((void*)0);
1391 }
1392
1393 width = gdk_window_get_width(window);
1394 height = gdk_window_get_height(window);
1395 surface = gdk_window_create_similar_surface (window,
1396 CAIRO_CONTENT_COLOR_ALPHA,
1397 width,
1398 height);
1399 gdk_x11_display_error_trap_push (display);
1400 cr = cairo_create (surface);
1401 cairo_set_source_surface (cr, background, -x, -y);
1402 cairo_rectangle (cr, 0, 0, width, height);
1403 cairo_fill (cr);
1404 gdk_x11_display_error_trap_pop_ignored (display);
1405
1406 cairo_surface_destroy (background);
1407 pattern = NULL((void*)0);
1408
1409 if (cairo_status (cr) == CAIRO_STATUS_SUCCESS) {
1410 pattern = cairo_pattern_create_for_surface (surface);
1411 }
1412
1413 cairo_destroy (cr);
1414 cairo_surface_destroy (surface);
1415
1416 return pattern;
1417}
1418#endif
1419
1420static MatePanelAppletBackgroundType
1421mate_panel_applet_handle_background_string (MatePanelApplet *applet,
1422 GdkRGBA *color,
1423 cairo_pattern_t **pattern)
1424{
1425 MatePanelAppletPrivate *priv;
1426 MatePanelAppletBackgroundType retval;
1427 char **elements;
1428
1429 priv = mate_panel_applet_get_instance_private (applet);
1430 retval = PANEL_NO_BACKGROUND;
1431
1432 if (!gtk_widget_get_realized (GTK_WIDGET (applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
) || !priv->background)
1433 return retval;
1434
1435 elements = g_strsplit (priv->background, ":", -1);
1436
1437 if (elements [0] && !strcmp (elements [0], "none" )) {
1438 retval = PANEL_NO_BACKGROUND;
1439
1440 } else if (elements [0] && !strcmp (elements [0], "color")) {
1441 g_return_val_if_fail (color != NULL, PANEL_NO_BACKGROUND)do { if ((color != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "color != NULL");
return (PANEL_NO_BACKGROUND); } } while (0)
;
1442
1443 if (!elements [1] || !mate_panel_applet_parse_color (elements [1], color)) {
1444
1445 g_warning ("Incomplete '%s' background type received", elements [0]);
1446 g_strfreev (elements);
1447 return PANEL_NO_BACKGROUND;
1448 }
1449
1450 retval = PANEL_COLOR_BACKGROUND;
1451
1452 } else if (elements [0] && !strcmp (elements [0], "pixmap")) {
1453#ifdef HAVE_X111
1454 if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gdk_display_get_default ())); GType __t = ((gdk_x11_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
) {
1455 Window pixmap_id;
1456 int x, y;
1457
1458 g_return_val_if_fail (pattern != NULL, PANEL_NO_BACKGROUND)do { if ((pattern != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "pattern != NULL"
); return (PANEL_NO_BACKGROUND); } } while (0)
;
1459
1460 if (!mate_panel_applet_parse_pixmap_str (elements [1], &pixmap_id, &x, &y)) {
1461 g_warning ("Incomplete '%s' background type received: %s",
1462 elements [0], elements [1]);
1463
1464 g_strfreev (elements);
1465 return PANEL_NO_BACKGROUND;
1466 }
1467
1468 *pattern = mate_panel_applet_get_pattern_from_pixmap (applet, pixmap_id, x, y);
1469 if (!*pattern) {
1470 g_warning ("Failed to get pattern %s", elements [1]);
1471 g_strfreev (elements);
1472 return PANEL_NO_BACKGROUND;
1473 }
1474
1475 retval = PANEL_PIXMAP_BACKGROUND;
1476 } else
1477#endif
1478 { /* not using X11 */
1479 g_warning("Received pixmap background type, which is only supported on X11");
1480 }
1481 } else
1482 g_warning ("Unknown background type received");
1483
1484 g_strfreev (elements);
1485
1486 return retval;
1487}
1488
1489MatePanelAppletBackgroundType
1490mate_panel_applet_get_background (MatePanelApplet *applet,
1491 GdkRGBA *color,
1492 cairo_pattern_t **pattern)
1493{
1494 g_return_val_if_fail (MATE_PANEL_IS_APPLET (applet), PANEL_NO_BACKGROUND)do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return (PANEL_NO_BACKGROUND); } } while (0)
;
1495
1496 /* initial sanity */
1497 if (pattern != NULL((void*)0))
1498 *pattern = NULL((void*)0);
1499
1500 if (color != NULL((void*)0))
1501 memset (color, 0, sizeof (GdkRGBA));
1502
1503 return mate_panel_applet_handle_background_string (applet, color, pattern);
1504}
1505
1506static void
1507mate_panel_applet_set_background_string (MatePanelApplet *applet,
1508 const gchar *background)
1509{
1510 MatePanelAppletPrivate *priv;
1511
1512 priv = mate_panel_applet_get_instance_private (applet);
1513
1514 if (priv->background == background)
1515 return;
1516
1517 if (g_strcmp0 (priv->background, background) == 0)
1518 return;
1519
1520 g_free (priv->background);
1521 priv->background = background ? g_strdup (background)g_strdup_inline (background) : NULL((void*)0);
1522 mate_panel_applet_handle_background (applet);
1523
1524 g_object_notify (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
, "background");
1525}
1526
1527static void
1528mate_panel_applet_handle_background (MatePanelApplet *applet)
1529{
1530 MatePanelAppletBackgroundType type;
1531
1532 GdkRGBA color;
1533 cairo_pattern_t *pattern;
1534
1535 type = mate_panel_applet_get_background (applet, &color, &pattern);
1536
1537 if (!gdk_screen_is_composited (gdk_screen_get_default ())) {
1538 color.alpha = 1.;
1539 }
1540
1541 switch (type) {
1542 case PANEL_NO_BACKGROUND:
1543 g_signal_emit (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
,
1544 mate_panel_applet_signals [CHANGE_BACKGROUND],
1545 0, PANEL_NO_BACKGROUND, NULL((void*)0), NULL((void*)0));
1546 break;
1547 case PANEL_COLOR_BACKGROUND:
1548 g_signal_emit (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
,
1549 mate_panel_applet_signals [CHANGE_BACKGROUND],
1550 0, PANEL_COLOR_BACKGROUND, &color, NULL((void*)0));
1551 break;
1552 case PANEL_PIXMAP_BACKGROUND:
1553 g_signal_emit (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
,
1554 mate_panel_applet_signals [CHANGE_BACKGROUND],
1555
1556 0, PANEL_PIXMAP_BACKGROUND, NULL((void*)0), pattern);
1557
1558 cairo_pattern_destroy (pattern);
1559
1560 break;
1561 default:
1562 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "mate-panel-applet.c"
, 1562, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1563 break;
1564 }
1565}
1566
1567static void
1568mate_panel_applet_realize (GtkWidget *widget)
1569{
1570 MatePanelApplet *applet;
1571 MatePanelAppletPrivate *priv;
1572
1573 GTK_WIDGET_CLASS (mate_panel_applet_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((mate_panel_applet_parent_class)), ((gtk_widget_get_type (
)))))))
->realize (widget);
1574
1575 applet = MATE_PANEL_APPLET (widget);
1576 priv = mate_panel_applet_get_instance_private (applet);
1577 if (priv->background)
1578 mate_panel_applet_handle_background (applet);
1579}
1580
1581static void
1582mate_panel_applet_move_focus_out_of_applet (MatePanelApplet *applet,
1583 GtkDirectionType dir)
1584{
1585 MatePanelAppletPrivate *priv;
1586 GtkWidget *toplevel;
1587
1588 priv = mate_panel_applet_get_instance_private (applet);
1589 priv->moving_focus_out = TRUE(!(0));
1590 toplevel = gtk_widget_get_toplevel (GTK_WIDGET (applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
);
1591 g_return_if_fail (toplevel)do { if ((toplevel)) { } else { g_return_if_fail_warning (((gchar
*) 0), ((const char*) (__func__)), "toplevel"); return; } } while
(0)
;
1592
1593 gtk_widget_child_focus (toplevel, dir);
1594 priv->moving_focus_out = FALSE(0);
1595}
1596
1597static void
1598mate_panel_applet_change_background(MatePanelApplet *applet,
1599 MatePanelAppletBackgroundType type,
1600 GdkRGBA* color,
1601 cairo_pattern_t *pattern)
1602{
1603 MatePanelAppletPrivate *priv;
1604 GdkWindow *window;
1605
1606 priv = mate_panel_applet_get_instance_private (applet);
1607
1608 if (priv->out_of_process)
1609 window = gtk_widget_get_window (GTK_WIDGET (priv->plug)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->plug)), ((gtk_widget_get_type ()))))))
);
1610 else
1611 window = gtk_widget_get_window (GTK_WIDGET (applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
);
1612
1613 gtk_widget_set_app_paintable (GTK_WIDGET (applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
,TRUE(!(0)));
1614
1615 if (priv->out_of_process)
1616 _mate_panel_applet_apply_css (GTK_WIDGET (priv->plug)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->plug)), ((gtk_widget_get_type ()))))))
,type);
1617
1618 switch (type) {
1619 case PANEL_NO_BACKGROUND:
1620 if (priv->out_of_process){
1621 cairo_pattern_t *transparent = cairo_pattern_create_rgba (0, 0, 0, 0); /* Using NULL here breaks transparent */
1622 gdk_window_set_background_pattern (window, transparent); /* backgrounds set by GTK theme */
1623 cairo_pattern_destroy (transparent);
1624 }
1625 break;
1626 case PANEL_COLOR_BACKGROUND:
1627 if (priv->out_of_process){
1628 gdk_window_set_background_rgba(window,color);
1629 gtk_widget_queue_draw (priv->plug); /*change the bg right away always */
1630 }
1631 break;
1632 case PANEL_PIXMAP_BACKGROUND:
1633 if (priv->out_of_process){
1634 gdk_window_set_background_pattern(window,pattern);
1635 gtk_widget_queue_draw (priv->plug); /*change the bg right away always */
1636 }
1637 break;
1638 default:
1639 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "mate-panel-applet.c"
, 1639, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1640 break;
1641 }
1642
1643 if (priv->out_of_process){
1644 GtkStyleContext *context;
1645
1646 context = gtk_widget_get_style_context (GTK_WIDGET (priv->plug)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->plug)), ((gtk_widget_get_type ()))))))
);
1647
1648 if (priv->orient == MATE_PANEL_APPLET_ORIENT_UP ||
1649 priv->orient == MATE_PANEL_APPLET_ORIENT_DOWN)
1650 gtk_style_context_add_class (context, "horizontal");
1651 else
1652 gtk_style_context_add_class (context, "vertical");
1653 }
1654}
1655
1656static void
1657mate_panel_applet_get_property (GObject *object,
1658 guint prop_id,
1659 GValue *value,
1660 GParamSpec *pspec)
1661{
1662 MatePanelApplet *applet;
1663 MatePanelAppletPrivate *priv;
1664
1665 applet = MATE_PANEL_APPLET (object);
1666 priv = mate_panel_applet_get_instance_private (applet);
1667
1668 switch (prop_id) {
1669 case PROP_OUT_OF_PROCESS:
1670 g_value_set_boolean (value, priv->out_of_process);
1671 break;
1672 case PROP_ID:
1673 g_value_set_string (value, priv->id);
1674 break;
1675 case PROP_CLOSURE:
1676 g_value_set_pointer (value, priv->closure);
1677 break;
1678 case PROP_CONNECTION:
1679 g_value_set_object (value, priv->connection);
1680 break;
1681 case PROP_PREFS_PATH:
1682 g_value_set_string (value, priv->prefs_path);
1683 break;
1684 case PROP_ORIENT:
1685 g_value_set_uint (value, priv->orient);
1686 break;
1687 case PROP_SIZE:
1688 g_value_set_uint (value, priv->size);
1689 break;
1690 case PROP_BACKGROUND:
1691 g_value_set_string (value, priv->background);
1692 break;
1693 case PROP_FLAGS:
1694 g_value_set_uint (value, priv->flags);
1695 break;
1696 case PROP_SIZE_HINTS: {
1697 GVariant **children;
1698 GVariant *variant;
1699 gint i;
1700
1701 children = g_new (GVariant *, priv->size_hints_len)((GVariant * *) g_malloc_n ((priv->size_hints_len), sizeof
(GVariant *)))
;
1702 for (i = 0; i < priv->size_hints_len; i++)
1703 children[i] = g_variant_new_int32 (priv->size_hints[i]);
1704 variant = g_variant_new_array (G_VARIANT_TYPE_INT32((const GVariantType *) "i"),
1705 children, priv->size_hints_len);
1706 g_free (children);
1707 g_value_set_pointer (value, variant);
1708 break;
1709 }
1710 case PROP_LOCKED:
1711 g_value_set_boolean (value, priv->locked);
1712 break;
1713 case PROP_LOCKED_DOWN:
1714 g_value_set_boolean (value, priv->locked_down);
1715 break;
1716 default:
1717 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "mate-panel-applet.c", 1717, ("property"), _glib__property_id
, _glib__pspec->name, g_type_name ((((((GTypeClass*) (((GTypeInstance
*) (_glib__pspec))->g_class))->g_type)))), (g_type_name
((((((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
1718 }
1719}
1720
1721static void
1722mate_panel_applet_set_property (GObject *object,
1723 guint prop_id,
1724 const GValue *value,
1725 GParamSpec *pspec)
1726{
1727 MatePanelApplet *applet;
1728 MatePanelAppletPrivate *priv;
1729
1730 applet = MATE_PANEL_APPLET (object);
1731 priv = mate_panel_applet_get_instance_private (applet);
1732
1733 switch (prop_id) {
1734 case PROP_OUT_OF_PROCESS:
1735 priv->out_of_process = g_value_get_boolean (value);
1736 break;
1737 case PROP_ID:
1738 priv->id = g_value_dup_string (value);
1739 break;
1740 case PROP_CLOSURE:
1741 priv->closure = g_value_get_pointer (value);
1742 g_closure_set_marshal (priv->closure,
1743 mate_panel_applet_marshal_BOOLEAN__STRING);
1744 break;
1745 case PROP_CONNECTION:
1746 priv->connection = g_value_dup_object (value);
1747 break;
1748 case PROP_PREFS_PATH:
1749 mate_panel_applet_set_preferences_path (applet, g_value_get_string (value));
1750 break;
1751 case PROP_ORIENT:
1752 mate_panel_applet_set_orient (applet, g_value_get_uint (value));
1753 break;
1754 case PROP_SIZE:
1755 mate_panel_applet_set_size (applet, g_value_get_uint (value));
1756 break;
1757 case PROP_BACKGROUND:
1758 mate_panel_applet_set_background_string (applet, g_value_get_string (value));
1759 break;
1760 case PROP_FLAGS:
1761 mate_panel_applet_set_flags (applet, g_value_get_uint (value));
1762 break;
1763 case PROP_SIZE_HINTS: {
1764 const int *size_hints;
1765 gsize n_elements;
1766
1767 size_hints = g_variant_get_fixed_array (g_value_get_pointer (value),
1768 &n_elements, sizeof (gint32));
1769 mate_panel_applet_set_size_hints (applet, size_hints, n_elements, 0);
1770 }
1771 break;
1772 case PROP_LOCKED:
1773 mate_panel_applet_set_locked (applet, g_value_get_boolean (value));
1774 break;
1775 case PROP_LOCKED_DOWN:
1776 mate_panel_applet_set_locked_down (applet, g_value_get_boolean (value));
1777 break;
1778 default:
1779 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "mate-panel-applet.c", 1779, ("property"), _glib__property_id
, _glib__pspec->name, g_type_name ((((((GTypeClass*) (((GTypeInstance
*) (_glib__pspec))->g_class))->g_type)))), (g_type_name
((((((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
1780 }
1781}
1782
1783static void
1784add_tab_bindings (GtkBindingSet *binding_set,
1785 GdkModifierType modifiers,
1786 GtkDirectionType direction)
1787{
1788 gtk_binding_entry_add_signal (binding_set, GDK_KEY_Tab0xff09, modifiers,
1789 "move_focus_out_of_applet", 1,
1790 GTK_TYPE_DIRECTION_TYPE(gtk_direction_type_get_type ()), direction);
1791 gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Tab0xff89, modifiers,
1792 "move_focus_out_of_applet", 1,
1793 GTK_TYPE_DIRECTION_TYPE(gtk_direction_type_get_type ()), direction);
1794}
1795
1796static void
1797mate_panel_applet_setup (MatePanelApplet *applet)
1798{
1799 MatePanelAppletPrivate *priv;
1800 GValue value = {0, };
1801 GArray *params;
1802 guint i;
1803 gboolean ret;
1804
1805 priv = mate_panel_applet_get_instance_private (applet);
1806
1807 g_assert ((priv->id != NULL) && (priv->closure != NULL))do { if ((priv->id != ((void*)0)) && (priv->closure
!= ((void*)0))) ; else g_assertion_message_expr (((gchar*) 0
), "mate-panel-applet.c", 1807, ((const char*) (__func__)), "(priv->id != NULL) && (priv->closure != NULL)"
); } while (0)
;
1808
1809 params = g_array_sized_new (FALSE(0), TRUE(!(0)), sizeof (GValue), 2);
1810 value.g_type = 0;
1811 g_value_init (&value, G_TYPE_OBJECT((GType) ((20) << (2))));
1812 g_value_set_object (&value, G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
);
1813 g_array_append_val (params, value)g_array_append_vals (params, &(value), 1);
1814
1815 value.g_type = 0;
1816 g_value_init (&value, G_TYPE_STRING((GType) ((16) << (2))));
1817 g_value_set_string (&value, priv->id);
1818 g_array_append_val (params, value)g_array_append_vals (params, &(value), 1);
1819
1820 value.g_type = 0;
1821 g_value_init (&value, G_TYPE_BOOLEAN((GType) ((5) << (2))));
1822
1823 g_closure_invoke (priv->closure,
1824 &value, params->len,
1825 (GValue *) params->data,
1826 NULL((void*)0));
1827
1828 for (i = 0; i < params->len; i++)
1829 g_value_unset (&g_array_index (params, GValue, i)(((GValue*) (void *) (params)->data) [(i)]));
1830 g_array_free (params, TRUE(!(0)));
1831
1832 ret = g_value_get_boolean (&value);
1833 g_value_unset (&value);
1834
1835 if (!ret) { /* FIXME */
1836 g_warning ("need to free the control here");
1837
1838 return;
1839 }
1840}
1841
1842void _mate_panel_applet_apply_css(GtkWidget* widget, MatePanelAppletBackgroundType type)
1843{
1844 GtkStyleContext* context;
1845
1846 context = gtk_widget_get_style_context (widget);
1847
1848 switch (type) {
1849 case PANEL_NO_BACKGROUND:
1850 gtk_style_context_remove_class (context, "mate-custom-panel-background");
1851 break;
1852 case PANEL_COLOR_BACKGROUND:
1853 case PANEL_PIXMAP_BACKGROUND:
1854 gtk_style_context_add_class (context, "mate-custom-panel-background");
1855 break;
1856 default:
1857 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "mate-panel-applet.c"
, 1857, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1858 break;
1859 }
1860}
1861
1862#ifdef HAVE_X111
1863static void _mate_panel_applet_prepare_css (GtkStyleContext *context)
1864{
1865 GtkCssProvider *provider;
1866
1867 g_return_if_fail (GDK_IS_X11_DISPLAY (gdk_display_get_default ()))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((gdk_display_get_default ())); GType __t = ((gdk_x11_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0
), ((const char*) (__func__)), "GDK_IS_X11_DISPLAY (gdk_display_get_default ())"
); return; } } while (0)
;
1868 provider = gtk_css_provider_new ();
1869 gtk_css_provider_load_from_data (provider,
1870 "#PanelPlug {\n"
1871 " background-repeat: no-repeat;\n" /*disable in gtk theme features */
1872 " background-size: cover; " /*that don't work on panel-toplevel */
1873 " }\n"
1874 ".mate-custom-panel-background{\n" /*prepare CSS for user set theme */
1875 " background-color: rgba (0, 0, 0, 0);\n"
1876 " background-image: none;\n"
1877 "}",
1878 -1, NULL((void*)0));
1879
1880 gtk_style_context_add_provider (context,
1881 GTK_STYLE_PROVIDER (provider)((((GtkStyleProvider*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((provider)), ((gtk_style_provider_get_type (
)))))))
,
1882 GTK_STYLE_PROVIDER_PRIORITY_APPLICATION600);
1883 g_object_unref (provider);
1884}
1885#endif /* HAVE_X11 */
1886
1887static void
1888mate_panel_applet_init (MatePanelApplet *applet)
1889{
1890 MatePanelAppletPrivate *priv;
1891
1892 priv = mate_panel_applet_get_instance_private (applet);
1893
1894 priv->flags = MATE_PANEL_APPLET_FLAGS_NONE;
1895 priv->orient = MATE_PANEL_APPLET_ORIENT_UP;
1896 priv->size = 24;
1897
1898 priv->panel_action_group = gtk_action_group_new ("PanelActions");
1899 gtk_action_group_set_translation_domain (priv->panel_action_group, GETTEXT_PACKAGE"mate-panel");
1900 gtk_action_group_add_actions (priv->panel_action_group,
1901 menu_entries,
1902 G_N_ELEMENTS (menu_entries)(sizeof (menu_entries) / sizeof ((menu_entries)[0])),
1903 applet);
1904 gtk_action_group_add_toggle_actions (priv->panel_action_group,
1905 menu_toggle_entries,
1906 G_N_ELEMENTS (menu_toggle_entries)(sizeof (menu_toggle_entries) / sizeof ((menu_toggle_entries)
[0]))
,
1907 applet);
1908
1909 priv->ui_manager = gtk_ui_manager_new ();
1910 gtk_ui_manager_insert_action_group (priv->ui_manager,
1911 priv->panel_action_group, 1);
1912 gtk_ui_manager_add_ui_from_string (priv->ui_manager,
1913 panel_menu_ui, -1, NULL((void*)0));
1914
1915 gtk_widget_set_events (GTK_WIDGET (applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
,
1916 GDK_BUTTON_PRESS_MASK |
1917 GDK_BUTTON_RELEASE_MASK);
1918}
1919
1920static GObject *
1921mate_panel_applet_constructor (GType type,
1922 guint n_construct_properties,
1923 GObjectConstructParam *construct_properties)
1924{
1925 GObject *object;
1926 MatePanelApplet *applet;
1927 MatePanelAppletPrivate *priv;
1928
1929 object = G_OBJECT_CLASS (mate_panel_applet_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((mate_panel_applet_parent_class)), (((GType) ((20) <<
(2))))))))
->constructor (type,
1930 n_construct_properties,
1931 construct_properties);
1932 applet = MATE_PANEL_APPLET (object);
1933 priv = mate_panel_applet_get_instance_private (applet);
1934
1935 if (!priv->out_of_process)
1936 return object;
1937
1938#ifdef HAVE_X111
1939 if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gdk_display_get_default ())); GType __t = ((gdk_x11_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
)
1940 {
1941 GtkStyleContext *context;
1942 GtkWidget *widget;
1943
1944 priv->plug = gtk_plug_new (0);
1945 widget = GTK_WIDGET (priv->plug)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->plug)), ((gtk_widget_get_type ()))))))
;
1946 gtk_widget_set_visual (widget,
1947 gdk_screen_get_rgba_visual (gtk_widget_get_screen (widget)));
1948 context = gtk_widget_get_style_context (widget);
1949 gtk_style_context_add_class (context, "gnome-panel-menu-bar");
1950 gtk_style_context_add_class (context, "mate-panel-menu-bar");
1951 gtk_widget_set_name (widget, "PanelPlug");
1952 _mate_panel_applet_prepare_css (context);
1953
1954 g_signal_connect_swapped (priv->plug, "embedded",g_signal_connect_data ((priv->plug), ("embedded"), (((GCallback
) (mate_panel_applet_setup))), (applet), ((void*)0), G_CONNECT_SWAPPED
)
1955 G_CALLBACK (mate_panel_applet_setup),g_signal_connect_data ((priv->plug), ("embedded"), (((GCallback
) (mate_panel_applet_setup))), (applet), ((void*)0), G_CONNECT_SWAPPED
)
1956 applet)g_signal_connect_data ((priv->plug), ("embedded"), (((GCallback
) (mate_panel_applet_setup))), (applet), ((void*)0), G_CONNECT_SWAPPED
)
;
1957
1958 gtk_container_add (GTK_CONTAINER (priv->plug)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->plug)), ((gtk_container_get_type ()))))))
, GTK_WIDGET (applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
);
1959 } else
1960#endif
1961 { /* not using X11 */
1962 g_warning ("Requested construction of an out-of-process applet, which is only possible on X11");
1963 }
1964
1965 return object;
1966}
1967
1968static void
1969mate_panel_applet_constructed (GObject* object)
1970{
1971 MatePanelApplet* applet = MATE_PANEL_APPLET(object);
1972
1973 /* Rename the class to have compatibility with all GTK2 themes
1974 * https://github.com/perberos/Mate-Desktop-Environment/issues/27
1975 */
1976 gtk_widget_set_name(GTK_WIDGET(applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
, "PanelApplet");
1977
1978 mate_panel_applet_register_object (applet);
1979}
1980
1981static void
1982mate_panel_applet_class_init (MatePanelAppletClass *klass)
1983{
1984 GObjectClass *gobject_class = (GObjectClass *) klass;
1985 GtkWidgetClass *widget_class = (GtkWidgetClass *) klass;
1986 GtkBindingSet *binding_set;
1987
1988 gobject_class->get_property = mate_panel_applet_get_property;
1989 gobject_class->set_property = mate_panel_applet_set_property;
1990 gobject_class->constructor = mate_panel_applet_constructor;
1991 gobject_class->constructed = mate_panel_applet_constructed;
1992 klass->move_focus_out_of_applet = mate_panel_applet_move_focus_out_of_applet;
1993 klass->change_background = mate_panel_applet_change_background;
1994 widget_class->button_press_event = mate_panel_applet_button_press;
1995 widget_class->button_release_event = mate_panel_applet_button_release;
1996 widget_class->get_request_mode = mate_panel_applet_get_request_mode;
1997 widget_class->get_preferred_width = mate_panel_applet_get_preferred_width;
1998 widget_class->get_preferred_height = mate_panel_applet_get_preferred_height;
1999 widget_class->draw = mate_panel_applet_draw;
2000 widget_class->size_allocate = mate_panel_applet_size_allocate;
2001 widget_class->focus = mate_panel_applet_focus;
2002 widget_class->realize = mate_panel_applet_realize;
2003 widget_class->key_press_event = mate_panel_applet_key_press_event;
2004
2005 gobject_class->finalize = mate_panel_applet_finalize;
2006
2007 g_object_class_install_property (gobject_class,
2008 PROP_OUT_OF_PROCESS,
2009 g_param_spec_boolean ("out-of-process",
2010 "out-of-process",
2011 "out-of-process",
2012 TRUE(!(0)),
2013 G_PARAM_CONSTRUCT_ONLY |
2014 G_PARAM_READWRITE));
2015 g_object_class_install_property (gobject_class,
2016 PROP_ID,
2017 g_param_spec_string ("id",
2018 "Id",
2019 "The Applet identifier",
2020 NULL((void*)0),
2021 G_PARAM_CONSTRUCT_ONLY |
2022 G_PARAM_READWRITE));
2023 g_object_class_install_property (gobject_class,
2024 PROP_CLOSURE,
2025 g_param_spec_pointer ("closure",
2026 "GClosure",
2027 "The Applet closure",
2028 G_PARAM_CONSTRUCT_ONLY |
2029 G_PARAM_READWRITE));
2030 g_object_class_install_property (gobject_class,
2031 PROP_CONNECTION,
2032 g_param_spec_object ("connection",
2033 "Connection",
2034 "The DBus Connection",
2035 G_TYPE_DBUS_CONNECTION(g_dbus_connection_get_type ()),
2036 G_PARAM_CONSTRUCT_ONLY |
2037 G_PARAM_READWRITE));
2038 g_object_class_install_property (gobject_class,
2039 PROP_PREFS_PATH,
2040 g_param_spec_string ("prefs-path",
2041 "PrefsPath",
2042 "GSettings Preferences Path",
2043 NULL((void*)0),
2044 G_PARAM_READWRITE));
2045 g_object_class_install_property (gobject_class,
2046 PROP_ORIENT,
2047 g_param_spec_uint ("orient",
2048 "Orient",
2049 "Panel Applet Orientation",
2050 MATE_PANEL_APPLET_ORIENT_FIRSTMATE_PANEL_APPLET_ORIENT_UP,
2051 MATE_PANEL_APPLET_ORIENT_LASTMATE_PANEL_APPLET_ORIENT_RIGHT,
2052 MATE_PANEL_APPLET_ORIENT_UP,
2053 G_PARAM_READWRITE));
2054 g_object_class_install_property (gobject_class,
2055 PROP_SIZE,
2056 g_param_spec_uint ("size",
2057 "Size",
2058 "Panel Applet Size",
2059 0, G_MAXUINT(2147483647 *2U +1U), 0,
2060 G_PARAM_READWRITE));
2061 g_object_class_install_property (gobject_class,
2062 PROP_BACKGROUND,
2063 g_param_spec_string ("background",
2064 "Background",
2065 "Panel Applet Background",
2066 NULL((void*)0),
2067 G_PARAM_READWRITE));
2068 g_object_class_install_property (gobject_class,
2069 PROP_FLAGS,
2070 g_param_spec_uint ("flags",
2071 "Flags",
2072 "Panel Applet flags",
2073 MATE_PANEL_APPLET_FLAGS_NONE,
2074 MATE_PANEL_APPLET_FLAGS_ALL(MATE_PANEL_APPLET_EXPAND_MAJOR|MATE_PANEL_APPLET_EXPAND_MINOR
|MATE_PANEL_APPLET_HAS_HANDLE)
,
2075 MATE_PANEL_APPLET_FLAGS_NONE,
2076 G_PARAM_READWRITE));
2077 g_object_class_install_property (gobject_class,
2078 PROP_SIZE_HINTS,
2079 /* FIXME: value_array? */
2080 g_param_spec_pointer ("size-hints",
2081 "SizeHints",
2082 "Panel Applet Size Hints",
2083 G_PARAM_READWRITE));
2084 g_object_class_install_property (gobject_class,
2085 PROP_LOCKED,
2086 g_param_spec_boolean ("locked",
2087 "Locked",
2088 "Whether Panel Applet is locked",
2089 FALSE(0),
2090 G_PARAM_READWRITE));
2091 g_object_class_install_property (gobject_class,
2092 PROP_LOCKED_DOWN,
2093 g_param_spec_boolean ("locked-down",
2094 "LockedDown",
2095 "Whether Panel Applet is locked down",
2096 FALSE(0),
2097 G_PARAM_READWRITE));
2098
2099 mate_panel_applet_signals [CHANGE_ORIENT] =
2100 g_signal_new ("change-orient",
2101 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2102 G_SIGNAL_RUN_LAST,
2103 G_STRUCT_OFFSET (MatePanelAppletClass, change_orient)((glong) __builtin_offsetof(MatePanelAppletClass, change_orient
))
,
2104 NULL((void*)0),
2105 NULL((void*)0),
2106 mate_panel_applet_marshal_VOID__UINTg_cclosure_marshal_VOID__UINT,
2107 G_TYPE_NONE((GType) ((1) << (2))),
2108 1,
2109 G_TYPE_UINT((GType) ((7) << (2))));
2110
2111 mate_panel_applet_signals [CHANGE_SIZE] =
2112 g_signal_new ("change-size",
2113 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2114 G_SIGNAL_RUN_LAST,
2115 G_STRUCT_OFFSET (MatePanelAppletClass, change_size)((glong) __builtin_offsetof(MatePanelAppletClass, change_size
))
,
2116 NULL((void*)0),
2117 NULL((void*)0),
2118 mate_panel_applet_marshal_VOID__INTg_cclosure_marshal_VOID__INT,
2119 G_TYPE_NONE((GType) ((1) << (2))),
2120 1,
2121 G_TYPE_INT((GType) ((6) << (2))));
2122
2123 mate_panel_applet_signals [CHANGE_BACKGROUND] =
2124 g_signal_new ("change-background",
2125 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2126 G_SIGNAL_RUN_LAST,
2127 G_STRUCT_OFFSET (MatePanelAppletClass, change_background)((glong) __builtin_offsetof(MatePanelAppletClass, change_background
))
,
2128 NULL((void*)0),
2129 NULL((void*)0),
2130 mate_panel_applet_marshal_VOID__ENUM_BOXED_OBJECT,
2131 G_TYPE_NONE((GType) ((1) << (2))),
2132 3,
2133 PANEL_TYPE_MATE_PANEL_APPLET_BACKGROUND_TYPEmate_panel_applet_background_type_get_type(),
2134 GDK_TYPE_RGBA(gdk_rgba_get_type ()),
2135 CAIRO_GOBJECT_TYPE_PATTERNcairo_gobject_pattern_get_type ());
2136
2137 mate_panel_applet_signals [MOVE_FOCUS_OUT_OF_APPLET] =
2138 g_signal_new ("move_focus_out_of_applet",
2139 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2140 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
2141 G_STRUCT_OFFSET (MatePanelAppletClass, move_focus_out_of_applet)((glong) __builtin_offsetof(MatePanelAppletClass, move_focus_out_of_applet
))
,
2142 NULL((void*)0),
2143 NULL((void*)0),
2144 mate_panel_applet_marshal_VOID__ENUMg_cclosure_marshal_VOID__ENUM,
2145 G_TYPE_NONE((GType) ((1) << (2))),
2146 1,
2147 GTK_TYPE_DIRECTION_TYPE(gtk_direction_type_get_type ()));
2148
2149 binding_set = gtk_binding_set_by_class (gobject_class);
2150 add_tab_bindings (binding_set, 0, GTK_DIR_TAB_FORWARD);
2151 add_tab_bindings (binding_set, GDK_SHIFT_MASK, GTK_DIR_TAB_BACKWARD);
2152 add_tab_bindings (binding_set, GDK_CONTROL_MASK, GTK_DIR_TAB_FORWARD);
2153 add_tab_bindings (binding_set, GDK_CONTROL_MASK | GDK_SHIFT_MASK, GTK_DIR_TAB_BACKWARD);
2154
2155 gtk_widget_class_set_css_name (widget_class, "PanelApplet");
2156}
2157
2158GtkWidget* mate_panel_applet_new(void)
2159{
2160 MatePanelApplet* applet = g_object_new(PANEL_TYPE_APPLETmate_panel_applet_get_type (), NULL((void*)0));
2161
2162 return GTK_WIDGET(applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
;
2163}
2164
2165static GdkEvent *
2166button_press_event_new (MatePanelApplet *applet,
2167 guint button,
2168 guint time)
2169{
2170 GdkDisplay *display;
2171 GdkSeat *seat;
2172 GdkDevice *device;
2173 GdkEvent *event;
2174
2175 display = gdk_display_get_default ();
2176 seat = gdk_display_get_default_seat (display);
2177 device = gdk_seat_get_pointer (seat);
2178
2179 event = gdk_event_new (GDK_BUTTON_PRESS);
2180
2181 event->button.time = time;
2182 event->button.button = button;
2183
2184 gdk_event_set_device (event, device);
2185
2186 return event;
2187}
2188
2189static void
2190method_call_cb (GDBusConnection *connection,
2191 const gchar *sender,
2192 const gchar *object_path,
2193 const gchar *interface_name,
2194 const gchar *method_name,
2195 GVariant *parameters,
2196 GDBusMethodInvocation *invocation,
2197 gpointer user_data)
2198{
2199 MatePanelApplet *applet = MATE_PANEL_APPLET (user_data);
2200
2201 if (g_strcmp0 (method_name, "PopupMenu") == 0) {
2202 guint button;
2203 guint time;
2204
2205 g_variant_get (parameters, "(uu)", &button, &time);
2206
2207 GdkEvent *event = button_press_event_new (applet, button, time);
2208 mate_panel_applet_menu_popup (applet, event);
2209 gdk_event_free (event);
2210
2211 g_dbus_method_invocation_return_value (invocation, NULL((void*)0));
2212 }
2213}
2214
2215static GVariant *
2216get_property_cb (GDBusConnection *connection,
2217 const gchar *sender,
2218 const gchar *object_path,
2219 const gchar *interface_name,
2220 const gchar *property_name,
2221 GError **error,
2222 gpointer user_data)
2223{
2224 MatePanelAppletPrivate *priv;
2225 GVariant *retval = NULL((void*)0);
2226
2227 priv = mate_panel_applet_get_instance_private (MATE_PANEL_APPLET (user_data));
2228
2229 if (g_strcmp0 (property_name, "PrefsPath") == 0) {
2230 retval = g_variant_new_string (priv->prefs_path ? priv->prefs_path : "");
2231 } else if (g_strcmp0 (property_name, "Orient") == 0) {
2232 retval = g_variant_new_uint32 (priv->orient);
2233 } else if (g_strcmp0 (property_name, "Size") == 0) {
2234 retval = g_variant_new_uint32 (priv->size);
2235 } else if (g_strcmp0 (property_name, "Background") == 0) {
2236 retval = g_variant_new_string (priv->background ? priv->background : "");
2237 } else if (g_strcmp0 (property_name, "Flags") == 0) {
2238 retval = g_variant_new_uint32 (priv->flags);
2239 } else if (g_strcmp0 (property_name, "SizeHints") == 0) {
2240 GVariant **children;
2241 gint i;
2242
2243 children = g_new (GVariant *, priv->size_hints_len)((GVariant * *) g_malloc_n ((priv->size_hints_len), sizeof
(GVariant *)))
;
2244 for (i = 0; i < priv->size_hints_len; i++)
2245 children[i] = g_variant_new_int32 (priv->size_hints[i]);
2246 retval = g_variant_new_array (G_VARIANT_TYPE_INT32((const GVariantType *) "i"),
2247 children, priv->size_hints_len);
2248 g_free (children);
2249 } else if (g_strcmp0 (property_name, "Locked") == 0) {
2250 retval = g_variant_new_boolean (priv->locked);
2251 } else if (g_strcmp0 (property_name, "LockedDown") == 0) {
2252 retval = g_variant_new_boolean (priv->locked_down);
2253 }
2254
2255 return retval;
2256}
2257
2258static gboolean
2259set_property_cb (GDBusConnection *connection,
2260 const gchar *sender,
2261 const gchar *object_path,
2262 const gchar *interface_name,
2263 const gchar *property_name,
2264 GVariant *value,
2265 GError **error,
2266 gpointer user_data)
2267{
2268 MatePanelApplet *applet = MATE_PANEL_APPLET (user_data);
2269
2270 if (g_strcmp0 (property_name, "PrefsPath") == 0) {
2271 mate_panel_applet_set_preferences_path (applet, g_variant_get_string (value, NULL((void*)0)));
2272 } else if (g_strcmp0 (property_name, "Orient") == 0) {
2273 mate_panel_applet_set_orient (applet, g_variant_get_uint32 (value));
2274 } else if (g_strcmp0 (property_name, "Size") == 0) {
2275 mate_panel_applet_set_size (applet, g_variant_get_uint32 (value));
2276 } else if (g_strcmp0 (property_name, "Background") == 0) {
2277 mate_panel_applet_set_background_string (applet, g_variant_get_string (value, NULL((void*)0)));
2278 } else if (g_strcmp0 (property_name, "Flags") == 0) {
2279 mate_panel_applet_set_flags (applet, g_variant_get_uint32 (value));
2280 } else if (g_strcmp0 (property_name, "SizeHints") == 0) {
2281 const int *size_hints;
2282 gsize n_elements;
2283
2284 size_hints = g_variant_get_fixed_array (value, &n_elements, sizeof (gint32));
2285 mate_panel_applet_set_size_hints (applet, size_hints, n_elements, 0);
2286 } else if (g_strcmp0 (property_name, "Locked") == 0) {
2287 mate_panel_applet_set_locked (applet, g_variant_get_boolean (value));
2288 } else if (g_strcmp0 (property_name, "LockedDown") == 0) {
2289 mate_panel_applet_set_locked_down (applet, g_variant_get_boolean (value));
2290 }
2291
2292 return TRUE(!(0));
2293}
2294
2295static const gchar introspection_xml[] =
2296 "<node>"
2297 "<interface name='org.mate.panel.applet.Applet'>"
2298 "<method name='PopupMenu'>"
2299 "<arg name='button' type='u' direction='in'/>"
2300 "<arg name='time' type='u' direction='in'/>"
2301 "</method>"
2302 "<property name='PrefsPath' type='s' access='readwrite'/>"
2303 "<property name='Orient' type='u' access='readwrite' />"
2304 "<property name='Size' type='u' access='readwrite'/>"
2305 "<property name='Background' type='s' access='readwrite'/>"
2306 "<property name='Flags' type='u' access='readwrite'/>"
2307 "<property name='SizeHints' type='ai' access='readwrite'/>"
2308 "<property name='Locked' type='b' access='readwrite'/>"
2309 "<property name='LockedDown' type='b' access='readwrite'/>"
2310 "<signal name='Move' />"
2311 "<signal name='RemoveFromPanel' />"
2312 "<signal name='Lock' />"
2313 "<signal name='Unlock' />"
2314 "</interface>"
2315 "</node>";
2316
2317static const GDBusInterfaceVTable interface_vtable = {
2318 method_call_cb,
2319 get_property_cb,
2320 set_property_cb,
2321 { 0 }
2322};
2323
2324static GDBusNodeInfo *introspection_data = NULL((void*)0);
2325
2326static void
2327mate_panel_applet_register_object (MatePanelApplet *applet)
2328{
2329 MatePanelAppletPrivate *priv;
2330 GError *error = NULL((void*)0);
2331 static gint id = 0;
2332
2333 if (!introspection_data)
2334 introspection_data = g_dbus_node_info_new_for_xml (introspection_xml, NULL((void*)0));
2335
2336 priv = mate_panel_applet_get_instance_private (applet);
2337 priv->object_path = g_strdup_printf (MATE_PANEL_APPLET_OBJECT_PATH"/org/mate/panel/applet/%s/%d", priv->id, id++);
2338 priv->object_id =
2339 g_dbus_connection_register_object (priv->connection,
2340 priv->object_path,
2341 introspection_data->interfaces[0],
2342 &interface_vtable,
2343 applet, NULL((void*)0),
2344 &error);
2345 if (!priv->object_id) {
2346 g_printerr ("Failed to register object %s: %s\n", priv->object_path, error->message);
2347 g_error_free (error);
2348 }
2349}
2350
2351static void mate_panel_applet_factory_main_finalized(gpointer data, GObject* object)
2352{
2353 gtk_main_quit();
2354
2355 if (introspection_data)
2356 {
2357 g_dbus_node_info_unref(introspection_data);
2358 introspection_data = NULL((void*)0);
2359 }
2360}
2361
2362#ifdef HAVE_X111
2363static int (*_x_error_func) (Display *, XErrorEvent *);
2364
2365static int
2366_x_error_handler (Display *display, XErrorEvent *error)
2367{
2368 if (!error->error_code)
2369 return 0;
2370
2371 /* If we got a BadDrawable or a BadWindow, we ignore it for now.
2372 * FIXME: We need to somehow distinguish real errors from
2373 * X-server-induced errors. Keeping a list of windows for which we
2374 * will ignore BadDrawables would be a good idea. */
2375 if (error->error_code == BadDrawable9 ||
2376 error->error_code == BadWindow3)
2377 return 0;
2378
2379 return _x_error_func (display, error);
2380}
2381
2382/*
2383 * To do graphical embedding in the X window system, MATE Panel
2384 * uses the classic foreign-window-reparenting trick. The
2385 * GtkPlug/GtkSocket widgets are used for this purpose. However,
2386 * serious robustness problems arise if the GtkSocket end of the
2387 * connection unexpectedly dies. The X server sends out DestroyNotify
2388 * events for the descendants of the GtkPlug (i.e., your embedded
2389 * component's windows) in effectively random order. Furthermore, if
2390 * you happened to be drawing on any of those windows when the
2391 * GtkSocket was destroyed (a common state of affairs), an X error
2392 * will kill your application.
2393 *
2394 * To solve this latter problem, MATE Panel sets up its own X error
2395 * handler which ignores certain X errors that might have been
2396 * caused by such a scenario. Other X errors get passed to gdk_x_error
2397 * normally.
2398 */
2399static void
2400_mate_panel_applet_setup_x_error_handler (void)
2401{
2402 static gboolean error_handler_setup = FALSE(0);
2403
2404 if (error_handler_setup)
2405 return;
2406
2407 error_handler_setup = TRUE(!(0));
2408
2409 _x_error_func = XSetErrorHandler (_x_error_handler);
2410}
2411#endif
2412
2413static int
2414_mate_panel_applet_factory_main_internal (const gchar *factory_id,
2415 gboolean out_process,
2416 GType applet_type,
2417 MatePanelAppletFactoryCallback callback,
2418 gpointer user_data)
2419{
2420 MatePanelAppletFactory* factory;
2421 GClosure* closure;
2422
2423 g_return_val_if_fail(factory_id != NULL, 1)do { if ((factory_id != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "factory_id != NULL"
); return (1); } } while (0)
;
2424 g_return_val_if_fail(callback != NULL, 1)do { if ((callback != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "callback != NULL"
); return (1); } } while (0)
;
2425 g_assert(g_type_is_a(applet_type, PANEL_TYPE_APPLET))do { if (((applet_type) == (mate_panel_applet_get_type ()) ||
(g_type_is_a) ((applet_type), (mate_panel_applet_get_type ()
)))) ; else g_assertion_message_expr (((gchar*) 0), "mate-panel-applet.c"
, 2425, ((const char*) (__func__)), "g_type_is_a(applet_type, PANEL_TYPE_APPLET)"
); } while (0)
;
2426
2427#ifdef HAVE_X111
2428 if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gdk_display_get_default ())); GType __t = ((gdk_x11_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
) {
2429 /*Use this both in and out of process as the tray applet always uses GtkSocket
2430 *to handle GtkStatusIcons whether the tray itself is built in or out of process
2431 */
2432 _mate_panel_applet_setup_x_error_handler();
2433 } else
2434#endif
2435 { /* not using X11 */
2436 if (out_process) {
2437 g_warning("Requested out-of-process applet, which is only supported on X11");
2438 return 1;
2439 }
2440 }
2441
2442 closure = g_cclosure_new(G_CALLBACK(callback)((GCallback) (callback)), user_data, NULL((void*)0));
2443 factory = mate_panel_applet_factory_new(factory_id, out_process, applet_type, closure);
2444 g_closure_unref(closure);
2445
2446 if (mate_panel_applet_factory_register_service(factory))
2447 {
2448 if (out_process)
2449 {
2450 g_object_weak_ref(G_OBJECT(factory)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((factory)), (((GType) ((20) << (2))))))))
, mate_panel_applet_factory_main_finalized, NULL((void*)0));
2451 gtk_main();
2452 }
2453
2454 return 0;
2455 }
2456
2457 g_object_unref (factory);
2458
2459 return 1;
2460}
2461
2462/**
2463 * mate_panel_applet_factory_main:
2464 * @out_process: boolean, dummy to support applets sending it
2465 * @factory_id: Factory ID.
2466 * @applet_type: GType of the applet this factory creates.
2467 * @callback: (scope call): Callback to be called when a new applet is to be created.
2468 * @data: (closure): Callback data.
2469 *
2470 * Returns: 0 on success, 1 if there is an error.
2471 */
2472int
2473mate_panel_applet_factory_main (const gchar *factory_id,
2474 gboolean out_process, /*Dummy to support applets w issues with this */
2475 GType applet_type,
2476 MatePanelAppletFactoryCallback callback,
2477 gpointer user_data)
2478{
2479 return _mate_panel_applet_factory_main_internal (factory_id, TRUE(!(0)), applet_type,
2480 callback, user_data);
2481}
2482
2483/**
2484 * mate_panel_applet_factory_setup_in_process: (skip)
2485 * @factory_id: Factory ID.
2486 * @applet_type: GType of the applet this factory creates.
2487 * @callback: (scope call): Callback to be called when a new applet is to be created.
2488 * @data: (closure): Callback data.
2489 *
2490 * Returns: 0 on success, 1 if there is an error.
2491 */
2492int
2493mate_panel_applet_factory_setup_in_process (const gchar *factory_id,
2494 GType applet_type,
2495 MatePanelAppletFactoryCallback callback,
2496 gpointer user_data)
2497{
2498 return _mate_panel_applet_factory_main_internal (factory_id, FALSE(0), applet_type,
2499 callback, user_data);
2500}
2501
2502/**
2503 * mate_panel_applet_set_background_widget:
2504 * @applet: a #PanelApplet.
2505 * @widget: a #GtkWidget.
2506 *
2507 * Configure #PanelApplet to automatically draw the background of the applet on
2508 * @widget. It is generally enough to call this function with @applet as
2509 * @widget.
2510 *
2511 * Deprecated: 3.20: Do not use this API. Since 3.20 this function does nothing.
2512 **/
2513
2514void
2515mate_panel_applet_set_background_widget (MatePanelApplet *applet,
2516 GtkWidget *widget)
2517{
2518}
2519
2520guint32
2521mate_panel_applet_get_xid (MatePanelApplet *applet,
2522 GdkScreen *screen)
2523{
2524 MatePanelAppletPrivate *priv;
2525
2526 priv = mate_panel_applet_get_instance_private (applet);
2527
2528 /* out_of_process should only be true on X11, so an extra runtime Wayland check is not needed */
2529 if (priv->out_of_process == FALSE(0))
2530 return 0;
2531
2532#ifdef HAVE_X111
2533 gtk_window_set_screen (GTK_WINDOW (priv->plug)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->plug)), ((gtk_window_get_type ()))))))
, screen);
2534 gtk_widget_show (priv->plug);
2535
2536 return gtk_plug_get_id (GTK_PLUG (priv->plug)((((GtkPlug*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->plug)), ((gtk_plug_get_type ()))))))
);
2537#else
2538 return 0;
2539#endif
2540}
2541
2542const gchar *
2543mate_panel_applet_get_object_path (MatePanelApplet *applet)
2544{
2545 MatePanelAppletPrivate *priv;
2546
2547 priv = mate_panel_applet_get_instance_private (applet);
2548
2549 return priv->object_path;
2550}
2551
2552G_MODULE_EXPORT__attribute__((visibility("default"))) GtkWidget *
2553mate_panel_applet_get_applet_widget (const gchar *factory_id,
2554 guint uid)
2555{
2556 GtkWidget *widget;
2557
2558 widget = mate_panel_applet_factory_get_applet_widget (factory_id, uid);
2559 if (!widget) {
2560 return NULL((void*)0);
2561 }
2562
2563 mate_panel_applet_setup (MATE_PANEL_APPLET (widget));
2564
2565 return widget;
2566}
diff --git a/2024-06-18-172109-13286-1@e182420b844f_master/report-56cac4.html b/2024-06-18-172109-13286-1@e182420b844f_master/report-56cac4.html new file mode 100644 index 00000000..88623e9d --- /dev/null +++ b/2024-06-18-172109-13286-1@e182420b844f_master/report-56cac4.html @@ -0,0 +1,1977 @@ + + + +window-list.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:applets/wncklet/window-list.c
Warning:line 418, column 88
The left operand of '-' is a garbage value
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name window-list.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/applets/wncklet -fcoverage-compilation-dir=/rootdir/applets/wncklet -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I ../.. -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/gio-unix-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/libwnck-3.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/startup-notification-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/gio-unix-2.0 -I /usr/include/dconf -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I ../.. -I ../../applets/wncklet -I ../../libmate-panel-applet -I ../../libmate-panel-applet -D MATELOCALEDIR="/usr/local/share/locale" -I /usr/include/gtk-layer-shell -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/gtk-3.0 -I /usr/include/cloudproviders -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/atk-1.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/gio-unix-2.0 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -D PIC -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-18-172109-13286-1 -x c window-list.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* -*- mode: C; c-file-style: "linux" -*- */
2/*
3 * libwnck based tasklist applet.
4 * (C) 2001 Red Hat, Inc
5 * (C) 2001 Alexander Larsson
6 *
7 * Authors: Alexander Larsson
8 *
9 */
10
11#include <config.h>
12
13#include <string.h>
14
15#include <mate-panel-applet.h>
16#include <mate-panel-applet-gsettings.h>
17
18#include <glib/gi18n.h>
19#include <gtk/gtk.h>
20#include <gio/gio.h>
21
22#ifdef HAVE_X111
23#include <gdk/gdkx.h>
24#define WNCK_I_KNOW_THIS_IS_UNSTABLE
25#include <libwnck/libwnck.h>
26#endif /* HAVE_X11 */
27
28#ifdef HAVE_WAYLAND1
29#include <gdk/gdkwayland.h>
30#include "wayland-backend.h"
31#endif /* HAVE_WAYLAND */
32
33#define MATE_DESKTOP_USE_UNSTABLE_API
34#include <libmate-desktop/mate-desktop-utils.h>
35
36#include "wncklet.h"
37#include "window-list.h"
38
39#define WINDOW_LIST_ICON"mate-panel-window-list" "mate-panel-window-list"
40#define WINDOW_LIST_SCHEMA"org.mate.panel.applet.window-list" "org.mate.panel.applet.window-list"
41
42#ifdef HAVE_WINDOW_PREVIEWS1
43#define WINDOW_LIST_PREVIEW_SCHEMA"org.mate.panel.applet.window-list-previews" "org.mate.panel.applet.window-list-previews"
44#endif /* HAVE_WINDOW_PREVIEWS */
45
46typedef enum {
47 TASKLIST_NEVER_GROUP,
48 TASKLIST_AUTO_GROUP,
49 TASKLIST_ALWAYS_GROUP
50} TasklistGroupingType;
51
52typedef struct {
53 GtkWidget* applet;
54 GtkWidget* tasklist;
55#ifdef HAVE_WINDOW_PREVIEWS1
56 GtkWidget* preview;
57
58 gboolean show_window_thumbnails;
59 gint thumbnail_size;
60#endif
61 gboolean include_all_workspaces;
62
63 TasklistGroupingType grouping;
64 gboolean move_unminimized_windows;
65 gboolean scroll_enable;
66 gboolean middle_click_close;
67
68 GtkOrientation orientation;
69 int size;
70#if !defined(WNCKLET_INPROCESS1) && !GTK_CHECK_VERSION (3, 23, 0)((3) > (3) || ((3) == (3) && (24) > (23)) || ((
3) == (3) && (24) == (23) && (42) >= (0)))
71 gboolean needs_hints;
72#endif
73
74 /* Properties: */
75 GtkWidget* properties_dialog;
76 GtkWidget* wayland_info_label;
77 GtkWidget* show_current_radio;
78 GtkWidget* show_all_radio;
79#ifdef HAVE_WINDOW_PREVIEWS1
80 GtkWidget* window_thumbnail_box;
81 GtkWidget* show_thumbnails_check;
82 GtkWidget* thumbnail_size_label;
83 GtkWidget* thumbnail_size_spin;
84#endif
85 GtkWidget* never_group_radio;
86 GtkWidget* auto_group_radio;
87 GtkWidget* always_group_radio;
88 GtkWidget* move_minimized_radio;
89 GtkWidget* mouse_scroll_check;
90 GtkWidget* middle_click_close_check;
91 GtkWidget* change_workspace_radio;
92 GtkWidget* minimized_windows_box;
93 GtkWidget* window_grouping_box;
94 GtkWidget* window_list_content_box;
95
96 GSettings* settings;
97#ifdef HAVE_WINDOW_PREVIEWS1
98 GSettings* preview_settings;
99#endif
100} TasklistData;
101
102static void call_system_monitor(GtkAction* action, TasklistData* tasklist);
103static void display_properties_dialog(GtkAction* action, TasklistData* tasklist);
104static void display_help_dialog(GtkAction* action, TasklistData* tasklist);
105static void display_about_dialog(GtkAction* action, TasklistData* tasklist);
106static void destroy_tasklist(GtkWidget* widget, TasklistData* tasklist);
107
108static void tasklist_update(TasklistData* tasklist)
109{
110 if (tasklist->orientation == GTK_ORIENTATION_HORIZONTAL)
111 {
112 gtk_widget_set_size_request(GTK_WIDGET(tasklist->tasklist)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tasklist->tasklist)), ((gtk_widget_get_type ()))))))
, -1, tasklist->size);
113 }
114 else
115 {
116 gtk_widget_set_size_request(GTK_WIDGET(tasklist->tasklist)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tasklist->tasklist)), ((gtk_widget_get_type ()))))))
, tasklist->size, -1);
117 }
118
119#ifdef HAVE_X111
120 if (WNCK_IS_TASKLIST(tasklist->tasklist)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(tasklist->tasklist)); GType __t = ((wnck_tasklist_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; }))))
)
121 {
122 WnckTasklistGroupingType grouping;
123 switch (tasklist->grouping)
124 {
125 case TASKLIST_NEVER_GROUP:
126 grouping = WNCK_TASKLIST_NEVER_GROUP;
127 break;
128 case TASKLIST_AUTO_GROUP:
129 grouping = WNCK_TASKLIST_AUTO_GROUP;
130 break;
131 case TASKLIST_ALWAYS_GROUP:
132 grouping = WNCK_TASKLIST_ALWAYS_GROUP;
133 break;
134 default:
135 grouping = WNCK_TASKLIST_NEVER_GROUP;
136 }
137 wnck_tasklist_set_grouping(WNCK_TASKLIST(tasklist->tasklist)((((WnckTasklist*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tasklist->tasklist)), ((wnck_tasklist_get_type ()))))
))
, grouping);
138 wnck_tasklist_set_include_all_workspaces(WNCK_TASKLIST(tasklist->tasklist)((((WnckTasklist*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tasklist->tasklist)), ((wnck_tasklist_get_type ()))))
))
, tasklist->include_all_workspaces);
139 wnck_tasklist_set_switch_workspace_on_unminimize(WNCK_TASKLIST(tasklist->tasklist)((((WnckTasklist*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tasklist->tasklist)), ((wnck_tasklist_get_type ()))))
))
, tasklist->move_unminimized_windows);
140 wnck_tasklist_set_scroll_enabled (WNCK_TASKLIST(tasklist->tasklist)((((WnckTasklist*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tasklist->tasklist)), ((wnck_tasklist_get_type ()))))
))
, tasklist->scroll_enable);
141 wnck_tasklist_set_middle_click_close (WNCK_TASKLIST (tasklist->tasklist)((((WnckTasklist*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tasklist->tasklist)), ((wnck_tasklist_get_type ()))))
))
, tasklist->middle_click_close);
142 }
143#endif /* HAVE_X11 */
144
145 /* Not implemented for Wayland */
146}
147
148static void tasklist_apply_orientation(TasklistData* tasklist)
149{
150#ifdef HAVE_X111
151 if (WNCK_IS_TASKLIST(tasklist->tasklist)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(tasklist->tasklist)); GType __t = ((wnck_tasklist_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; }))))
)
152 {
153 wnck_tasklist_set_orientation(WNCK_TASKLIST(tasklist->tasklist)((((WnckTasklist*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tasklist->tasklist)), ((wnck_tasklist_get_type ()))))
))
, tasklist->orientation);
154 }
155#endif /* HAVE_X11 */
156
157#ifdef HAVE_WAYLAND1
158 if (GDK_IS_WAYLAND_DISPLAY(gdk_display_get_default())(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gdk_display_get_default())); GType __t = ((gdk_wayland_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
)
159 {
160 wayland_tasklist_set_orientation(tasklist->tasklist, tasklist->orientation);
161 }
162#endif
163}
164
165static void tasklist_set_button_relief(TasklistData* tasklist, GtkReliefStyle relief)
166{
167#ifdef HAVE_X111
168 if (WNCK_IS_TASKLIST(tasklist->tasklist)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(tasklist->tasklist)); GType __t = ((wnck_tasklist_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; }))))
)
169 {
170 wnck_tasklist_set_button_relief(WNCK_TASKLIST(tasklist->tasklist)((((WnckTasklist*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tasklist->tasklist)), ((wnck_tasklist_get_type ()))))
))
, relief);
171 }
172#endif /* HAVE_X11 */
173
174 /* Not implemented for Wayland */
175}
176
177static const int* tasklist_get_size_hint_list(TasklistData* tasklist, int* n_elements)
178{
179#ifdef HAVE_X111
180 if (WNCK_IS_TASKLIST(tasklist->tasklist)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(tasklist->tasklist)); GType __t = ((wnck_tasklist_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; }))))
)
181 {
182 return wnck_tasklist_get_size_hint_list(WNCK_TASKLIST(tasklist->tasklist)((((WnckTasklist*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tasklist->tasklist)), ((wnck_tasklist_get_type ()))))
))
, n_elements);
183 }
184 else
185#endif /* HAVE_X11 */
186
187 {
188 /* Not implemented for Wayland */
189 *n_elements = 0;
190 return NULL((void*)0);
191 }
192}
193
194static void response_cb(GtkWidget* widget, int id, TasklistData* tasklist)
195{
196 if (id == GTK_RESPONSE_HELP)
197 {
198 wncklet_display_help(widget, "mate-user-guide", "windowlist-prefs", WINDOW_LIST_ICON"mate-panel-window-list");
199 }
200 else
201 {
202 gtk_widget_hide(widget);
203 }
204}
205
206static void applet_change_orient(MatePanelApplet* applet, MatePanelAppletOrient orient, TasklistData* tasklist)
207{
208 GtkOrientation new_orient;
209
210 switch (orient)
211 {
212 case MATE_PANEL_APPLET_ORIENT_LEFT:
213 case MATE_PANEL_APPLET_ORIENT_RIGHT:
214 new_orient = GTK_ORIENTATION_VERTICAL;
215 break;
216 case MATE_PANEL_APPLET_ORIENT_UP:
217 case MATE_PANEL_APPLET_ORIENT_DOWN:
218 default:
219 new_orient = GTK_ORIENTATION_HORIZONTAL;
220 break;
221 }
222
223 if (new_orient == tasklist->orientation)
224 return;
225
226 tasklist->orientation = new_orient;
227 tasklist_apply_orientation (tasklist);
228
229 tasklist_update(tasklist);
230}
231
232static void applet_change_background(MatePanelApplet* applet, MatePanelAppletBackgroundType type, GdkColor* color, cairo_pattern_t* pattern, TasklistData* tasklist)
233{
234 switch (type)
235 {
236 case PANEL_NO_BACKGROUND:
237 case PANEL_COLOR_BACKGROUND:
238 case PANEL_PIXMAP_BACKGROUND:
239 tasklist_set_button_relief(tasklist, GTK_RELIEF_NONE);
240 break;
241 }
242}
243
244#ifdef HAVE_X111
245#ifdef HAVE_WINDOW_PREVIEWS1
246static cairo_surface_t*
247preview_window_thumbnail (WnckWindow *wnck_window,
248 TasklistData *tasklist,
249 int *thumbnail_width,
250 int *thumbnail_height,
251 int *thumbnail_scale)
252{
253 GdkWindow *window;
254 Window win;
255 cairo_surface_t *thumbnail;
256 cairo_t *cr;
257 double ratio;
258 int width, height, scale;
259
260 win = wnck_window_get_xid (wnck_window);
261
262 if ((window = gdk_x11_window_foreign_new_for_display (gdk_display_get_default (), win)) == NULL((void*)0))
263 {
264 return NULL((void*)0);
265 }
266
267 *thumbnail_scale = scale = gdk_window_get_scale_factor (window);
268 width = gdk_window_get_width (window) * scale;
269 height = gdk_window_get_height (window) * scale;
270
271 /* Scale to configured size while maintaining aspect ratio */
272 if (width > height)
273 {
274 int max_size = MIN (width, tasklist->thumbnail_size * scale)(((width) < (tasklist->thumbnail_size * scale)) ? (width
) : (tasklist->thumbnail_size * scale))
;
275 ratio = (double) max_size / (double) width;
276 *thumbnail_width = max_size;
277 *thumbnail_height = (int) ((double) height * ratio);
278 }
279 else
280 {
281 int max_size = MIN (height, tasklist->thumbnail_size * scale)(((height) < (tasklist->thumbnail_size * scale)) ? (height
) : (tasklist->thumbnail_size * scale))
;
282 ratio = (double) max_size / (double) height;
283 *thumbnail_height = max_size;
284 *thumbnail_width = (int) ((double) width * ratio);
285 }
286
287 gdk_x11_display_error_trap_push (gdk_window_get_display (window));
288
289 thumbnail = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
290 *thumbnail_width,
291 *thumbnail_height);
292 cairo_surface_set_device_scale (thumbnail, scale, scale);
293 cr = cairo_create (thumbnail);
294 cairo_scale (cr, ratio, ratio);
295 gdk_cairo_set_source_window (cr, window, 0, 0);
296 cairo_paint (cr);
297 cairo_destroy (cr);
298
299 if (gdk_x11_display_error_trap_pop (gdk_window_get_display (window)))
300 {
301 cairo_surface_destroy (thumbnail);
302 thumbnail = NULL((void*)0);
303 }
304
305 g_object_unref (window);
306
307 return thumbnail;
308}
309
310static int g_int_compare(gconstpointer a, gconstpointer b)
311{
312 gint a_val = GPOINTER_TO_INT(a)((gint) (glong) (a));
313 gint b_val = GPOINTER_TO_INT(b)((gint) (glong) (b));
314 if (a_val > b_val) return -1;
315 if (a_val == b_val) return 0;
316 return 1;
317}
318
319static int find_offset(GList *list, gdouble target)
320{
321 GList *node = list;
322 while (node != NULL((void*)0)) {
323 int value = GPOINTER_TO_INT(node->data)((gint) (glong) (node->data));
324 if (value <= target)
325 return value;
326 node = node->next;
327 }
328 return -1;
329}
330
331#define PREVIEW_PADDING5 5
332static void
333preview_window_reposition (WnckTasklist *tl,
334 TasklistData *tasklist,
335 int width,
336 int height,
337 int scale)
338{
339 /* Known issues:
340 * - When grouping is toggled the previews won't be centered correctly until a new window is opened or one is closed.
341 * - Previews are not shown at all for grouped windows, this function is not called when hovering over those.
342 */
343
344 GdkMonitor *monitor;
345 GdkRectangle monitor_geom;
346 MatePanelAppletOrient orient;
347 gdouble x_pos, y_pos;
348 int x_offset, y_offset;
349
350 /* Get mouse position */
351 gdk_device_get_position_double (gdk_seat_get_pointer (gdk_display_get_default_seat (gdk_display_get_default ())), NULL((void*)0), &x_pos, &y_pos);
352
353 /* Get geometry of monitor where tasklist is located to calculate correct position of preview */
354 monitor = gdk_display_get_monitor_at_point (gdk_display_get_default (), x_pos, y_pos);
355 gdk_monitor_get_geometry (monitor, &monitor_geom);
356
357 /* Get the position where the window list applet starts */
358 gdk_window_get_origin (gtk_widget_get_window (gtk_widget_get_parent (GTK_WIDGET(tl)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tl)), ((gtk_widget_get_type ()))))))
)), &x_offset, &y_offset);
359
360 /* Get panel orientation */
361 orient = mate_panel_applet_get_orient (MATE_PANEL_APPLET (tasklist->applet));
362
363 /* Add padding to clear the panel */
364 switch (orient)
15
Control jumps to 'case MATE_PANEL_APPLET_ORIENT_RIGHT:' at line 369
365 {
366 case MATE_PANEL_APPLET_ORIENT_LEFT:
367 x_pos = monitor_geom.width + monitor_geom.x - width - tasklist->size - PREVIEW_PADDING5;
368 break;
369 case MATE_PANEL_APPLET_ORIENT_RIGHT:
370 x_pos = tasklist->size + PREVIEW_PADDING5;
371 break;
372 case MATE_PANEL_APPLET_ORIENT_UP:
373 y_pos = monitor_geom.height + monitor_geom.y - height - tasklist->size - PREVIEW_PADDING5;
374 break;
375 case MATE_PANEL_APPLET_ORIENT_DOWN:
376 default:
377 y_pos = tasklist->size + PREVIEW_PADDING5;
378 break;
379 }
380
381 /* Collect the allocation.x/y values of each button into lists.
382 * We need to iterate over all of them because grouped buttons will be the last children,
383 * even though they are positioned at the beginning. And not all buttons will have the exact same width.
384 * This allows us to avoid off-by-one errors that would cause the preview to be positioned over the adjacent button. */
385 GList *alloc_x_list = NULL((void*)0);
16
Execution continues on line 385
386 GList *alloc_y_list = NULL((void*)0);
387 GtkAllocation last_alloc;
388 GList* children = gtk_container_get_children (GTK_CONTAINER(tl)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tl)), ((gtk_container_get_type ()))))))
);
389 while (children != NULL((void*)0))
17
Assuming 'children' is equal to NULL
390 {
391 if (g_strcmp0 (gtk_widget_get_name (children->data), "tasklist-button") == 0) {
392 GtkAllocation alloc;
393 gtk_widget_get_allocation (children->data, &alloc);
394
395 /* Skip grouped buttons: these usually have alloc width/heigh=1, except right after grouping is toggled.
396 * Then simply open or close a new window to get the correct offset. */
397 if (alloc.width < 2 || alloc.height < 2)
398 {
399 children = children->next;
400 continue;
401 }
402
403 /* Keep x and y offsets in sorted lists */
404 alloc_x_list = g_list_insert_sorted (alloc_x_list, GINT_TO_POINTER(alloc.x)((gpointer) (glong) (alloc.x)), g_int_compare);
405 alloc_y_list = g_list_insert_sorted (alloc_y_list, GINT_TO_POINTER(alloc.y)((gpointer) (glong) (alloc.y)), g_int_compare);
406
407 /* The width/height from the last allocation will be used for centering the preview.
408 * It might be off by a pixel because not all buttons have the exact same width/height but this isn't critical. */
409 last_alloc = alloc;
410 }
411 children = children->next;
412 }
413
414 /* Center preview at the midpoint of the tasklist button */
415 if (orient
17.1
'orient' is not equal to MATE_PANEL_APPLET_ORIENT_LEFT
== MATE_PANEL_APPLET_ORIENT_LEFT || orient
17.2
'orient' is equal to MATE_PANEL_APPLET_ORIENT_RIGHT
== MATE_PANEL_APPLET_ORIENT_RIGHT)
18
Taking true branch
416 {
417 /* Vertical panel */
418 y_pos = y_offset + find_offset (alloc_y_list, y_pos - y_offset) + (last_alloc.height - height) / 2;
19
The left operand of '-' is a garbage value
419 y_pos = y_pos < PREVIEW_PADDING5 ? PREVIEW_PADDING5 : y_pos;
420 }
421 else if (orient == MATE_PANEL_APPLET_ORIENT_UP || orient == MATE_PANEL_APPLET_ORIENT_DOWN)
422 {
423 /* Horizontal panel */
424 x_pos = x_offset + find_offset (alloc_x_list, x_pos - x_offset) + (last_alloc.width - width) / 2;
425 x_pos = x_pos < PREVIEW_PADDING5 ? PREVIEW_PADDING5 : x_pos;
426 }
427
428 g_list_free (alloc_x_list);
429 g_list_free (alloc_y_list);
430
431 gtk_window_move (GTK_WINDOW (tasklist->preview)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tasklist->preview)), ((gtk_window_get_type ()))))))
, x_pos, y_pos);
432}
433
434static gboolean preview_window_draw (GtkWidget *widget, cairo_t *cr, cairo_surface_t *thumbnail)
435{
436 GtkStyleContext *context;
437
438 context = gtk_widget_get_style_context (widget);
439 gtk_render_icon_surface (context, cr, thumbnail, 0, 0);
440
441 return FALSE(0);
442}
443
444static gboolean applet_enter_notify_event (WnckTasklist *tl, GList *wnck_windows, TasklistData *tasklist)
445{
446 cairo_surface_t *thumbnail;
447 WnckWindow *wnck_window = NULL((void*)0);
448 int n_windows;
449 int thumbnail_width;
450 int thumbnail_height;
451 int thumbnail_scale;
452
453 if (tasklist->preview != NULL((void*)0))
1
Assuming field 'preview' is equal to NULL
454 {
455 gtk_widget_destroy (tasklist->preview);
456 tasklist->preview = NULL((void*)0);
457 }
458
459 if (!tasklist->show_window_thumbnails || wnck_windows == NULL((void*)0))
2
Assuming field 'show_window_thumbnails' is not equal to 0
3
Assuming 'wnck_windows' is not equal to NULL
4
Taking false branch
460 return FALSE(0);
461
462 n_windows = g_list_length (wnck_windows);
463 /* TODO: Display a list of stacked thumbnails for grouped windows. */
464 if (n_windows == 1)
5
Assuming 'n_windows' is equal to 1
6
Taking true branch
465 {
466 GList* l = wnck_windows;
467 if (l
6.1
'l' is not equal to NULL
!= NULL((void*)0))
7
Taking true branch
468 wnck_window = (WnckWindow*)l->data;
469 }
470
471 if (wnck_window == NULL((void*)0))
8
Assuming 'wnck_window' is not equal to NULL
9
Taking false branch
472 return FALSE(0);
473
474 /* Do not show preview if window is not visible nor in current workspace */
475 if (!wnck_window_is_visible_on_workspace (wnck_window,
10
Assuming the condition is false
11
Taking false branch
476 wnck_screen_get_active_workspace (wnck_screen_get_default ())))
477 return FALSE(0);
478
479 thumbnail = preview_window_thumbnail (wnck_window, tasklist, &thumbnail_width, &thumbnail_height, &thumbnail_scale);
480
481 if (thumbnail == NULL((void*)0))
12
Assuming 'thumbnail' is not equal to NULL
13
Taking false branch
482 return FALSE(0);
483
484 /* Create window to display preview */
485 tasklist->preview = gtk_window_new (GTK_WINDOW_POPUP);
486
487 gtk_widget_set_app_paintable (tasklist->preview, TRUE(!(0)));
488 gtk_window_set_default_size (GTK_WINDOW (tasklist->preview)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tasklist->preview)), ((gtk_window_get_type ()))))))
, thumbnail_width/thumbnail_scale, thumbnail_height/thumbnail_scale);
489 gtk_window_set_resizable (GTK_WINDOW (tasklist->preview)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tasklist->preview)), ((gtk_window_get_type ()))))))
, TRUE(!(0)));
490 preview_window_reposition (tl, tasklist, thumbnail_width/thumbnail_scale, thumbnail_height/thumbnail_scale, thumbnail_scale);
14
Calling 'preview_window_reposition'
491
492 gtk_widget_show (tasklist->preview);
493
494 g_signal_connect_data (tasklist->preview, "draw",
495 G_CALLBACK (preview_window_draw)((GCallback) (preview_window_draw)), thumbnail,
496 (GClosureNotify) G_CALLBACK (cairo_surface_destroy)((GCallback) (cairo_surface_destroy)),
497 0);
498
499 return FALSE(0);
500}
501
502static gboolean applet_leave_notify_event (WnckTasklist *tl, GList *wnck_windows, TasklistData *tasklist)
503{
504 if (tasklist->preview != NULL((void*)0))
505 {
506 gtk_widget_destroy (tasklist->preview);
507 tasklist->preview = NULL((void*)0);
508 }
509
510 return FALSE(0);
511}
512#endif /* HAVE_WINDOW_PREVIEWS */
513#endif /* HAVE_X11 */
514
515static void applet_change_pixel_size(MatePanelApplet* applet, gint size, TasklistData* tasklist)
516{
517 if (tasklist->size == size)
518 return;
519
520 tasklist->size = size;
521
522 tasklist_update(tasklist);
523}
524
525/* TODO: this is sad, should be used a function to retrieve applications from
526 * .desktop or some like that. */
527static const char* system_monitors[] = {
528 "mate-system-monitor",
529 "gnome-system-monitor",
530};
531
532static const GtkActionEntry tasklist_menu_actions[] = {
533 {
534 "TasklistSystemMonitor",
535 "utilities-system-monitor",
536 N_("_System Monitor")("_System Monitor"),
537 NULL((void*)0),
538 NULL((void*)0),
539 G_CALLBACK(call_system_monitor)((GCallback) (call_system_monitor))
540 },
541 {
542 "TasklistPreferences",
543 "document-properties",
544 N_("_Preferences")("_Preferences"),
545 NULL((void*)0),
546 NULL((void*)0),
547 G_CALLBACK(display_properties_dialog)((GCallback) (display_properties_dialog))
548 },
549 {
550 "TasklistHelp",
551 "help-browser",
552 N_("_Help")("_Help"),
553 NULL((void*)0),
554 NULL((void*)0),
555 G_CALLBACK(display_help_dialog)((GCallback) (display_help_dialog))
556 },
557 {
558 "TasklistAbout",
559 "help-about",
560 N_("_About")("_About"),
561 NULL((void*)0),
562 NULL((void*)0),
563 G_CALLBACK(display_about_dialog)((GCallback) (display_about_dialog))
564 }
565};
566
567static void tasklist_properties_update_content_radio(TasklistData* tasklist)
568{
569 GtkWidget* button;
570
571 if (tasklist->show_current_radio == NULL((void*)0))
572 return;
573
574 if (tasklist->include_all_workspaces)
575 {
576 button = tasklist->show_all_radio;
577 }
578 else
579 {
580 button = tasklist->show_current_radio;
581 }
582
583 if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), ((gtk_toggle_button_get_type ()))))))
))
584 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button)((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), ((gtk_toggle_button_get_type ()))))))
, TRUE(!(0)));
585
586 gtk_widget_set_sensitive(tasklist->minimized_windows_box, tasklist->include_all_workspaces);
587}
588
589static void display_all_workspaces_changed(GSettings* settings, gchar* key, TasklistData* tasklist)
590{
591 gboolean value;
592
593 value = g_settings_get_boolean(settings, key);
594
595 tasklist->include_all_workspaces = (value != 0);
596 tasklist_update(tasklist);
597
598 tasklist_properties_update_content_radio(tasklist);
599}
600
601#ifdef HAVE_WINDOW_PREVIEWS1
602static void tasklist_update_thumbnail_size_spin(TasklistData* tasklist)
603{
604 GtkWidget* button;
605
606 if (!tasklist->thumbnail_size)
607 return;
608
609 button = tasklist->thumbnail_size_spin;
610
611 gtk_spin_button_set_value(GTK_SPIN_BUTTON(button)((((GtkSpinButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), ((gtk_spin_button_get_type ()))))))
, (gdouble)tasklist->thumbnail_size);
612}
613
614static void show_thumbnails_changed(GSettings* settings, gchar* key, TasklistData* tasklist)
615{
616 tasklist->show_window_thumbnails = g_settings_get_boolean (settings, key);
617}
618
619static void thumbnail_size_changed(GSettings *settings, gchar* key, TasklistData* tasklist)
620{
621 tasklist->thumbnail_size = g_settings_get_int(settings, key);
622 tasklist_update_thumbnail_size_spin(tasklist);
623}
624#endif
625
626static GtkWidget* get_grouping_button(TasklistData* tasklist, TasklistGroupingType type)
627{
628 switch (type)
629 {
630 default:
631 case TASKLIST_NEVER_GROUP:
632 return tasklist->never_group_radio;
633 break;
634 case TASKLIST_AUTO_GROUP:
635 return tasklist->auto_group_radio;
636 break;
637 case TASKLIST_ALWAYS_GROUP:
638 return tasklist->always_group_radio;
639 break;
640 }
641}
642
643static void group_windows_changed(GSettings* settings, gchar* key, TasklistData* tasklist)
644{
645 TasklistGroupingType type;
646 GtkWidget* button;
647
648 type = g_settings_get_enum (settings, key);
649
650 tasklist->grouping = type;
651 tasklist_update(tasklist);
652
653 button = get_grouping_button(tasklist, type);
654
655 if (button && !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), ((gtk_toggle_button_get_type ()))))))
))
656 {
657 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button)((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), ((gtk_toggle_button_get_type ()))))))
, TRUE(!(0)));
658 }
659}
660
661static void tasklist_update_unminimization_radio(TasklistData* tasklist)
662{
663 GtkWidget* button;
664
665 if (tasklist->move_minimized_radio == NULL((void*)0))
666 return;
667
668 if (tasklist->move_unminimized_windows)
669 {
670 button = tasklist->move_minimized_radio;
671 }
672 else
673 {
674 button = tasklist->change_workspace_radio;
675 }
676
677 if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), ((gtk_toggle_button_get_type ()))))))
))
678 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button)((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), ((gtk_toggle_button_get_type ()))))))
, TRUE(!(0)));
679}
680
681static void move_unminimized_windows_changed(GSettings* settings, gchar* key, TasklistData* tasklist)
682{
683 gboolean value;
684
685 value = g_settings_get_boolean(settings, key);
686
687 tasklist->move_unminimized_windows = (value != 0);
688 tasklist_update(tasklist);
689
690 tasklist_update_unminimization_radio(tasklist);
691}
692
693static void scroll_enabled_changed (GSettings* settings, gchar* key, TasklistData* tasklist)
694{
695 tasklist->scroll_enable = g_settings_get_boolean (settings, key);
696 tasklist_update(tasklist);
697}
698
699static void middle_click_close_changed (GSettings* settings, gchar* key, TasklistData* tasklist)
700{
701 tasklist->middle_click_close = g_settings_get_boolean (settings, key);
702 tasklist_update(tasklist);
703}
704
705static void setup_gsettings(TasklistData* tasklist)
706{
707 tasklist->settings = mate_panel_applet_settings_new (MATE_PANEL_APPLET (tasklist->applet), WINDOW_LIST_SCHEMA"org.mate.panel.applet.window-list");
708
709 g_signal_connect (tasklist->settings,g_signal_connect_data ((tasklist->settings), ("changed::display-all-workspaces"
), (((GCallback) (display_all_workspaces_changed))), (tasklist
), ((void*)0), (GConnectFlags) 0)
710 "changed::display-all-workspaces",g_signal_connect_data ((tasklist->settings), ("changed::display-all-workspaces"
), (((GCallback) (display_all_workspaces_changed))), (tasklist
), ((void*)0), (GConnectFlags) 0)
711 G_CALLBACK (display_all_workspaces_changed),g_signal_connect_data ((tasklist->settings), ("changed::display-all-workspaces"
), (((GCallback) (display_all_workspaces_changed))), (tasklist
), ((void*)0), (GConnectFlags) 0)
712 tasklist)g_signal_connect_data ((tasklist->settings), ("changed::display-all-workspaces"
), (((GCallback) (display_all_workspaces_changed))), (tasklist
), ((void*)0), (GConnectFlags) 0)
;
713
714#ifdef HAVE_WINDOW_PREVIEWS1
715 tasklist->preview_settings = mate_panel_applet_settings_new (MATE_PANEL_APPLET (tasklist->applet), WINDOW_LIST_PREVIEW_SCHEMA"org.mate.panel.applet.window-list-previews");
716
717 g_signal_connect (tasklist->preview_settings,g_signal_connect_data ((tasklist->preview_settings), ("changed::show-window-thumbnails"
), (((GCallback) (show_thumbnails_changed))), (tasklist), ((void
*)0), (GConnectFlags) 0)
718 "changed::show-window-thumbnails",g_signal_connect_data ((tasklist->preview_settings), ("changed::show-window-thumbnails"
), (((GCallback) (show_thumbnails_changed))), (tasklist), ((void
*)0), (GConnectFlags) 0)
719 G_CALLBACK (show_thumbnails_changed),g_signal_connect_data ((tasklist->preview_settings), ("changed::show-window-thumbnails"
), (((GCallback) (show_thumbnails_changed))), (tasklist), ((void
*)0), (GConnectFlags) 0)
720 tasklist)g_signal_connect_data ((tasklist->preview_settings), ("changed::show-window-thumbnails"
), (((GCallback) (show_thumbnails_changed))), (tasklist), ((void
*)0), (GConnectFlags) 0)
;
721
722 g_signal_connect (tasklist->preview_settings,g_signal_connect_data ((tasklist->preview_settings), ("changed::thumbnail-window-size"
), (((GCallback) (thumbnail_size_changed))), (tasklist), ((void
*)0), (GConnectFlags) 0)
723 "changed::thumbnail-window-size",g_signal_connect_data ((tasklist->preview_settings), ("changed::thumbnail-window-size"
), (((GCallback) (thumbnail_size_changed))), (tasklist), ((void
*)0), (GConnectFlags) 0)
724 G_CALLBACK (thumbnail_size_changed),g_signal_connect_data ((tasklist->preview_settings), ("changed::thumbnail-window-size"
), (((GCallback) (thumbnail_size_changed))), (tasklist), ((void
*)0), (GConnectFlags) 0)
725 tasklist)g_signal_connect_data ((tasklist->preview_settings), ("changed::thumbnail-window-size"
), (((GCallback) (thumbnail_size_changed))), (tasklist), ((void
*)0), (GConnectFlags) 0)
;
726#endif
727 g_signal_connect (tasklist->settings,g_signal_connect_data ((tasklist->settings), ("changed::group-windows"
), (((GCallback) (group_windows_changed))), (tasklist), ((void
*)0), (GConnectFlags) 0)
728 "changed::group-windows",g_signal_connect_data ((tasklist->settings), ("changed::group-windows"
), (((GCallback) (group_windows_changed))), (tasklist), ((void
*)0), (GConnectFlags) 0)
729 G_CALLBACK (group_windows_changed),g_signal_connect_data ((tasklist->settings), ("changed::group-windows"
), (((GCallback) (group_windows_changed))), (tasklist), ((void
*)0), (GConnectFlags) 0)
730 tasklist)g_signal_connect_data ((tasklist->settings), ("changed::group-windows"
), (((GCallback) (group_windows_changed))), (tasklist), ((void
*)0), (GConnectFlags) 0)
;
731 g_signal_connect (tasklist->settings,g_signal_connect_data ((tasklist->settings), ("changed::move-unminimized-windows"
), (((GCallback) (move_unminimized_windows_changed))), (tasklist
), ((void*)0), (GConnectFlags) 0)
732 "changed::move-unminimized-windows",g_signal_connect_data ((tasklist->settings), ("changed::move-unminimized-windows"
), (((GCallback) (move_unminimized_windows_changed))), (tasklist
), ((void*)0), (GConnectFlags) 0)
733 G_CALLBACK (move_unminimized_windows_changed),g_signal_connect_data ((tasklist->settings), ("changed::move-unminimized-windows"
), (((GCallback) (move_unminimized_windows_changed))), (tasklist
), ((void*)0), (GConnectFlags) 0)
734 tasklist)g_signal_connect_data ((tasklist->settings), ("changed::move-unminimized-windows"
), (((GCallback) (move_unminimized_windows_changed))), (tasklist
), ((void*)0), (GConnectFlags) 0)
;
735 g_signal_connect (tasklist->settings,g_signal_connect_data ((tasklist->settings), ("changed::scroll-enabled"
), (((GCallback) (scroll_enabled_changed))), (tasklist), ((void
*)0), (GConnectFlags) 0)
736 "changed::scroll-enabled",g_signal_connect_data ((tasklist->settings), ("changed::scroll-enabled"
), (((GCallback) (scroll_enabled_changed))), (tasklist), ((void
*)0), (GConnectFlags) 0)
737 G_CALLBACK (scroll_enabled_changed),g_signal_connect_data ((tasklist->settings), ("changed::scroll-enabled"
), (((GCallback) (scroll_enabled_changed))), (tasklist), ((void
*)0), (GConnectFlags) 0)
738 tasklist)g_signal_connect_data ((tasklist->settings), ("changed::scroll-enabled"
), (((GCallback) (scroll_enabled_changed))), (tasklist), ((void
*)0), (GConnectFlags) 0)
;
739 g_signal_connect (tasklist->settings,g_signal_connect_data ((tasklist->settings), ("changed::middle-click-close"
), (((GCallback) (middle_click_close_changed))), (tasklist), (
(void*)0), (GConnectFlags) 0)
740 "changed::middle-click-close",g_signal_connect_data ((tasklist->settings), ("changed::middle-click-close"
), (((GCallback) (middle_click_close_changed))), (tasklist), (
(void*)0), (GConnectFlags) 0)
741 G_CALLBACK (middle_click_close_changed),g_signal_connect_data ((tasklist->settings), ("changed::middle-click-close"
), (((GCallback) (middle_click_close_changed))), (tasklist), (
(void*)0), (GConnectFlags) 0)
742 tasklist)g_signal_connect_data ((tasklist->settings), ("changed::middle-click-close"
), (((GCallback) (middle_click_close_changed))), (tasklist), (
(void*)0), (GConnectFlags) 0)
;
743}
744
745static void applet_size_allocate(GtkWidget *widget, GtkAllocation *allocation, TasklistData *tasklist)
746{
747 int len;
748 const int* size_hints;
749
750 size_hints = tasklist_get_size_hint_list (tasklist, &len);
751
752 g_assert(len % 2 == 0)do { if (len % 2 == 0) ; else g_assertion_message_expr (((gchar
*) 0), "window-list.c", 752, ((const char*) (__func__)), "len % 2 == 0"
); } while (0)
;
753
754#if !defined(WNCKLET_INPROCESS1) && !GTK_CHECK_VERSION (3, 23, 0)((3) > (3) || ((3) == (3) && (24) > (23)) || ((
3) == (3) && (24) == (23) && (42) >= (0)))
755 /* HACK: When loading the WnckTasklist initially, it reports size hints as though there were
756 * no elements in the Tasklist. This causes a rendering issue when built out-of-process in
757 * HiDPI displays. We keep a flag to skip size hinting until WnckTasklist has something to
758 * show. */
759 if (!tasklist->needs_hints)
760 {
761 int i;
762 for (i = 0; i < len; i++)
763 {
764 if (size_hints[i])
765 {
766 tasklist->needs_hints = TRUE(!(0));
767 break;
768 }
769 }
770 }
771
772 if (tasklist->needs_hints)
773#endif
774 mate_panel_applet_set_size_hints(MATE_PANEL_APPLET(tasklist->applet), size_hints, len, 0);
775}
776
777gboolean window_list_applet_fill(MatePanelApplet* applet)
778{
779 TasklistData* tasklist;
780 GtkActionGroup* action_group;
781 GtkCssProvider *provider;
782 GdkScreen *screen;
783
784 tasklist = g_new0(TasklistData, 1)((TasklistData *) g_malloc0_n ((1), sizeof (TasklistData)));
785
786 tasklist->applet = GTK_WIDGET(applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
;
787
788 provider = gtk_css_provider_new ();
789 screen = gdk_screen_get_default ();
790 gtk_css_provider_load_from_data (provider,
791 ".mate-panel-menu-bar button,\n"
792 " #tasklist-button {\n"
793 " padding: 0px;\n"
794 " margin: 0px;\n }",
795 -1, NULL((void*)0));
796 gtk_style_context_add_provider_for_screen (screen,
797 GTK_STYLE_PROVIDER (provider)((((GtkStyleProvider*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((provider)), ((gtk_style_provider_get_type (
)))))))
,
798 GTK_STYLE_PROVIDER_PRIORITY_APPLICATION600);
799 g_object_unref (provider);
800
801 mate_panel_applet_set_flags(MATE_PANEL_APPLET(tasklist->applet), MATE_PANEL_APPLET_EXPAND_MAJOR | MATE_PANEL_APPLET_EXPAND_MINOR | MATE_PANEL_APPLET_HAS_HANDLE);
802
803 setup_gsettings(tasklist);
804
805 tasklist->include_all_workspaces = g_settings_get_boolean (tasklist->settings, "display-all-workspaces");
806
807#ifdef HAVE_WINDOW_PREVIEWS1
808 tasklist->show_window_thumbnails = g_settings_get_boolean (tasklist->preview_settings, "show-window-thumbnails");
809
810 tasklist->thumbnail_size = g_settings_get_int (tasklist->preview_settings, "thumbnail-window-size");
811#endif
812
813 tasklist->grouping = g_settings_get_enum (tasklist->settings, "group-windows");
814
815 tasklist->move_unminimized_windows = g_settings_get_boolean (tasklist->settings, "move-unminimized-windows");
816
817 tasklist->scroll_enable = g_settings_get_boolean (tasklist->settings, "scroll-enabled");
818
819 tasklist->middle_click_close = g_settings_get_boolean (tasklist->settings, "middle-click-close");
820
821 tasklist->size = mate_panel_applet_get_size(applet);
822
823#if !defined(WNCKLET_INPROCESS1) && !GTK_CHECK_VERSION (3, 23, 0)((3) > (3) || ((3) == (3) && (24) > (23)) || ((
3) == (3) && (24) == (23) && (42) >= (0)))
824 tasklist->needs_hints = FALSE(0);
825#endif
826
827 switch (mate_panel_applet_get_orient(applet))
828 {
829 case MATE_PANEL_APPLET_ORIENT_LEFT:
830 case MATE_PANEL_APPLET_ORIENT_RIGHT:
831 tasklist->orientation = GTK_ORIENTATION_VERTICAL;
832 break;
833 case MATE_PANEL_APPLET_ORIENT_UP:
834 case MATE_PANEL_APPLET_ORIENT_DOWN:
835 default:
836 tasklist->orientation = GTK_ORIENTATION_HORIZONTAL;
837 break;
838 }
839
840#ifdef HAVE_X111
841 if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gdk_display_get_default ())); GType __t = ((gdk_x11_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
)
842 {
843 tasklist->tasklist = wnck_tasklist_new();
844
845#ifdef HAVE_WINDOW_PREVIEWS1
846 g_signal_connect (tasklist->tasklist, "task-enter-notify",g_signal_connect_data ((tasklist->tasklist), ("task-enter-notify"
), (((GCallback) (applet_enter_notify_event))), (tasklist), (
(void*)0), (GConnectFlags) 0)
847 G_CALLBACK (applet_enter_notify_event),g_signal_connect_data ((tasklist->tasklist), ("task-enter-notify"
), (((GCallback) (applet_enter_notify_event))), (tasklist), (
(void*)0), (GConnectFlags) 0)
848 tasklist)g_signal_connect_data ((tasklist->tasklist), ("task-enter-notify"
), (((GCallback) (applet_enter_notify_event))), (tasklist), (
(void*)0), (GConnectFlags) 0)
;
849 g_signal_connect (tasklist->tasklist, "task-leave-notify",g_signal_connect_data ((tasklist->tasklist), ("task-leave-notify"
), (((GCallback) (applet_leave_notify_event))), (tasklist), (
(void*)0), (GConnectFlags) 0)
850 G_CALLBACK (applet_leave_notify_event),g_signal_connect_data ((tasklist->tasklist), ("task-leave-notify"
), (((GCallback) (applet_leave_notify_event))), (tasklist), (
(void*)0), (GConnectFlags) 0)
851 tasklist)g_signal_connect_data ((tasklist->tasklist), ("task-leave-notify"
), (((GCallback) (applet_leave_notify_event))), (tasklist), (
(void*)0), (GConnectFlags) 0)
;
852#endif /* HAVE_WINDOW_PREVIEWS */
853 }
854 else
855#endif /* HAVE_X11 */
856
857#ifdef HAVE_WAYLAND1
858 if (GDK_IS_WAYLAND_DISPLAY (gdk_display_get_default ())(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gdk_display_get_default ())); GType __t = ((gdk_wayland_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
)
859 {
860 tasklist->tasklist = wayland_tasklist_new();
861 }
862 else
863#endif /* HAVE_WAYLAND */
864
865 {
866 tasklist->tasklist = gtk_label_new ("[Tasklist not supported on this platform]");
867 }
868
869 tasklist_apply_orientation(tasklist);
870
871 g_signal_connect (tasklist->tasklist, "destroy",g_signal_connect_data ((tasklist->tasklist), ("destroy"), (
((GCallback) (destroy_tasklist))), (tasklist), ((void*)0), (GConnectFlags
) 0)
872 G_CALLBACK (destroy_tasklist),g_signal_connect_data ((tasklist->tasklist), ("destroy"), (
((GCallback) (destroy_tasklist))), (tasklist), ((void*)0), (GConnectFlags
) 0)
873 tasklist)g_signal_connect_data ((tasklist->tasklist), ("destroy"), (
((GCallback) (destroy_tasklist))), (tasklist), ((void*)0), (GConnectFlags
) 0)
;
874 g_signal_connect (tasklist->applet, "size-allocate",g_signal_connect_data ((tasklist->applet), ("size-allocate"
), (((GCallback) (applet_size_allocate))), (tasklist), ((void
*)0), (GConnectFlags) 0)
875 G_CALLBACK (applet_size_allocate),g_signal_connect_data ((tasklist->applet), ("size-allocate"
), (((GCallback) (applet_size_allocate))), (tasklist), ((void
*)0), (GConnectFlags) 0)
876 tasklist)g_signal_connect_data ((tasklist->applet), ("size-allocate"
), (((GCallback) (applet_size_allocate))), (tasklist), ((void
*)0), (GConnectFlags) 0)
;
877
878 gtk_container_add(GTK_CONTAINER(tasklist->applet)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tasklist->applet)), ((gtk_container_get_type ()))))))
, tasklist->tasklist);
879
880 g_signal_connect (tasklist->applet, "change-orient",g_signal_connect_data ((tasklist->applet), ("change-orient"
), (((GCallback) (applet_change_orient))), (tasklist), ((void
*)0), (GConnectFlags) 0)
881 G_CALLBACK (applet_change_orient),g_signal_connect_data ((tasklist->applet), ("change-orient"
), (((GCallback) (applet_change_orient))), (tasklist), ((void
*)0), (GConnectFlags) 0)
882 tasklist)g_signal_connect_data ((tasklist->applet), ("change-orient"
), (((GCallback) (applet_change_orient))), (tasklist), ((void
*)0), (GConnectFlags) 0)
;
883 g_signal_connect (tasklist->applet, "change-size",g_signal_connect_data ((tasklist->applet), ("change-size")
, (((GCallback) (applet_change_pixel_size))), (tasklist), ((void
*)0), (GConnectFlags) 0)
884 G_CALLBACK (applet_change_pixel_size),g_signal_connect_data ((tasklist->applet), ("change-size")
, (((GCallback) (applet_change_pixel_size))), (tasklist), ((void
*)0), (GConnectFlags) 0)
885 tasklist)g_signal_connect_data ((tasklist->applet), ("change-size")
, (((GCallback) (applet_change_pixel_size))), (tasklist), ((void
*)0), (GConnectFlags) 0)
;
886 g_signal_connect (tasklist->applet, "change-background",g_signal_connect_data ((tasklist->applet), ("change-background"
), (((GCallback) (applet_change_background))), (tasklist), ((
void*)0), (GConnectFlags) 0)
887 G_CALLBACK(applet_change_background),g_signal_connect_data ((tasklist->applet), ("change-background"
), (((GCallback) (applet_change_background))), (tasklist), ((
void*)0), (GConnectFlags) 0)
888 tasklist)g_signal_connect_data ((tasklist->applet), ("change-background"
), (((GCallback) (applet_change_background))), (tasklist), ((
void*)0), (GConnectFlags) 0)
;
889
890 action_group = gtk_action_group_new("Tasklist Applet Actions");
891 gtk_action_group_set_translation_domain(action_group, GETTEXT_PACKAGE"mate-panel");
892 gtk_action_group_add_actions(action_group, tasklist_menu_actions, G_N_ELEMENTS(tasklist_menu_actions)(sizeof (tasklist_menu_actions) / sizeof ((tasklist_menu_actions
)[0]))
, tasklist);
893
894 /* disable the item of system monitor, if not exists.
895 * example, mate-system-monitor, o gnome-system-monitor */
896 char* programpath;
897 gsize i;
898
899 for (i = 0; i < G_N_ELEMENTS(system_monitors)(sizeof (system_monitors) / sizeof ((system_monitors)[0])); i += 1)
900 {
901 programpath = g_find_program_in_path(system_monitors[i]);
902
903 if (programpath != NULL((void*)0))
904 {
905 g_free(programpath);
906 /* we give up */
907 goto _system_monitor_found;
908 }
909
910 /* search another */
911 }
912
913 /* system monitor not found */
914 gtk_action_set_visible(gtk_action_group_get_action(action_group, "TasklistSystemMonitor"), FALSE(0));
915
916 _system_monitor_found:;
917 /* end of system monitor item */
918
919 mate_panel_applet_setup_menu_from_resource (MATE_PANEL_APPLET (tasklist->applet),
920 WNCKLET_RESOURCE_PATH"/org/mate/panel/applet/wncklet/" "window-list-menu.xml",
921 action_group);
922
923 if (mate_panel_applet_get_locked_down(MATE_PANEL_APPLET(tasklist->applet)))
924 {
925 GtkAction* action;
926
927 action = gtk_action_group_get_action(action_group, "TasklistPreferences");
928 gtk_action_set_visible(action, FALSE(0));
929 }
930
931 g_object_unref(action_group);
932
933 tasklist_update(tasklist);
934 gtk_widget_show(tasklist->tasklist);
935 gtk_widget_show(tasklist->applet);
936
937 return TRUE(!(0));
938}
939
940static void call_system_monitor(GtkAction* action, TasklistData* tasklist)
941{
942 gsize i;
943
944 for (i = 0; i < G_N_ELEMENTS(system_monitors)(sizeof (system_monitors) / sizeof ((system_monitors)[0])); i += 1)
945 {
946 char *programpath = g_find_program_in_path(system_monitors[i]);
947
948 if (programpath != NULL((void*)0))
949 {
950 g_free(programpath);
951
952 mate_gdk_spawn_command_line_on_screen(gtk_widget_get_screen(tasklist->applet),
953 system_monitors[i],
954 NULL((void*)0));
955 return;
956 }
957 }
958}
959
960static void display_help_dialog(GtkAction* action, TasklistData* tasklist)
961{
962 wncklet_display_help(tasklist->applet, "mate-user-guide", "windowlist", WINDOW_LIST_ICON"mate-panel-window-list");
963}
964
965static void display_about_dialog(GtkAction* action, TasklistData* tasklist)
966{
967 static const gchar* authors[] = {
968 "Perberos <perberos@gmail.com>",
969 "Steve Zesch <stevezesch2@gmail.com>",
970 "Stefano Karapetsas <stefano@karapetsas.com>",
971 "Alexander Larsson <alla@lysator.liu.se>",
972 NULL((void*)0)
973 };
974
975 const char* documenters [] = {
976 "Sun GNOME Documentation Team <gdocteam@sun.com>",
977 NULL((void*)0)
978 };
979
980 gtk_show_about_dialog(GTK_WINDOW(tasklist->applet)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tasklist->applet)), ((gtk_window_get_type ()))))))
,
981 "program-name", _("Window List")gettext ("Window List"),
982 "title", _("About Window List")gettext ("About Window List"),
983 "authors", authors,
984 "comments", _("The Window List shows a list of all windows in a set of buttons and lets you browse them.")gettext ("The Window List shows a list of all windows in a set of buttons and lets you browse them."
)
,
985 "copyright", _("Copyright \xc2\xa9 2002 Red Hat, Inc.\n"gettext ("Copyright \xc2\xa9 2002 Red Hat, Inc.\n" "Copyright \xc2\xa9 2011 Perberos\n"
"Copyright \xc2\xa9 2012-2021 MATE developers")
986 "Copyright \xc2\xa9 2011 Perberos\n"gettext ("Copyright \xc2\xa9 2002 Red Hat, Inc.\n" "Copyright \xc2\xa9 2011 Perberos\n"
"Copyright \xc2\xa9 2012-2021 MATE developers")
987 "Copyright \xc2\xa9 2012-2021 MATE developers")gettext ("Copyright \xc2\xa9 2002 Red Hat, Inc.\n" "Copyright \xc2\xa9 2011 Perberos\n"
"Copyright \xc2\xa9 2012-2021 MATE developers")
,
988 "documenters", documenters,
989 "icon-name", WINDOW_LIST_ICON"mate-panel-window-list",
990 "logo-icon-name", WINDOW_LIST_ICON"mate-panel-window-list",
991 "translator-credits", _("translator-credits")gettext ("translator-credits"),
992 "version", VERSION"1.29.0",
993 "website", PACKAGE_URL"https://mate-desktop.org",
994 NULL((void*)0));
995}
996
997static void group_windows_toggled(GtkToggleButton* button, TasklistData* tasklist)
998{
999 if (gtk_toggle_button_get_active(button))
1000 {
1001 gchar *value;
1002 value = g_object_get_data (G_OBJECT (button)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), (((GType) ((20) << (2))))))))
, "group_value");
1003 g_settings_set_string (tasklist->settings, "group-windows", value);
1004 }
1005}
1006
1007#ifdef HAVE_WINDOW_PREVIEWS1
1008static void thumbnail_size_spin_changed(GtkSpinButton* button, TasklistData* tasklist)
1009{
1010 g_settings_set_int(tasklist->preview_settings, "thumbnail-window-size", gtk_spin_button_get_value_as_int(button));
1011}
1012#endif
1013
1014static void move_minimized_toggled(GtkToggleButton* button, TasklistData* tasklist)
1015{
1016 g_settings_set_boolean(tasklist->settings, "move-unminimized-windows", gtk_toggle_button_get_active(button));
1017}
1018
1019static void display_all_workspaces_toggled(GtkToggleButton* button, TasklistData* tasklist)
1020{
1021 g_settings_set_boolean(tasklist->settings, "display-all-workspaces", gtk_toggle_button_get_active(button));
1022}
1023
1024#define WID(s)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object(builder, s))), ((gtk_widget_get_type
()))))))
GTK_WIDGET(gtk_builder_get_object(builder, s))((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object(builder, s))), ((gtk_widget_get_type
()))))))
1025
1026static void setup_sensitivity(TasklistData* tasklist, GtkBuilder* builder, const char* wid1, const char* wid2, const char* wid3, const char* key)
1027{
1028 GtkWidget* w;
1029
1030 if (g_settings_is_writable(tasklist->settings, key))
1031 {
1032 return;
1033 }
1034
1035 w = WID(wid1)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object(builder, wid1))), ((gtk_widget_get_type
()))))))
;
1036 g_assert(w != NULL)do { if (w != ((void*)0)) ; else g_assertion_message_expr (((
gchar*) 0), "window-list.c", 1036, ((const char*) (__func__))
, "w != NULL"); } while (0)
;
1037 gtk_widget_set_sensitive(w, FALSE(0));
1038
1039 if (wid2 != NULL((void*)0))
1040 {
1041 w = WID(wid2)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object(builder, wid2))), ((gtk_widget_get_type
()))))))
;
1042 g_assert(w != NULL)do { if (w != ((void*)0)) ; else g_assertion_message_expr (((
gchar*) 0), "window-list.c", 1042, ((const char*) (__func__))
, "w != NULL"); } while (0)
;
1043 gtk_widget_set_sensitive(w, FALSE(0));
1044 }
1045
1046 if (wid3 != NULL((void*)0))
1047 {
1048 w = WID(wid3)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object(builder, wid3))), ((gtk_widget_get_type
()))))))
;
1049 g_assert(w != NULL)do { if (w != ((void*)0)) ; else g_assertion_message_expr (((
gchar*) 0), "window-list.c", 1049, ((const char*) (__func__))
, "w != NULL"); } while (0)
;
1050 gtk_widget_set_sensitive(w, FALSE(0));
1051 }
1052}
1053
1054#ifdef HAVE_WAYLAND1
1055static void setup_dialog_wayland(TasklistData* tasklist)
1056{
1057 gtk_widget_show(tasklist->wayland_info_label);
1058
1059 gtk_widget_set_sensitive(tasklist->window_list_content_box, FALSE(0));
1060 gtk_widget_set_sensitive(tasklist->window_grouping_box, FALSE(0));
1061 gtk_widget_set_sensitive(tasklist->minimized_windows_box, FALSE(0));
1062
1063#ifdef HAVE_WINDOW_PREVIEWS1
1064 gtk_widget_set_sensitive(tasklist->window_thumbnail_box, FALSE(0));
1065#endif /* HAVE_WINDOW_PREVIEWS */
1066}
1067#endif /* HAVE_WAYLAND */
1068
1069static void setup_dialog(GtkBuilder* builder, TasklistData* tasklist)
1070{
1071 GtkWidget* button;
1072
1073 tasklist->wayland_info_label = WID("wayland_info_label")((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object(builder, "wayland_info_label"))),
((gtk_widget_get_type ()))))))
;
1074 tasklist->show_current_radio = WID("show_current_radio")((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object(builder, "show_current_radio"))),
((gtk_widget_get_type ()))))))
;
1075 tasklist->show_all_radio = WID("show_all_radio")((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object(builder, "show_all_radio"))), ((gtk_widget_get_type
()))))))
;
1076
1077 setup_sensitivity(tasklist, builder, "show_current_radio", "show_all_radio", NULL((void*)0), "display-all-workspaces" /* key */);
1078
1079 tasklist->never_group_radio = WID("never_group_radio")((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object(builder, "never_group_radio"))), (
(gtk_widget_get_type ()))))))
;
1080 tasklist->auto_group_radio = WID("auto_group_radio")((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object(builder, "auto_group_radio"))), (
(gtk_widget_get_type ()))))))
;
1081 tasklist->always_group_radio = WID("always_group_radio")((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object(builder, "always_group_radio"))),
((gtk_widget_get_type ()))))))
;
1082
1083 setup_sensitivity(tasklist, builder, "never_group_radio", "auto_group_radio", "always_group_radio", "group-windows" /* key */);
1084
1085#ifdef HAVE_WINDOW_PREVIEWS1
1086 tasklist->window_thumbnail_box = WID("window_thumbnail_box")((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object(builder, "window_thumbnail_box"))
), ((gtk_widget_get_type ()))))))
;
1087 tasklist->show_thumbnails_check = WID("show_thumbnails_check")((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object(builder, "show_thumbnails_check")
)), ((gtk_widget_get_type ()))))))
;
1088 tasklist->thumbnail_size_label = WID("thumbnail_size_label")((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object(builder, "thumbnail_size_label"))
), ((gtk_widget_get_type ()))))))
;
1089 tasklist->thumbnail_size_spin = WID("thumbnail_size_spin")((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object(builder, "thumbnail_size_spin")))
, ((gtk_widget_get_type ()))))))
;
1090
1091 g_settings_bind(tasklist->preview_settings, "show-window-thumbnails", tasklist->show_thumbnails_check, "active", G_SETTINGS_BIND_DEFAULT);
1092 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(tasklist->show_thumbnails_check)((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tasklist->show_thumbnails_check)), ((gtk_toggle_button_get_type
()))))))
)) {
1093 gtk_widget_set_sensitive (tasklist->thumbnail_size_label, TRUE(!(0)));
1094 gtk_widget_set_sensitive (tasklist->thumbnail_size_spin, TRUE(!(0)));
1095 } else {
1096 gtk_widget_set_sensitive (tasklist->thumbnail_size_label, FALSE(0));
1097 gtk_widget_set_sensitive (tasklist->thumbnail_size_spin, FALSE(0));
1098 }
1099 g_object_bind_property(tasklist->show_thumbnails_check, "active", tasklist->thumbnail_size_label, "sensitive", G_BINDING_DEFAULT);
1100 g_object_bind_property(tasklist->show_thumbnails_check, "active", tasklist->thumbnail_size_spin, "sensitive", G_BINDING_DEFAULT);
1101
1102#else
1103 gtk_widget_hide(WID("window_thumbnail_box")((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object(builder, "window_thumbnail_box"))
), ((gtk_widget_get_type ()))))))
);
1104#endif
1105
1106 tasklist->move_minimized_radio = WID("move_minimized_radio")((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object(builder, "move_minimized_radio"))
), ((gtk_widget_get_type ()))))))
;
1107 tasklist->change_workspace_radio = WID("change_workspace_radio")((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object(builder, "change_workspace_radio"
))), ((gtk_widget_get_type ()))))))
;
1108 tasklist->mouse_scroll_check = WID("mouse_scroll_check")((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object(builder, "mouse_scroll_check"))),
((gtk_widget_get_type ()))))))
;
1109 tasklist->middle_click_close_check = WID("middle_click_close_check")((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object(builder, "middle_click_close_check"
))), ((gtk_widget_get_type ()))))))
;
1110 tasklist->minimized_windows_box = WID("minimized_windows_box")((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object(builder, "minimized_windows_box")
)), ((gtk_widget_get_type ()))))))
;
1111 tasklist->window_grouping_box = WID("window_grouping_box")((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object(builder, "window_grouping_box")))
, ((gtk_widget_get_type ()))))))
;
1112 tasklist->window_list_content_box = WID("window_list_content_box")((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object(builder, "window_list_content_box"
))), ((gtk_widget_get_type ()))))))
;
1113
1114 setup_sensitivity(tasklist, builder, "move_minimized_radio", "change_workspace_radio", NULL((void*)0), "move-unminimized-windows" /* key */);
1115
1116 /* Window grouping: */
1117 button = get_grouping_button(tasklist, tasklist->grouping);
1118 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button)((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), ((gtk_toggle_button_get_type ()))))))
, TRUE(!(0)));
1119 g_object_set_data(G_OBJECT(tasklist->never_group_radio)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tasklist->never_group_radio)), (((GType) ((20) <<
(2))))))))
, "group_value", "never");
1120 g_object_set_data(G_OBJECT(tasklist->auto_group_radio)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tasklist->auto_group_radio)), (((GType) ((20) <<
(2))))))))
, "group_value", "auto");
1121 g_object_set_data(G_OBJECT(tasklist->always_group_radio)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tasklist->always_group_radio)), (((GType) ((20) <<
(2))))))))
, "group_value", "always");
1122
1123 g_signal_connect (tasklist->never_group_radio, "toggled",g_signal_connect_data ((tasklist->never_group_radio), ("toggled"
), ((GCallback) group_windows_toggled), (tasklist), ((void*)0
), (GConnectFlags) 0)
1124 (GCallback) group_windows_toggled,g_signal_connect_data ((tasklist->never_group_radio), ("toggled"
), ((GCallback) group_windows_toggled), (tasklist), ((void*)0
), (GConnectFlags) 0)
1125 tasklist)g_signal_connect_data ((tasklist->never_group_radio), ("toggled"
), ((GCallback) group_windows_toggled), (tasklist), ((void*)0
), (GConnectFlags) 0)
;
1126 g_signal_connect (tasklist->auto_group_radio, "toggled",g_signal_connect_data ((tasklist->auto_group_radio), ("toggled"
), ((GCallback) group_windows_toggled), (tasklist), ((void*)0
), (GConnectFlags) 0)
1127 (GCallback) group_windows_toggled,g_signal_connect_data ((tasklist->auto_group_radio), ("toggled"
), ((GCallback) group_windows_toggled), (tasklist), ((void*)0
), (GConnectFlags) 0)
1128 tasklist)g_signal_connect_data ((tasklist->auto_group_radio), ("toggled"
), ((GCallback) group_windows_toggled), (tasklist), ((void*)0
), (GConnectFlags) 0)
;
1129 g_signal_connect (tasklist->always_group_radio, "toggled",g_signal_connect_data ((tasklist->always_group_radio), ("toggled"
), ((GCallback) group_windows_toggled), (tasklist), ((void*)0
), (GConnectFlags) 0)
1130 (GCallback) group_windows_toggled,g_signal_connect_data ((tasklist->always_group_radio), ("toggled"
), ((GCallback) group_windows_toggled), (tasklist), ((void*)0
), (GConnectFlags) 0)
1131 tasklist)g_signal_connect_data ((tasklist->always_group_radio), ("toggled"
), ((GCallback) group_windows_toggled), (tasklist), ((void*)0
), (GConnectFlags) 0)
;
1132
1133 /* Mouse Scroll: */
1134 g_settings_bind (tasklist->settings,
1135 "scroll-enabled",
1136 tasklist->mouse_scroll_check,
1137 "active",
1138 G_SETTINGS_BIND_DEFAULT);
1139
1140 /* Middle mouse click to close window: */
1141 g_settings_bind (tasklist->settings,
1142 "middle-click-close",
1143 tasklist->middle_click_close_check,
1144 "active",
1145 G_SETTINGS_BIND_DEFAULT);
1146
1147#ifdef HAVE_WINDOW_PREVIEWS1
1148 /* change thumbnail size: */
1149 tasklist_update_thumbnail_size_spin(tasklist);
1150 g_signal_connect (tasklist->thumbnail_size_spin, "value-changed",g_signal_connect_data ((tasklist->thumbnail_size_spin), ("value-changed"
), ((GCallback) thumbnail_size_spin_changed), (tasklist), ((void
*)0), (GConnectFlags) 0)
1151 (GCallback) thumbnail_size_spin_changed,g_signal_connect_data ((tasklist->thumbnail_size_spin), ("value-changed"
), ((GCallback) thumbnail_size_spin_changed), (tasklist), ((void
*)0), (GConnectFlags) 0)
1152 tasklist)g_signal_connect_data ((tasklist->thumbnail_size_spin), ("value-changed"
), ((GCallback) thumbnail_size_spin_changed), (tasklist), ((void
*)0), (GConnectFlags) 0)
;
1153#endif
1154
1155 /* move window when unminimizing: */
1156 tasklist_update_unminimization_radio(tasklist);
1157 g_signal_connect (tasklist->move_minimized_radio, "toggled",g_signal_connect_data ((tasklist->move_minimized_radio), (
"toggled"), ((GCallback) move_minimized_toggled), (tasklist),
((void*)0), (GConnectFlags) 0)
1158 (GCallback) move_minimized_toggled,g_signal_connect_data ((tasklist->move_minimized_radio), (
"toggled"), ((GCallback) move_minimized_toggled), (tasklist),
((void*)0), (GConnectFlags) 0)
1159 tasklist)g_signal_connect_data ((tasklist->move_minimized_radio), (
"toggled"), ((GCallback) move_minimized_toggled), (tasklist),
((void*)0), (GConnectFlags) 0)
;
1160
1161 /* Tasklist content: */
1162 tasklist_properties_update_content_radio (tasklist);
1163 g_signal_connect (tasklist->show_all_radio, "toggled",g_signal_connect_data ((tasklist->show_all_radio), ("toggled"
), ((GCallback) display_all_workspaces_toggled), (tasklist), (
(void*)0), (GConnectFlags) 0)
1164 (GCallback) display_all_workspaces_toggled,g_signal_connect_data ((tasklist->show_all_radio), ("toggled"
), ((GCallback) display_all_workspaces_toggled), (tasklist), (
(void*)0), (GConnectFlags) 0)
1165 tasklist)g_signal_connect_data ((tasklist->show_all_radio), ("toggled"
), ((GCallback) display_all_workspaces_toggled), (tasklist), (
(void*)0), (GConnectFlags) 0)
;
1166
1167 g_signal_connect_swapped (WID ("done_button"), "clicked",g_signal_connect_data ((((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((gtk_builder_get_object(builder, "done_button"
))), ((gtk_widget_get_type ()))))))), ("clicked"), ((GCallback
) gtk_widget_hide), (tasklist->properties_dialog), ((void*
)0), G_CONNECT_SWAPPED)
1168 (GCallback) gtk_widget_hide,g_signal_connect_data ((((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((gtk_builder_get_object(builder, "done_button"
))), ((gtk_widget_get_type ()))))))), ("clicked"), ((GCallback
) gtk_widget_hide), (tasklist->properties_dialog), ((void*
)0), G_CONNECT_SWAPPED)
1169 tasklist->properties_dialog)g_signal_connect_data ((((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((gtk_builder_get_object(builder, "done_button"
))), ((gtk_widget_get_type ()))))))), ("clicked"), ((GCallback
) gtk_widget_hide), (tasklist->properties_dialog), ((void*
)0), G_CONNECT_SWAPPED)
;
1170 g_signal_connect (tasklist->properties_dialog, "response",g_signal_connect_data ((tasklist->properties_dialog), ("response"
), (((GCallback) (response_cb))), (tasklist), ((void*)0), (GConnectFlags
) 0)
1171 G_CALLBACK (response_cb),g_signal_connect_data ((tasklist->properties_dialog), ("response"
), (((GCallback) (response_cb))), (tasklist), ((void*)0), (GConnectFlags
) 0)
1172 tasklist)g_signal_connect_data ((tasklist->properties_dialog), ("response"
), (((GCallback) (response_cb))), (tasklist), ((void*)0), (GConnectFlags
) 0)
;
1173
1174#ifdef HAVE_WAYLAND1
1175 if (GDK_IS_WAYLAND_DISPLAY(gdk_display_get_default())(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gdk_display_get_default())); GType __t = ((gdk_wayland_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
) {
1176 setup_dialog_wayland(tasklist);
1177 }
1178#endif /* HAVE_WAYLAND */
1179}
1180
1181static void display_properties_dialog(GtkAction* action, TasklistData* tasklist)
1182{
1183 if (tasklist->properties_dialog == NULL((void*)0))
1184 {
1185 GtkBuilder* builder;
1186
1187 builder = gtk_builder_new();
1188 gtk_builder_set_translation_domain(builder, GETTEXT_PACKAGE"mate-panel");
1189 gtk_builder_add_from_resource (builder, WNCKLET_RESOURCE_PATH"/org/mate/panel/applet/wncklet/" "window-list.ui", NULL((void*)0));
1190
1191 tasklist->properties_dialog = WID("tasklist_properties_dialog")((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object(builder, "tasklist_properties_dialog"
))), ((gtk_widget_get_type ()))))))
;
1192
1193 g_object_add_weak_pointer(G_OBJECT(tasklist->properties_dialog)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tasklist->properties_dialog)), (((GType) ((20) <<
(2))))))))
, (void**) &tasklist->properties_dialog);
1194
1195 setup_dialog(builder, tasklist);
1196
1197 g_object_unref(builder);
1198 }
1199
1200 gtk_window_set_icon_name(GTK_WINDOW(tasklist->properties_dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tasklist->properties_dialog)), ((gtk_window_get_type (
)))))))
, WINDOW_LIST_ICON"mate-panel-window-list");
1201
1202 gtk_window_set_resizable(GTK_WINDOW(tasklist->properties_dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tasklist->properties_dialog)), ((gtk_window_get_type (
)))))))
, FALSE(0));
1203 gtk_window_set_screen(GTK_WINDOW(tasklist->properties_dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tasklist->properties_dialog)), ((gtk_window_get_type (
)))))))
, gtk_widget_get_screen(tasklist->applet));
1204 gtk_window_present(GTK_WINDOW(tasklist->properties_dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tasklist->properties_dialog)), ((gtk_window_get_type (
)))))))
);
1205}
1206
1207static void destroy_tasklist(GtkWidget* widget, TasklistData* tasklist)
1208{
1209 g_signal_handlers_disconnect_by_data (G_OBJECT (tasklist->applet), tasklist)g_signal_handlers_disconnect_matched ((((((GObject*) (void *)
g_type_check_instance_cast ((GTypeInstance*) ((tasklist->
applet)), (((GType) ((20) << (2))))))))), G_SIGNAL_MATCH_DATA
, 0, 0, ((void*)0), ((void*)0), (tasklist))
;
1210
1211#ifdef HAVE_WINDOW_PREVIEWS1
1212 g_signal_handlers_disconnect_by_data (G_OBJECT (tasklist->tasklist), tasklist)g_signal_handlers_disconnect_matched ((((((GObject*) (void *)
g_type_check_instance_cast ((GTypeInstance*) ((tasklist->
tasklist)), (((GType) ((20) << (2))))))))), G_SIGNAL_MATCH_DATA
, 0, 0, ((void*)0), ((void*)0), (tasklist))
;
1213 g_signal_handlers_disconnect_by_data (tasklist->preview_settings, tasklist)g_signal_handlers_disconnect_matched ((tasklist->preview_settings
), G_SIGNAL_MATCH_DATA, 0, 0, ((void*)0), ((void*)0), (tasklist
))
;
1214 g_object_unref(tasklist->preview_settings);
1215#endif
1216
1217 g_signal_handlers_disconnect_by_data (tasklist->settings, tasklist)g_signal_handlers_disconnect_matched ((tasklist->settings)
, G_SIGNAL_MATCH_DATA, 0, 0, ((void*)0), ((void*)0), (tasklist
))
;
1218
1219 g_object_unref(tasklist->settings);
1220
1221 if (tasklist->properties_dialog)
1222 gtk_widget_destroy(tasklist->properties_dialog);
1223
1224#ifdef HAVE_WINDOW_PREVIEWS1
1225 if (tasklist->preview)
1226 gtk_widget_destroy(tasklist->preview);
1227#endif
1228
1229 g_free(tasklist);
1230}
diff --git a/2024-06-18-172109-13286-1@e182420b844f_master/report-713bcf.html b/2024-06-18-172109-13286-1@e182420b844f_master/report-713bcf.html new file mode 100644 index 00000000..40cd0c11 --- /dev/null +++ b/2024-06-18-172109-13286-1@e182420b844f_master/report-713bcf.html @@ -0,0 +1,912 @@ + + + +panel-glib.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:mate-panel/libpanel-util/panel-glib.c
Warning:line 147, column 10
The right operand of '==' is a garbage value
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name panel-glib.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/mate-panel/libpanel-util -fcoverage-compilation-dir=/rootdir/mate-panel/libpanel-util -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I ../.. -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/startup-notification-1.0 -I /usr/include/mate-menus -I /usr/include/gio-unix-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/dconf -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/dconf -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I . -I . -I ../../mate-panel/libpanel-util -D DATADIR="/usr/local/share" -D PIC -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-18-172109-13286-1 -x c panel-glib.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * panel-glib.c: various small extensions to glib
3 *
4 * Copyright (C) 2008 Novell, Inc.
5 * Copyright (C) 2012-2021 MATE Developers
6 *
7 * Originally based on code from panel-util.c (there was no relevant copyright
8 * header at the time), but the code was:
9 * Copyright (C) Novell, Inc. (for the panel_g_utf8_strstrcase() code)
10 * Copyright (C) Dennis Cranston (for the panel_g_lookup_in_data_dirs() code)
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License as
14 * published by the Free Software Foundation; either version 2 of the
15 * License, or (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
25 * 02110-1301, USA.
26 *
27 * Authors:
28 * Vincent Untz <vuntz@gnome.org>
29 */
30
31#include <string.h>
32
33#include <glib.h>
34
35#include "panel-glib.h"
36
37typedef char * (*LookupInDir) (const char *basename, const char *dir);
38
39static char *
40_lookup_in_dir (const char *basename,
41 const char *dir)
42{
43 char *path;
44
45 path = g_build_filename (dir, basename, NULL((void*)0));
46 if (!g_file_test (path, G_FILE_TEST_EXISTS)) {
47 g_free (path);
48 return NULL((void*)0);
49 }
50
51 return path;
52}
53
54static char *
55_lookup_in_applications_subdir (const char *basename,
56 const char *dir)
57{
58 char *path;
59
60 path = g_build_filename (dir, "applications", basename, NULL((void*)0));
61 if (!g_file_test (path, G_FILE_TEST_EXISTS)) {
62 g_free (path);
63 return NULL((void*)0);
64 }
65
66 return path;
67}
68
69static char *
70_panel_g_lookup_in_data_dirs_internal (const char *basename,
71 LookupInDir lookup)
72{
73 const char * const *system_data_dirs;
74 const char *user_data_dir;
75 char *retval;
76 int i;
77
78 user_data_dir = g_get_user_data_dir ();
79 system_data_dirs = g_get_system_data_dirs ();
80
81 if ((retval = lookup (basename, user_data_dir)))
82 return retval;
83
84 for (i = 0; system_data_dirs[i]; i++)
85 if ((retval = lookup (basename, system_data_dirs[i])))
86 return retval;
87
88 return NULL((void*)0);
89}
90
91char *
92panel_g_lookup_in_data_dirs (const char *basename)
93{
94 return _panel_g_lookup_in_data_dirs_internal (basename,
95 _lookup_in_dir);
96}
97
98char *
99panel_g_lookup_in_applications_dirs (const char *basename)
100{
101 return _panel_g_lookup_in_data_dirs_internal (basename,
102 _lookup_in_applications_subdir);
103}
104
105/* Copied from evolution-data-server/libedataserver/e-util.c:
106 * e_util_unicode_get_utf8() */
107static char *
108_unicode_get_utf8 (const char *text, gunichar *out)
109{
110 *out = g_utf8_get_char (text);
17
Value assigned to 'unival', which participates in a condition later
111 return (*out == (gunichar)-1) ? NULL((void*)0) : g_utf8_next_char (text)(char *)((text) + g_utf8_skip[*(const guchar *)(text)]);
10
Assuming the condition is false
11
'?' condition is false
12
Returning pointer, which participates in a condition later
18
Assuming the condition is false
19
'?' condition is false
20
Returning pointer, which participates in a condition later
112}
113
114/* Copied from evolution-data-server/libedataserver/e-util.c:
115 * e_util_utf8_strstrcase() */
116const char *
117panel_g_utf8_strstrcase (const char *haystack, const char *needle)
118{
119 gunichar *nuni;
120 gunichar unival;
121 gint nlen;
122 const char *o, *p;
123
124 if (haystack == NULL((void*)0)) return NULL((void*)0);
1
Assuming 'haystack' is not equal to NULL
2
Taking false branch
125 if (needle == NULL((void*)0)) return NULL((void*)0);
3
Assuming 'needle' is not equal to NULL
4
Taking false branch
126 if (strlen (needle) == 0) return haystack;
5
Assuming the condition is false
6
Taking false branch
127 if (strlen (haystack) == 0) return NULL((void*)0);
7
Assuming the condition is false
8
Taking false branch
128
129 nuni = g_alloca (sizeof (gunichar) * strlen (needle))__builtin_alloca (sizeof (gunichar) * strlen (needle));
130
131 nlen = 0;
132 for (p = _unicode_get_utf8 (needle, &unival);
9
Calling '_unicode_get_utf8'
13
Returning from '_unicode_get_utf8'
14
Loop condition is false. Execution continues on line 138
133 p
13.1
'p' is non-null
&& unival;
134 p = _unicode_get_utf8 (p, &unival)) {
135 nuni[nlen++] = g_unichar_tolower (unival);
136 }
137 /* NULL means there was illegal utf-8 sequence */
138 if (!p
14.1
'p' is non-null
) return NULL((void*)0);
15
Taking false branch
139
140 o = haystack;
141 for (p = _unicode_get_utf8 (o, &unival);
16
Calling '_unicode_get_utf8'
21
Returning from '_unicode_get_utf8'
22
Loop condition is true. Entering loop body
142 p
21.1
'p' is non-null
&& unival;
143 p = _unicode_get_utf8 (p, &unival)) {
144 gint sc;
145 sc = g_unichar_tolower (unival);
146 /* We have valid stripped char */
147 if (sc == nuni[0]) {
23
The right operand of '==' is a garbage value
148 const char *q = p;
149 gint npos = 1;
150 while (npos < nlen) {
151 q = _unicode_get_utf8 (q, &unival);
152 if (!q || !unival) return NULL((void*)0);
153 sc = g_unichar_tolower (unival);
154 if (sc != nuni[npos]) break;
155 npos++;
156 }
157 if (npos == nlen) {
158 return o;
159 }
160 }
161 o = p;
162 }
163
164 return NULL((void*)0);
165}
diff --git a/2024-06-18-172109-13286-1@e182420b844f_master/report-7c33d7.html b/2024-06-18-172109-13286-1@e182420b844f_master/report-7c33d7.html new file mode 100644 index 00000000..e093d330 --- /dev/null +++ b/2024-06-18-172109-13286-1@e182420b844f_master/report-7c33d7.html @@ -0,0 +1,2409 @@ + + + +panel-profile.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:mate-panel/panel-profile.c
Warning:line 871, column 56
Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name panel-profile.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/mate-panel -fcoverage-compilation-dir=/rootdir/mate-panel -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I .. -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/startup-notification-1.0 -I /usr/include/mate-menus -I /usr/include/gio-unix-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/dconf -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/dconf -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I . -I . -I ../mate-panel -I ../mate-panel/mate-submodules -I ../mate-panel/libpanel-util -D MATELOCALEDIR="/usr/local/share/locale" -D PANELDATADIR="/usr/local/share/mate-panel" -I /usr/include/gtk-layer-shell -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/gtk-3.0 -I /usr/include/cloudproviders -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/atk-1.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/gio-unix-2.0 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -D PANEL_MODULES_DIR="/usr/local/lib/mate-panel/modules" -D MATEMENU_I_KNOW_THIS_IS_UNSTABLE -I /usr/include/gtk-layer-shell -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/gtk-3.0 -I /usr/include/cloudproviders -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/atk-1.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/gio-unix-2.0 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-18-172109-13286-1 -x c panel-profile.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * panel-profile.c:
3 *
4 * Copyright (C) 2003 Sun Microsystems, Inc.
5 * Copyright (C) 2012-2021 MATE Developers
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of the
10 * License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301, USA.
21 *
22 * Authors:
23 * Mark McLoughlin <mark@skynet.ie>
24 */
25
26#include <config.h>
27
28#include "panel-profile.h"
29#include "panel-layout.h"
30
31#include <string.h>
32#include <glib/gi18n.h>
33#include <gio/gio.h>
34
35#ifdef HAVE_X111
36#include <gdk/gdkx.h>
37#endif
38
39#include <libpanel-util/panel-list.h>
40#include <libmate-desktop/mate-dconf.h>
41#include <libmate-desktop/mate-gsettings.h>
42
43#include "applet.h"
44#include "panel.h"
45#include "panel-widget.h"
46#include "panel-util.h"
47#include "panel-multimonitor.h"
48#include "panel-toplevel.h"
49#include "panel-lockdown.h"
50#include "panel-schemas.h"
51
52typedef struct {
53 GdkScreen *screen;
54 int monitor;
55 int size;
56 int x;
57 int x_right;
58 gboolean x_centered;
59 int y;
60 int y_bottom;
61 gboolean y_centered;
62 PanelOrientation orientation;
63
64 guint screen_changed : 1;
65 guint monitor_changed : 1;
66 guint size_changed : 1;
67 guint x_changed : 1;
68 guint x_right_changed : 1;
69 guint x_centered_changed : 1;
70 guint y_changed : 1;
71 guint y_bottom_changed : 1;
72 guint y_centered_changed : 1;
73 guint orientation_changed : 1;
74} ToplevelLocationChange;
75
76typedef const char *(*PanelProfileGetIdFunc) (gpointer object);
77typedef gboolean (*PanelProfileOnLoadQueue) (const char *id);
78typedef void (*PanelProfileLoadFunc) (const char *id);
79typedef void (*PanelProfileDestroyFunc) (const char *id);
80
81static GSettings *profile_settings = NULL((void*)0);
82
83static GQuark toplevel_id_quark = 0;
84#if 0
85static GQuark queued_changes_quark = 0;
86#endif
87static GQuark commit_timeout_quark = 0;
88
89static void panel_profile_object_id_list_update (gchar **objects);
90static void panel_profile_ensure_toplevel_per_screen (void);
91
92static void
93panel_profile_set_toplevel_id (PanelToplevel *toplevel,
94 const char *id)
95{
96 if (!toplevel_id_quark)
97 toplevel_id_quark = g_quark_from_static_string ("panel-toplevel-id");
98
99 g_object_set_qdata_full (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
,
100 toplevel_id_quark,
101 g_strdup (id)g_strdup_inline (id),
102 g_free);
103}
104
105const char *
106panel_profile_get_toplevel_id (PanelToplevel *toplevel)
107{
108 if (!toplevel_id_quark)
109 return NULL((void*)0);
110
111 return g_object_get_qdata (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, toplevel_id_quark);
112}
113
114PanelToplevel *
115panel_profile_get_toplevel_by_id (const char *toplevel_id)
116{
117 GSList *toplevels, *l;
118
119 if (!toplevel_id || !toplevel_id [0])
120 return NULL((void*)0);
121
122 toplevels = panel_toplevel_list_toplevels ();
123 for (l = toplevels; l; l = l->next)
124 if (!strcmp (panel_profile_get_toplevel_id (l->data), toplevel_id))
125 return l->data;
126
127 return NULL((void*)0);
128}
129
130char *
131panel_profile_find_new_id (PanelGSettingsKeyType type)
132{
133 gchar **existing_ids;
134 char *retval = NULL((void*)0);
135 char *prefix = NULL((void*)0);
136 char *dir = NULL((void*)0);
137 int i;
138 int j;
139
140 switch (type) {
141 case PANEL_GSETTINGS_TOPLEVELS:
142 prefix = PANEL_TOPLEVEL_DEFAULT_PREFIX"toplevel";
143 dir = PANEL_TOPLEVEL_PATH"/org/mate/panel/toplevels/";
144 break;
145 case PANEL_GSETTINGS_OBJECTS:
146 prefix = PANEL_OBJECT_DEFAULT_PREFIX"object";
147 dir = PANEL_OBJECT_PATH"/org/mate/panel/objects/";
148 break;
149 default:
150 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-profile.c"
, 150, ((const char*) (__func__)), ((void*)0)); } while (0)
;
151 break;
152 }
153
154 existing_ids = mate_dconf_list_subdirs (dir, TRUE(!(0)));
155
156 for (i = 0; !retval; i++) {
157 retval = g_strdup_printf ("%s-%d", prefix, i);
158
159 for (j = 0; existing_ids[j] != NULL((void*)0); j++) {
160 if (g_strcmp0 (existing_ids[j], retval) == 0) {
161 g_clear_pointer (&retval, g_free)do { _Static_assert (sizeof *(&retval) == sizeof (gpointer
), "Expression evaluates to false"); __typeof__ ((&retval
)) _pp = (&retval); __typeof__ (*(&retval)) _ptr = *_pp
; *_pp = ((void*)0); if (_ptr) (g_free) (_ptr); } while (0)
;
162 break;
163 }
164 }
165 }
166 if (existing_ids)
167 g_strfreev (existing_ids);
168
169 g_assert (retval != NULL)do { if (retval != ((void*)0)) ; else g_assertion_message_expr
(((gchar*) 0), "panel-profile.c", 169, ((const char*) (__func__
)), "retval != NULL"); } while (0)
;
170
171 return retval;
172}
173
174static void
175panel_profile_remove_commit_timeout (guint timeout)
176{
177 g_source_remove (timeout);
178}
179
180static void
181panel_profile_set_commit_timeout (PanelToplevel *toplevel,
182 guint timeout)
183{
184 GDestroyNotify destroy_notify;
185
186 if (!commit_timeout_quark)
187 commit_timeout_quark = g_quark_from_static_string ("panel-queued-timeout");
188
189 if (timeout)
190 destroy_notify = (GDestroyNotify) panel_profile_remove_commit_timeout;
191 else
192 destroy_notify = NULL((void*)0);
193
194 g_object_set_qdata_full (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
,
195 commit_timeout_quark,
196 GUINT_TO_POINTER (timeout)((gpointer) (gulong) (timeout)),
197 destroy_notify);
198}
199
200static guint
201panel_profile_get_commit_timeout (GObject *object)
202{
203 if (!commit_timeout_quark)
204 return 0;
205
206 return GPOINTER_TO_UINT (g_object_get_qdata (object, commit_timeout_quark))((guint) (gulong) (g_object_get_qdata (object, commit_timeout_quark
)))
;
207}
208
209gboolean
210panel_profile_key_is_writable (PanelToplevel *toplevel, gchar *key) {
211 return g_settings_is_writable (toplevel->settings, key);
212}
213
214gboolean
215panel_profile_background_key_is_writable (PanelToplevel *toplevel, gchar *key) {
216 return g_settings_is_writable (toplevel->background_settings, key);
217}
218
219void
220panel_profile_set_background_type (PanelToplevel *toplevel,
221 PanelBackgroundType background_type)
222{
223 g_settings_set_enum (toplevel->background_settings,
224 "type",
225 background_type);
226}
227
228PanelBackgroundType
229panel_profile_get_background_type (PanelToplevel *toplevel)
230{
231 PanelBackgroundType background_type;
232 background_type = g_settings_get_enum (toplevel->background_settings,
233 "type");
234 return background_type;
235}
236
237void
238panel_profile_set_background_color (PanelToplevel *toplevel,
239 GdkRGBA *color)
240{
241 char *color_str;
242
243 color_str = gdk_rgba_to_string (color);
244
245 g_settings_set_string (toplevel->background_settings, "color", color_str);
246
247 g_free (color_str);
248}
249
250void
251panel_profile_get_background_color (PanelToplevel *toplevel,
252 GdkRGBA *color)
253{
254 char *color_str;
255
256 color_str = g_settings_get_string (toplevel->background_settings, "color");
257 if (!color_str || !gdk_rgba_parse (color, color_str)) {
258 color->red = 0.;
259 color->green = 0.;
260 color->blue = 0.;
261 color->alpha = 1.;
262 }
263
264 g_free (color_str);
265}
266
267void
268panel_profile_set_background_opacity (PanelToplevel *toplevel,
269 gdouble percentage)
270{
271 GdkRGBA color;
272 panel_profile_get_background_color (toplevel, &color);
273 color.alpha = percentage / 100.0;
274 panel_profile_set_background_color (toplevel, &color);
275}
276
277gdouble
278panel_profile_get_background_opacity (PanelToplevel *toplevel)
279{
280 GdkRGBA color;
281 panel_profile_get_background_color (toplevel, &color);
282 return color.alpha * 100.0;
283}
284
285void
286panel_profile_set_background_image (PanelToplevel *toplevel,
287 const char *image)
288{
289 if (image && image [0])
290 g_settings_set_string (toplevel->background_settings, "image", image);
291 else
292 g_settings_reset (toplevel->background_settings, "image");
293}
294
295char *
296panel_profile_get_background_image (PanelToplevel *toplevel)
297{
298 return g_settings_get_string (toplevel->background_settings, "image");
299}
300
301void
302panel_profile_set_toplevel_name (PanelToplevel *toplevel,
303 const char *name)
304{
305 if (name && name [0])
306 g_settings_set_string (toplevel->settings, "name", name);
307 else
308 g_settings_reset (toplevel->settings, "name");
309}
310
311char *
312panel_profile_get_toplevel_name (PanelToplevel *toplevel)
313{
314 return g_settings_get_string (toplevel->settings, "name");
315}
316
317void
318panel_profile_set_toplevel_orientation (PanelToplevel *toplevel,
319 PanelOrientation orientation)
320{
321 g_settings_set_enum (toplevel->settings, "orientation", orientation);
322}
323
324PanelOrientation
325panel_profile_get_toplevel_orientation (PanelToplevel *toplevel)
326{
327 PanelOrientation orientation;
328 orientation = g_settings_get_enum (toplevel->settings, "orientation");
329 return orientation;
330}
331
332#define TOPLEVEL_GET_SET_FUNCS(k, p, t, s, a)void panel_profile_set_p_s (PanelToplevel *toplevel, a s) { g_settings_set_t
(toplevel->settings, k, s); } a panel_profile_get_p_s (PanelToplevel
*toplevel) { a retval; retval = g_settings_get_t (toplevel->
settings, k); return retval; }
\
333 void \
334 panel_profile_set_##p##_##s (PanelToplevel *toplevel, a s) \
335 { \
336 g_settings_set_##t (toplevel->settings, k, s); \
337 } \
338 a \
339 panel_profile_get_##p##_##s (PanelToplevel *toplevel) \
340 { \
341 a retval; \
342 retval = g_settings_get_##t (toplevel->settings, k); \
343 return retval; \
344 }
345
346TOPLEVEL_GET_SET_FUNCS ("size", toplevel, int, size, int)void panel_profile_set_toplevel_size (PanelToplevel *toplevel
, int size) { g_settings_set_int (toplevel->settings, "size"
, size); } int panel_profile_get_toplevel_size (PanelToplevel
*toplevel) { int retval; retval = g_settings_get_int (toplevel
->settings, "size"); return retval; }
347TOPLEVEL_GET_SET_FUNCS ("expand", toplevel, boolean, expand, gboolean)void panel_profile_set_toplevel_expand (PanelToplevel *toplevel
, gboolean expand) { g_settings_set_boolean (toplevel->settings
, "expand", expand); } gboolean panel_profile_get_toplevel_expand
(PanelToplevel *toplevel) { gboolean retval; retval = g_settings_get_boolean
(toplevel->settings, "expand"); return retval; }
348TOPLEVEL_GET_SET_FUNCS ("auto-hide", toplevel, boolean, auto_hide, gboolean)void panel_profile_set_toplevel_auto_hide (PanelToplevel *toplevel
, gboolean auto_hide) { g_settings_set_boolean (toplevel->
settings, "auto-hide", auto_hide); } gboolean panel_profile_get_toplevel_auto_hide
(PanelToplevel *toplevel) { gboolean retval; retval = g_settings_get_boolean
(toplevel->settings, "auto-hide"); return retval; }
349TOPLEVEL_GET_SET_FUNCS ("enable-buttons", toplevel, boolean, enable_buttons, gboolean)void panel_profile_set_toplevel_enable_buttons (PanelToplevel
*toplevel, gboolean enable_buttons) { g_settings_set_boolean
(toplevel->settings, "enable-buttons", enable_buttons); }
gboolean panel_profile_get_toplevel_enable_buttons (PanelToplevel
*toplevel) { gboolean retval; retval = g_settings_get_boolean
(toplevel->settings, "enable-buttons"); return retval; }
350TOPLEVEL_GET_SET_FUNCS ("enable-arrows", toplevel, boolean, enable_arrows, gboolean)void panel_profile_set_toplevel_enable_arrows (PanelToplevel *
toplevel, gboolean enable_arrows) { g_settings_set_boolean (toplevel
->settings, "enable-arrows", enable_arrows); } gboolean panel_profile_get_toplevel_enable_arrows
(PanelToplevel *toplevel) { gboolean retval; retval = g_settings_get_boolean
(toplevel->settings, "enable-arrows"); return retval; }
351
352#define TOPLEVEL_GET_SET_BG_FUNCS(k, p, t, s, a)void panel_profile_set_p_s (PanelToplevel *toplevel, a s) { g_settings_set_t
(toplevel->background_settings, k, s); } a panel_profile_get_p_s
(PanelToplevel *toplevel) { a retval; retval = g_settings_get_t
(toplevel->background_settings, k); return retval; }
\
353 void \
354 panel_profile_set_##p##_##s (PanelToplevel *toplevel, a s) \
355 { \
356 g_settings_set_##t (toplevel->background_settings, k, s); \
357 } \
358 a \
359 panel_profile_get_##p##_##s (PanelToplevel *toplevel) \
360 { \
361 a retval; \
362 retval = g_settings_get_##t (toplevel->background_settings, k); \
363 return retval; \
364 }
365
366TOPLEVEL_GET_SET_BG_FUNCS ("fit", background, boolean, fit, gboolean)void panel_profile_set_background_fit (PanelToplevel *toplevel
, gboolean fit) { g_settings_set_boolean (toplevel->background_settings
, "fit", fit); } gboolean panel_profile_get_background_fit (PanelToplevel
*toplevel) { gboolean retval; retval = g_settings_get_boolean
(toplevel->background_settings, "fit"); return retval; }
367TOPLEVEL_GET_SET_BG_FUNCS ("stretch", background, boolean, stretch, gboolean)void panel_profile_set_background_stretch (PanelToplevel *toplevel
, gboolean stretch) { g_settings_set_boolean (toplevel->background_settings
, "stretch", stretch); } gboolean panel_profile_get_background_stretch
(PanelToplevel *toplevel) { gboolean retval; retval = g_settings_get_boolean
(toplevel->background_settings, "stretch"); return retval
; }
368TOPLEVEL_GET_SET_BG_FUNCS ("rotate", background, boolean, rotate, gboolean)void panel_profile_set_background_rotate (PanelToplevel *toplevel
, gboolean rotate) { g_settings_set_boolean (toplevel->background_settings
, "rotate", rotate); } gboolean panel_profile_get_background_rotate
(PanelToplevel *toplevel) { gboolean retval; retval = g_settings_get_boolean
(toplevel->background_settings, "rotate"); return retval;
}
369
370GSettings*
371panel_profile_get_attached_object_settings (PanelToplevel *toplevel)
372{
373 GtkWidget *attach_widget;
374 const char *id;
375 char *path;
376 GSettings *settings;
377
378 attach_widget = panel_toplevel_get_attach_widget (toplevel);
379
380 id = mate_panel_applet_get_id_by_widget (attach_widget);
381
382 if (!id)
383 return NULL((void*)0);
384
385 path = g_strdup_printf (PANEL_OBJECT_PATH"/org/mate/panel/objects/" "%s/", id);
386 settings = g_settings_new_with_path (PANEL_OBJECT_SCHEMA"org.mate.panel.object", path);
387 g_free (path);
388
389 return settings;
390}
391
392void
393panel_profile_set_attached_custom_icon (PanelToplevel *toplevel,
394 const char *custom_icon)
395{
396 GSettings *settings;
397 settings = panel_profile_get_attached_object_settings (toplevel);
398
399 g_settings_set_boolean (settings, PANEL_OBJECT_USE_CUSTOM_ICON_KEY"use-custom-icon", custom_icon != NULL((void*)0));
400 g_settings_set_string (settings, PANEL_OBJECT_CUSTOM_ICON_KEY"custom-icon", sure_string (custom_icon)((const char *)((custom_icon)!=((void*)0)?(custom_icon):"")));
401
402 g_object_unref (settings);
403}
404
405char *
406panel_profile_get_attached_custom_icon (PanelToplevel *toplevel)
407{
408 gchar *custom_icon = NULL((void*)0);
409 if (panel_toplevel_get_is_attached (toplevel))
410 {
411 GSettings *settings;
412 settings = panel_profile_get_attached_object_settings (toplevel);
413
414 if (!g_settings_get_boolean (settings, PANEL_OBJECT_USE_CUSTOM_ICON_KEY"use-custom-icon"))
415 {
416 g_object_unref (settings);
417 return NULL((void*)0);
418 }
419
420 custom_icon = g_settings_get_string (settings, PANEL_OBJECT_CUSTOM_ICON_KEY"custom-icon");
421 g_object_unref (settings);
422 }
423 return custom_icon;
424}
425
426gboolean
427panel_profile_is_writable_attached_custom_icon (PanelToplevel *toplevel)
428{
429 gboolean is_writable = FALSE(0);
430 if (panel_toplevel_get_is_attached (toplevel))
431 {
432 GSettings *settings;
433 settings = panel_profile_get_attached_object_settings (toplevel);
434
435 is_writable = g_settings_is_writable (settings, PANEL_OBJECT_USE_CUSTOM_ICON_KEY"use-custom-icon") &&
436 g_settings_is_writable (settings, PANEL_OBJECT_CUSTOM_ICON_KEY"custom-icon");
437
438 g_object_unref (settings);
439 }
440 return is_writable;
441}
442
443void
444panel_profile_set_attached_tooltip (PanelToplevel *toplevel,
445 const char *tooltip)
446{
447 GSettings *settings;
448 settings = panel_profile_get_attached_object_settings (toplevel);
449 g_settings_set_string (settings, PANEL_OBJECT_TOOLTIP_KEY"tooltip", tooltip);
450 g_object_unref (settings);
451}
452
453char *
454panel_profile_get_attached_tooltip (PanelToplevel *toplevel)
455{
456 gchar *tooltip = NULL((void*)0);
457 if (panel_toplevel_get_is_attached (toplevel))
458 {
459 GSettings *settings;
460 settings = panel_profile_get_attached_object_settings (toplevel);
461 tooltip = g_settings_get_string (settings, PANEL_OBJECT_TOOLTIP_KEY"tooltip");
462 g_object_unref (settings);
463 }
464 return tooltip;
465}
466
467gboolean
468panel_profile_is_writable_attached_tooltip (PanelToplevel *toplevel)
469{
470 gboolean is_writable = FALSE(0);
471 if (panel_toplevel_get_is_attached (toplevel))
472 {
473 GSettings *settings;
474 settings = panel_profile_get_attached_object_settings (toplevel);
475 is_writable = g_settings_is_writable (settings, PANEL_OBJECT_TOOLTIP_KEY"tooltip");
476 g_object_unref (settings);
477 }
478 return is_writable;
479}
480
481static char *
482get_background_image (PanelToplevel *toplevel,
483 gboolean *fit,
484 gboolean *stretch,
485 gboolean *rotate)
486{
487 char *image;
488 image = g_settings_get_string (toplevel->background_settings, "image");
489 *fit = g_settings_get_boolean (toplevel->background_settings, "fit");
490 *stretch = g_settings_get_boolean (toplevel->background_settings, "stretch");
491 *rotate = g_settings_get_boolean (toplevel->background_settings, "rotate");
492 return image;
493}
494
495static void
496panel_profile_load_background (PanelToplevel *toplevel)
497{
498 PanelWidget *panel_widget;
499 PanelBackground *background;
500 PanelBackgroundType background_type;
501 GdkRGBA color;
502 char *image;
503 gboolean fit;
504 gboolean stretch;
505 gboolean rotate;
506
507 panel_widget = panel_toplevel_get_panel_widget (toplevel);
508
509 background = &panel_widget->toplevel->background;
510 background_type = panel_profile_get_background_type (toplevel);
511
512 panel_profile_get_background_color (toplevel, &color);
513
514 image = get_background_image (toplevel, &fit, &stretch, &rotate);
515
516 panel_background_set (background,
517 background_type,
518 &color,
519 image,
520 fit,
521 stretch,
522 rotate);
523
524 g_free (image);
525}
526
527static gboolean
528panel_profile_commit_toplevel_changes (PanelToplevel *toplevel)
529{
530 if (g_settings_get_has_unapplied (toplevel->queued_settings))
531 g_settings_apply (toplevel->queued_settings);
532
533 panel_profile_set_commit_timeout (toplevel, 0);
534
535 return FALSE(0);
536}
537
538static void
539panel_profile_queue_toplevel_location_change (PanelToplevel *toplevel,
540 ToplevelLocationChange *change)
541{
542 guint commit_timeout;
543
544 g_settings_delay (toplevel->queued_settings);
545
546#ifdef HAVE_X111
547 if (change->screen_changed &&
548 GDK_IS_X11_SCREEN (change->screen)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(change->screen)); GType __t = ((gdk_x11_screen_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; }))))
) {
549 g_settings_set_int (toplevel->queued_settings,
550 "screen",
551 gdk_x11_screen_get_screen_number (change->screen));
552 }
553#endif
554
555 if (change->monitor_changed)
556 g_settings_set_int (toplevel->queued_settings,
557 "monitor",
558 change->monitor);
559
560 if (change->size_changed)
561 g_settings_set_int (toplevel->queued_settings,
562 "size",
563 change->size);
564
565 if (change->orientation_changed)
566 g_settings_set_enum (toplevel->queued_settings,
567 "orientation",
568 change->orientation);
569
570 if (change->x_changed)
571 g_settings_set_int (toplevel->queued_settings,
572 "x",
573 change->x);
574
575 if (change->x_right_changed)
576 g_settings_set_int (toplevel->queued_settings,
577 "x-right",
578 change->x_right);
579
580 if (change->x_centered_changed)
581 g_settings_set_boolean (toplevel->queued_settings,
582 "x-centered",
583 change->x_centered);
584
585 if (change->y_changed)
586 g_settings_set_int (toplevel->queued_settings,
587 "y",
588 change->y);
589
590 if (change->y_bottom_changed)
591 g_settings_set_int (toplevel->queued_settings,
592 "y-bottom",
593 change->y_bottom);
594
595 if (change->y_centered_changed)
596 g_settings_set_boolean (toplevel->queued_settings,
597 "y-centered",
598 change->y_centered);
599
600 commit_timeout = panel_profile_get_commit_timeout (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
);
601 if (!commit_timeout) {
602 commit_timeout =
603 g_timeout_add (500,
604 (GSourceFunc) panel_profile_commit_toplevel_changes,
605 toplevel);
606 panel_profile_set_commit_timeout (toplevel, commit_timeout);
607 }
608}
609
610#define TOPLEVEL_LOCATION_CHANGED_HANDLER(c)static void panel_profile_toplevel_c_changed (PanelToplevel *
toplevel) { ToplevelLocationChange change = { ((void*)0) }; change
.c_changed = (!(0)); change.c = panel_toplevel_get_c (toplevel
); panel_profile_queue_toplevel_location_change (toplevel, &
change); }
\
611 static void \
612 panel_profile_toplevel_##c##_changed (PanelToplevel *toplevel) \
613 { \
614 ToplevelLocationChange change = { NULL((void*)0) }; \
615 change.c##_changed = TRUE(!(0)); \
616 change.c = panel_toplevel_get_##c (toplevel); \
617 panel_profile_queue_toplevel_location_change (toplevel, &change); \
618 }
619
620TOPLEVEL_LOCATION_CHANGED_HANDLER(monitor)static void panel_profile_toplevel_monitor_changed (PanelToplevel
*toplevel) { ToplevelLocationChange change = { ((void*)0) };
change.monitor_changed = (!(0)); change.monitor = panel_toplevel_get_monitor
(toplevel); panel_profile_queue_toplevel_location_change (toplevel
, &change); }
621TOPLEVEL_LOCATION_CHANGED_HANDLER(size)static void panel_profile_toplevel_size_changed (PanelToplevel
*toplevel) { ToplevelLocationChange change = { ((void*)0) };
change.size_changed = (!(0)); change.size = panel_toplevel_get_size
(toplevel); panel_profile_queue_toplevel_location_change (toplevel
, &change); }
622TOPLEVEL_LOCATION_CHANGED_HANDLER(orientation)static void panel_profile_toplevel_orientation_changed (PanelToplevel
*toplevel) { ToplevelLocationChange change = { ((void*)0) };
change.orientation_changed = (!(0)); change.orientation = panel_toplevel_get_orientation
(toplevel); panel_profile_queue_toplevel_location_change (toplevel
, &change); }
623TOPLEVEL_LOCATION_CHANGED_HANDLER(x_centered)static void panel_profile_toplevel_x_centered_changed (PanelToplevel
*toplevel) { ToplevelLocationChange change = { ((void*)0) };
change.x_centered_changed = (!(0)); change.x_centered = panel_toplevel_get_x_centered
(toplevel); panel_profile_queue_toplevel_location_change (toplevel
, &change); }
624TOPLEVEL_LOCATION_CHANGED_HANDLER(y_centered)static void panel_profile_toplevel_y_centered_changed (PanelToplevel
*toplevel) { ToplevelLocationChange change = { ((void*)0) };
change.y_centered_changed = (!(0)); change.y_centered = panel_toplevel_get_y_centered
(toplevel); panel_profile_queue_toplevel_location_change (toplevel
, &change); }
625
626#define TOPLEVEL_POSITION_CHANGED_HANDLER(c)static void panel_profile_toplevel_c_changed (PanelToplevel *
toplevel) { ToplevelLocationChange change = { ((void*)0) }; int
x, y, x_right, y_bottom; change.c_changed = (!(0)); panel_toplevel_get_position
(toplevel, &x, &x_right, &y, &y_bottom); change
.c = c; panel_profile_queue_toplevel_location_change (toplevel
, &change); }
\
627 static void \
628 panel_profile_toplevel_##c##_changed (PanelToplevel *toplevel) \
629 { \
630 ToplevelLocationChange change = { NULL((void*)0) }; \
631 int x, y, x_right, y_bottom; \
632 change.c##_changed = TRUE(!(0)); \
633 panel_toplevel_get_position (toplevel, \
634 &x, &x_right, \
635 &y, &y_bottom); \
636 change.c = c; \
637 panel_profile_queue_toplevel_location_change (toplevel, &change); \
638 }
639
640TOPLEVEL_POSITION_CHANGED_HANDLER(x)static void panel_profile_toplevel_x_changed (PanelToplevel *
toplevel) { ToplevelLocationChange change = { ((void*)0) }; int
x, y, x_right, y_bottom; change.x_changed = (!(0)); panel_toplevel_get_position
(toplevel, &x, &x_right, &y, &y_bottom); change
.x = x; panel_profile_queue_toplevel_location_change (toplevel
, &change); }
641TOPLEVEL_POSITION_CHANGED_HANDLER(x_right)static void panel_profile_toplevel_x_right_changed (PanelToplevel
*toplevel) { ToplevelLocationChange change = { ((void*)0) };
int x, y, x_right, y_bottom; change.x_right_changed = (!(0))
; panel_toplevel_get_position (toplevel, &x, &x_right
, &y, &y_bottom); change.x_right = x_right; panel_profile_queue_toplevel_location_change
(toplevel, &change); }
642TOPLEVEL_POSITION_CHANGED_HANDLER(y)static void panel_profile_toplevel_y_changed (PanelToplevel *
toplevel) { ToplevelLocationChange change = { ((void*)0) }; int
x, y, x_right, y_bottom; change.y_changed = (!(0)); panel_toplevel_get_position
(toplevel, &x, &x_right, &y, &y_bottom); change
.y = y; panel_profile_queue_toplevel_location_change (toplevel
, &change); }
643TOPLEVEL_POSITION_CHANGED_HANDLER(y_bottom)static void panel_profile_toplevel_y_bottom_changed (PanelToplevel
*toplevel) { ToplevelLocationChange change = { ((void*)0) };
int x, y, x_right, y_bottom; change.y_bottom_changed = (!(0)
); panel_toplevel_get_position (toplevel, &x, &x_right
, &y, &y_bottom); change.y_bottom = y_bottom; panel_profile_queue_toplevel_location_change
(toplevel, &change); }
644
645static void
646panel_profile_toplevel_screen_changed (PanelToplevel *toplevel)
647{
648 ToplevelLocationChange change = { NULL((void*)0) };
649
650 change.screen_changed = TRUE(!(0));
651 change.screen = gtk_window_get_screen (GTK_WINDOW (toplevel)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_window_get_type ()))))))
);
652
653 panel_profile_queue_toplevel_location_change (toplevel, &change);
654}
655
656static void
657panel_profile_connect_to_toplevel (PanelToplevel *toplevel)
658{
659 g_signal_connect (toplevel, "notify::screen",g_signal_connect_data ((toplevel), ("notify::screen"), (((GCallback
) (panel_profile_toplevel_screen_changed))), (((void*)0)), ((
void*)0), (GConnectFlags) 0)
660 G_CALLBACK (panel_profile_toplevel_screen_changed), NULL)g_signal_connect_data ((toplevel), ("notify::screen"), (((GCallback
) (panel_profile_toplevel_screen_changed))), (((void*)0)), ((
void*)0), (GConnectFlags) 0)
;
661 g_signal_connect (toplevel, "notify::monitor",g_signal_connect_data ((toplevel), ("notify::monitor"), (((GCallback
) (panel_profile_toplevel_monitor_changed))), (((void*)0)), (
(void*)0), (GConnectFlags) 0)
662 G_CALLBACK (panel_profile_toplevel_monitor_changed), NULL)g_signal_connect_data ((toplevel), ("notify::monitor"), (((GCallback
) (panel_profile_toplevel_monitor_changed))), (((void*)0)), (
(void*)0), (GConnectFlags) 0)
;
663 g_signal_connect (toplevel, "notify::size",g_signal_connect_data ((toplevel), ("notify::size"), (((GCallback
) (panel_profile_toplevel_size_changed))), (((void*)0)), ((void
*)0), (GConnectFlags) 0)
664 G_CALLBACK (panel_profile_toplevel_size_changed), NULL)g_signal_connect_data ((toplevel), ("notify::size"), (((GCallback
) (panel_profile_toplevel_size_changed))), (((void*)0)), ((void
*)0), (GConnectFlags) 0)
;
665 g_signal_connect (toplevel, "notify::x",g_signal_connect_data ((toplevel), ("notify::x"), (((GCallback
) (panel_profile_toplevel_x_changed))), (((void*)0)), ((void*
)0), (GConnectFlags) 0)
666 G_CALLBACK (panel_profile_toplevel_x_changed), NULL)g_signal_connect_data ((toplevel), ("notify::x"), (((GCallback
) (panel_profile_toplevel_x_changed))), (((void*)0)), ((void*
)0), (GConnectFlags) 0)
;
667 g_signal_connect (toplevel, "notify::x-right",g_signal_connect_data ((toplevel), ("notify::x-right"), (((GCallback
) (panel_profile_toplevel_x_right_changed))), (((void*)0)), (
(void*)0), (GConnectFlags) 0)
668 G_CALLBACK (panel_profile_toplevel_x_right_changed), NULL)g_signal_connect_data ((toplevel), ("notify::x-right"), (((GCallback
) (panel_profile_toplevel_x_right_changed))), (((void*)0)), (
(void*)0), (GConnectFlags) 0)
;
669 g_signal_connect (toplevel, "notify::x-centered",g_signal_connect_data ((toplevel), ("notify::x-centered"), ((
(GCallback) (panel_profile_toplevel_x_centered_changed))), ((
(void*)0)), ((void*)0), (GConnectFlags) 0)
670 G_CALLBACK (panel_profile_toplevel_x_centered_changed), NULL)g_signal_connect_data ((toplevel), ("notify::x-centered"), ((
(GCallback) (panel_profile_toplevel_x_centered_changed))), ((
(void*)0)), ((void*)0), (GConnectFlags) 0)
;
671 g_signal_connect (toplevel, "notify::y",g_signal_connect_data ((toplevel), ("notify::y"), (((GCallback
) (panel_profile_toplevel_y_changed))), (((void*)0)), ((void*
)0), (GConnectFlags) 0)
672 G_CALLBACK (panel_profile_toplevel_y_changed), NULL)g_signal_connect_data ((toplevel), ("notify::y"), (((GCallback
) (panel_profile_toplevel_y_changed))), (((void*)0)), ((void*
)0), (GConnectFlags) 0)
;
673 g_signal_connect (toplevel, "notify::y-bottom",g_signal_connect_data ((toplevel), ("notify::y-bottom"), (((GCallback
) (panel_profile_toplevel_y_bottom_changed))), (((void*)0)), (
(void*)0), (GConnectFlags) 0)
674 G_CALLBACK (panel_profile_toplevel_y_bottom_changed), NULL)g_signal_connect_data ((toplevel), ("notify::y-bottom"), (((GCallback
) (panel_profile_toplevel_y_bottom_changed))), (((void*)0)), (
(void*)0), (GConnectFlags) 0)
;
675 g_signal_connect (toplevel, "notify::y-centered",g_signal_connect_data ((toplevel), ("notify::y-centered"), ((
(GCallback) (panel_profile_toplevel_y_centered_changed))), ((
(void*)0)), ((void*)0), (GConnectFlags) 0)
676 G_CALLBACK (panel_profile_toplevel_y_centered_changed), NULL)g_signal_connect_data ((toplevel), ("notify::y-centered"), ((
(GCallback) (panel_profile_toplevel_y_centered_changed))), ((
(void*)0)), ((void*)0), (GConnectFlags) 0)
;
677 g_signal_connect (toplevel, "notify::orientation",g_signal_connect_data ((toplevel), ("notify::orientation"), (
((GCallback) (panel_profile_toplevel_orientation_changed))), (
((void*)0)), ((void*)0), (GConnectFlags) 0)
678 G_CALLBACK (panel_profile_toplevel_orientation_changed), NULL)g_signal_connect_data ((toplevel), ("notify::orientation"), (
((GCallback) (panel_profile_toplevel_orientation_changed))), (
((void*)0)), ((void*)0), (GConnectFlags) 0)
;
679}
680
681static void
682panel_profile_toplevel_change_notify (GSettings *settings,
683 gchar *key,
684 PanelToplevel *toplevel)
685{
686 if (toplevel == NULL((void*)0) || !PANEL_IS_TOPLEVEL (toplevel)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(toplevel)); GType __t = ((panel_toplevel_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; }))))
)
687 return;
688
689#define UPDATE_STRING(k, n)if (!strcmp (key, k)) { gchar *value = g_settings_get_string (
settings, key); panel_toplevel_set_n (toplevel, value); g_free
(value); }
\
690 if (!strcmp (key, k)) { \
691 gchar *value = g_settings_get_string (settings, key); \
692 panel_toplevel_set_##n (toplevel, value); \
693 g_free (value); \
694 }
695
696#define UPDATE_ENUM(k, n)if (!strcmp (key, k)) { panel_toplevel_set_n (toplevel, g_settings_get_enum
(settings, key)); }
\
697 if (!strcmp (key, k)) { \
698 panel_toplevel_set_##n (toplevel, \
699 g_settings_get_enum (settings, key)); \
700 }
701
702#define UPDATE_INT(k, n)if (!strcmp (key, k)) { panel_toplevel_set_n (toplevel, g_settings_get_int
(settings, key)); }
\
703 if (!strcmp (key, k)) { \
704 panel_toplevel_set_##n (toplevel, \
705 g_settings_get_int (settings, key)); \
706 }
707
708#define UPDATE_BOOL(k, n)if (!strcmp (key, k)) { panel_toplevel_set_n (toplevel, g_settings_get_boolean
(settings, key)); }
\
709 if (!strcmp (key, k)) { \
710 panel_toplevel_set_##n (toplevel, \
711 g_settings_get_boolean (settings, key)); \
712 }
713
714#define UPDATE_POS(k, n, n2)if (!strcmp (key, k)) { int x, x_right, y, y_bottom; panel_toplevel_get_position
(toplevel, &x, &x_right, &y, &y_bottom); panel_toplevel_set_n
( toplevel, g_settings_get_int (settings, key), n2, panel_toplevel_get_n_centered
(toplevel)); }
\
715 if (!strcmp (key, k)) { \
716 int x, x_right, y, y_bottom; \
717 panel_toplevel_get_position (toplevel, &x, &x_right, \
718 &y, &y_bottom); \
719 panel_toplevel_set_##n ( \
720 toplevel, \
721 g_settings_get_int (settings, key), \
722 n2, \
723 panel_toplevel_get_##n##_centered (toplevel)); \
724 }
725
726#define UPDATE_POS2(k, n, n2)if (!strcmp (key, k)) { int x, x_right, y, y_bottom; panel_toplevel_get_position
(toplevel, &x, &x_right, &y, &y_bottom); panel_toplevel_set_n
( toplevel, n, g_settings_get_int (settings, key), panel_toplevel_get_n_centered
(toplevel)); }
\
727 if (!strcmp (key, k)) { \
728 int x, x_right, y, y_bottom; \
729 panel_toplevel_get_position (toplevel, &x, &x_right, \
730 &y, &y_bottom); \
731 panel_toplevel_set_##n ( \
732 toplevel, \
733 n, \
734 g_settings_get_int (settings, key), \
735 panel_toplevel_get_##n##_centered (toplevel)); \
736 }
737
738#define UPDATE_CENTERED(k, n, n2)if (!strcmp (key, k)) { int x, x_right, y, y_bottom; panel_toplevel_get_position
(toplevel, &x, &x_right, &y, &y_bottom); panel_toplevel_set_n
( toplevel, n, n2, g_settings_get_boolean (settings, key)); }
\
739 if (!strcmp (key, k)) { \
740 int x, x_right, y, y_bottom; \
741 panel_toplevel_get_position (toplevel, &x, &x_right, \
742 &y, &y_bottom); \
743 panel_toplevel_set_##n ( \
744 toplevel, n, n2, \
745 g_settings_get_boolean (settings, key)); \
746 }
747
748 if (!strcmp (key, "screen")) {
749 GdkScreen *screen;
750 screen = gdk_display_get_default_screen (gdk_display_get_default ());
751
752 if (screen)
753 gtk_window_set_screen (GTK_WINDOW (toplevel)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_window_get_type ()))))))
, screen);
754 else
755 /* Make sure to set the key back to an actual
756 * available screen so it will get loaded on
757 * next startup.
758 */
759 panel_profile_toplevel_screen_changed (toplevel);
760 }
761 else UPDATE_INT ("monitor", monitor)if (!strcmp (key, "monitor")) { panel_toplevel_set_monitor (toplevel
, g_settings_get_int (settings, key)); }
762 else UPDATE_STRING ("name", name)if (!strcmp (key, "name")) { gchar *value = g_settings_get_string
(settings, key); panel_toplevel_set_name (toplevel, value); g_free
(value); }
763 else UPDATE_BOOL ("expand", expand)if (!strcmp (key, "expand")) { panel_toplevel_set_expand (toplevel
, g_settings_get_boolean (settings, key)); }
764 else UPDATE_ENUM ("orientation", orientation)if (!strcmp (key, "orientation")) { panel_toplevel_set_orientation
(toplevel, g_settings_get_enum (settings, key)); }
765 else UPDATE_INT ("size", size)if (!strcmp (key, "size")) { panel_toplevel_set_size (toplevel
, g_settings_get_int (settings, key)); }
766 else UPDATE_POS ("x", x, x_right)if (!strcmp (key, "x")) { int x, x_right, y, y_bottom; panel_toplevel_get_position
(toplevel, &x, &x_right, &y, &y_bottom); panel_toplevel_set_x
( toplevel, g_settings_get_int (settings, key), x_right, panel_toplevel_get_x_centered
(toplevel)); }
767 else UPDATE_POS ("y", y, y_bottom)if (!strcmp (key, "y")) { int x, x_right, y, y_bottom; panel_toplevel_get_position
(toplevel, &x, &x_right, &y, &y_bottom); panel_toplevel_set_y
( toplevel, g_settings_get_int (settings, key), y_bottom, panel_toplevel_get_y_centered
(toplevel)); }
768 else UPDATE_POS2 ("x-right", x, x_right)if (!strcmp (key, "x-right")) { int x, x_right, y, y_bottom; panel_toplevel_get_position
(toplevel, &x, &x_right, &y, &y_bottom); panel_toplevel_set_x
( toplevel, x, g_settings_get_int (settings, key), panel_toplevel_get_x_centered
(toplevel)); }
769 else UPDATE_POS2 ("y-bottom", y, y_bottom)if (!strcmp (key, "y-bottom")) { int x, x_right, y, y_bottom;
panel_toplevel_get_position (toplevel, &x, &x_right,
&y, &y_bottom); panel_toplevel_set_y ( toplevel, y, g_settings_get_int
(settings, key), panel_toplevel_get_y_centered (toplevel)); }
770 else UPDATE_CENTERED ("x-centered", x, x_right)if (!strcmp (key, "x-centered")) { int x, x_right, y, y_bottom
; panel_toplevel_get_position (toplevel, &x, &x_right
, &y, &y_bottom); panel_toplevel_set_x ( toplevel, x,
x_right, g_settings_get_boolean (settings, key)); }
771 else UPDATE_CENTERED ("y-centered", y, y_bottom)if (!strcmp (key, "y-centered")) { int x, x_right, y, y_bottom
; panel_toplevel_get_position (toplevel, &x, &x_right
, &y, &y_bottom); panel_toplevel_set_y ( toplevel, y,
y_bottom, g_settings_get_boolean (settings, key)); }
772 else UPDATE_BOOL ("auto-hide", auto_hide)if (!strcmp (key, "auto-hide")) { panel_toplevel_set_auto_hide
(toplevel, g_settings_get_boolean (settings, key)); }
773 else UPDATE_BOOL ("enable-animations", animate)if (!strcmp (key, "enable-animations")) { panel_toplevel_set_animate
(toplevel, g_settings_get_boolean (settings, key)); }
774 else UPDATE_BOOL ("enable-buttons", enable_buttons)if (!strcmp (key, "enable-buttons")) { panel_toplevel_set_enable_buttons
(toplevel, g_settings_get_boolean (settings, key)); }
775 else UPDATE_BOOL ("enable-arrows", enable_arrows)if (!strcmp (key, "enable-arrows")) { panel_toplevel_set_enable_arrows
(toplevel, g_settings_get_boolean (settings, key)); }
776 else UPDATE_INT ("hide-delay", hide_delay)if (!strcmp (key, "hide-delay")) { panel_toplevel_set_hide_delay
(toplevel, g_settings_get_int (settings, key)); }
777 else UPDATE_INT ("unhide-delay", unhide_delay)if (!strcmp (key, "unhide-delay")) { panel_toplevel_set_unhide_delay
(toplevel, g_settings_get_int (settings, key)); }
778 else UPDATE_INT ("auto-hide-size", auto_hide_size)if (!strcmp (key, "auto-hide-size")) { panel_toplevel_set_auto_hide_size
(toplevel, g_settings_get_int (settings, key)); }
779 else UPDATE_ENUM ("animation-speed", animation_speed)if (!strcmp (key, "animation-speed")) { panel_toplevel_set_animation_speed
(toplevel, g_settings_get_enum (settings, key)); }
780}
781
782static void
783panel_profile_background_change_notify (GSettings *settings,
784 gchar *key,
785 PanelToplevel *toplevel)
786{
787 PanelWidget *panel_widget;
788 PanelBackground *background;
789
790 if (toplevel == NULL((void*)0) || !PANEL_IS_TOPLEVEL (toplevel)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(toplevel)); GType __t = ((panel_toplevel_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; }))))
)
791 return;
792
793 panel_widget = panel_toplevel_get_panel_widget (toplevel);
794 if (panel_widget == NULL((void*)0))
795 return;
796
797 background = &panel_widget->toplevel->background;
798
799 if (!strcmp (key, "type")) {
800 PanelBackgroundType background_type;
801 background_type = g_settings_get_enum (settings, key);
802 panel_background_set_type (background, background_type);
803 panel_toplevel_update_edges (toplevel);
804 } else if (!strcmp (key, "color")) {
805 GdkRGBA color;
806 gchar *str;
807 str = g_settings_get_string (settings, key);
808 if (gdk_rgba_parse (&color, str))
809 panel_background_set_color (background, &color);
810 g_free (str);
811 } else if (!strcmp (key, "image")) {
812 gchar *value = g_settings_get_string (settings, key);
813 panel_background_set_image (background, value);
814 g_free (value);
815 } else if (!strcmp (key, "fit")) {
816 panel_background_set_fit (background,
817 g_settings_get_boolean (settings, key));
818 } else if (!strcmp (key, "stretch")) {
819 panel_background_set_stretch (background,
820 g_settings_get_boolean (settings, key));
821 } else if (!strcmp (key, "rotate")) {
822 panel_background_set_rotate (background,
823 g_settings_get_boolean (settings, key));
824 }
825}
826
827static const char *
828key_from_type (PanelGSettingsKeyType type) {
829 if (type == PANEL_GSETTINGS_TOPLEVELS)
830 return PANEL_TOPLEVEL_ID_LIST_KEY"toplevel-id-list";
831 else if (type == PANEL_GSETTINGS_OBJECTS)
832 return PANEL_OBJECT_ID_LIST_KEY"object-id-list";
833
834 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-profile.c"
, 834, ((const char*) (__func__)), ((void*)0)); } while (0)
;
835 return NULL((void*)0);
836}
837
838static GVariant *
839remove_from_dict (GVariant *dict, const gchar *path)
840{
841 GVariantIter iter;
842 GVariantBuilder builder;
843
844 gchar *key;
845 gchar *value;
846
847 g_variant_builder_init (&builder, (const GVariantType *) "a{ss}");
848 g_variant_iter_init (&iter, dict);
849
850 while (g_variant_iter_next (&iter, "{ss}", &key, &value)) {
851 if ( g_strcmp0 (value, path) != 0) {
852 g_variant_builder_add (&builder, "{ss}", key, value);
853 }
854
855 g_free (key);
856 g_free (value);
857 }
858
859 return g_variant_ref_sink (g_variant_builder_end (&builder));
860}
861
862static void
863unregister_dconf_editor_relocatable_schema (const gchar *path)
864{
865 GSettings *dconf_editor_settings;
866 dconf_editor_settings = g_settings_new ("ca.desrt.dconf-editor.Settings");
867
868 if (dconf_editor_settings && g_settings_is_writable (dconf_editor_settings, "relocatable-schemas-user-paths")) {
869 GVariant *relocatable_schemas = g_settings_get_value (dconf_editor_settings, "relocatable-schemas-user-paths");
870
871 if (g_variant_is_of_type (relocatable_schemas, G_VARIANT_TYPE_DICTIONARY((const GVariantType *) "a{?*}"))) {
Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption
872 GVariant * new_relocatable_schemas = remove_from_dict (relocatable_schemas, path);
873 g_settings_set_value (dconf_editor_settings, "relocatable-schemas-user-paths", new_relocatable_schemas);
874 g_variant_unref (new_relocatable_schemas);
875 }
876
877 g_variant_unref (relocatable_schemas);
878 }
879
880 g_object_unref (dconf_editor_settings);
881}
882
883
884void
885panel_profile_add_to_list (PanelGSettingsKeyType type,
886 const char *id)
887{
888 char *new_id = id ? g_strdup (id)g_strdup_inline (id) : panel_profile_find_new_id (type);
889
890 if (new_id != NULL((void*)0)) {
891 mate_gsettings_append_strv (profile_settings,
892 key_from_type (type),
893 new_id);
894 g_free (new_id);
895 }
896}
897
898void
899panel_profile_remove_from_list (PanelGSettingsKeyType type,
900 const char *id)
901{
902 mate_gsettings_remove_all_from_strv (profile_settings,
903 key_from_type (type),
904 id);
905}
906
907static gboolean
908panel_profile_id_list_is_writable (PanelGSettingsKeyType type)
909{
910 return g_settings_is_writable (profile_settings, key_from_type (type));
911}
912
913gboolean
914panel_profile_id_lists_are_writable (void)
915{
916 return
917 panel_profile_id_list_is_writable (PANEL_GSETTINGS_TOPLEVELS) &&
918 panel_profile_id_list_is_writable (PANEL_GSETTINGS_OBJECTS);
919}
920
921static gboolean
922panel_profile_find_empty_spot (GdkScreen *screen,
923 PanelOrientation *orientation,
924 int *monitor)
925{
926 GSList *li;
927 int i;
928 int *filled_spots;
929 gboolean found_a_spot = FALSE(0);
930
931 *monitor = 0;
932 *orientation = PANEL_ORIENTATION_TOP;
933
934 filled_spots = g_new0 (int, panel_multimonitor_monitors ())((int *) g_malloc0_n ((panel_multimonitor_monitors ()), sizeof
(int)))
;
935
936 for (li = panel_toplevel_list_toplevels (); li != NULL((void*)0); li = li->next) {
937 PanelToplevel *toplevel = li->data;
938 GdkScreen *toplevel_screen = gtk_window_get_screen (GTK_WINDOW (toplevel)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_window_get_type ()))))))
);
939 int toplevel_monitor = panel_toplevel_get_monitor (toplevel);
940
941 if (toplevel_screen != screen ||
942 panel_toplevel_get_is_attached (toplevel) ||
943 toplevel_monitor < 0)
944 continue;
945
946 filled_spots[toplevel_monitor] |= panel_toplevel_get_orientation (toplevel);
947 }
948
949 for (i = 0; i < panel_multimonitor_monitors (); i++) {
950 /* These are ordered based on "priority" of the
951 orientation when picking it */
952 if ( ! (filled_spots[i] & PANEL_ORIENTATION_TOP)) {
953 *orientation = PANEL_ORIENTATION_TOP;
954 *monitor = i;
955 found_a_spot = TRUE(!(0));
956 break;
957 } else if ( ! (filled_spots[i] & PANEL_ORIENTATION_BOTTOM)) {
958 *orientation = PANEL_ORIENTATION_BOTTOM;
959 *monitor = i;
960 found_a_spot = TRUE(!(0));
961 break;
962 } else if ( ! (filled_spots[i] & PANEL_ORIENTATION_RIGHT)) {
963 *orientation = PANEL_ORIENTATION_RIGHT;
964 *monitor = i;
965 found_a_spot = TRUE(!(0));
966 break;
967 } else if ( ! (filled_spots[i] & PANEL_ORIENTATION_LEFT)) {
968 *orientation = PANEL_ORIENTATION_LEFT;
969 *monitor = i;
970 found_a_spot = TRUE(!(0));
971 break;
972 }
973 }
974
975 g_free (filled_spots);
976
977 return found_a_spot;
978}
979
980void
981panel_profile_create_toplevel (GdkScreen *screen)
982{
983 char *id;
984 char *path;
985 PanelOrientation orientation;
986 int monitor;
987 GSettings *settings;
988 int screen_number;
989
990 g_return_if_fail (screen != NULL)do { if ((screen != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "screen != NULL")
; return; } } while (0)
;
991
992 id = panel_profile_find_new_id (PANEL_GSETTINGS_TOPLEVELS);
993
994 path = g_strdup_printf (PANEL_TOPLEVEL_PATH"/org/mate/panel/toplevels/" "%s/", id);
995
996 settings = g_settings_new_with_path (PANEL_TOPLEVEL_SCHEMA"org.mate.panel.toplevel", path);
997 g_free (path);
998
999 screen_number = 0;
1000#ifdef HAVE_X111
1001 if (GDK_IS_X11_SCREEN (screen)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(screen)); GType __t = ((gdk_x11_screen_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; }))))
) {
1002 screen_number = gdk_x11_screen_get_screen_number (screen);
1003 }
1004#endif /* HAVE_X11 */
1005
1006 g_settings_set_int (settings, PANEL_TOPLEVEL_SCREEN_KEY"screen", screen_number);
1007
1008 if (panel_profile_find_empty_spot (screen, &orientation, &monitor)) {
1009 g_settings_set_int (settings, PANEL_TOPLEVEL_MONITOR_KEY"monitor", monitor);
1010 g_settings_set_enum (settings, PANEL_TOPLEVEL_ORIENTATION_KEY"orientation", orientation);
1011 }
1012
1013 panel_profile_add_to_list (PANEL_GSETTINGS_TOPLEVELS, id);
1014
1015 g_object_unref (settings);
1016 g_free (id);
1017}
1018
1019static void
1020panel_profile_delete_toplevel_objects (const char *toplevel_id)
1021{
1022 gchar **list;
1023 GArray *newlist;
1024 int i;
1025
1026 list = g_settings_get_strv (profile_settings, PANEL_OBJECT_ID_LIST_KEY"object-id-list");
1027 newlist = g_array_new (TRUE(!(0)), TRUE(!(0)), sizeof (gchar *));
1028
1029 for (i = 0; list[i]; i++) {
1030 char *path;
1031 char *parent_toplevel_id;
1032 GSettings *settings;
1033
1034 path = g_strdup_printf (PANEL_OBJECT_PATH"/org/mate/panel/objects/" "%s/", list[i]);
1035 settings = g_settings_new_with_path (PANEL_OBJECT_SCHEMA"org.mate.panel.object", path);
1036 parent_toplevel_id = g_settings_get_string (settings, PANEL_OBJECT_TOPLEVEL_ID_KEY"toplevel-id");
1037 g_free (path);
1038 g_object_unref (settings);
1039
1040 if (parent_toplevel_id && !strcmp (toplevel_id, parent_toplevel_id)) {
1041 g_free (parent_toplevel_id);
1042 continue;
1043 }
1044
1045 newlist = g_array_append_val (newlist, list[i])g_array_append_vals (newlist, &(list[i]), 1);
1046
1047 g_free (parent_toplevel_id);
1048 }
1049
1050 g_settings_set_strv (profile_settings, PANEL_OBJECT_ID_LIST_KEY"object-id-list", (const gchar **) newlist->data);
1051 g_array_free (newlist, TRUE(!(0)));
1052 g_strfreev (list);
1053}
1054
1055void
1056panel_profile_delete_toplevel (PanelToplevel *toplevel)
1057{
1058 const char *toplevel_id;
1059
1060 toplevel_id = panel_profile_get_toplevel_id (toplevel);
1061
1062 panel_profile_delete_toplevel_objects (toplevel_id);
1063
1064 panel_profile_remove_from_list (PANEL_GSETTINGS_TOPLEVELS, toplevel_id);
1065}
1066
1067PanelToplevel *
1068panel_profile_load_toplevel (const char *toplevel_id)
1069{
1070 PanelToplevel *toplevel;
1071 GdkScreen *screen;
1072 char *toplevel_path;
1073 char *toplevel_background_path;
1074
1075 if (!toplevel_id || !toplevel_id [0])
1076 return NULL((void*)0);
1077
1078 toplevel_path = g_strdup_printf ("%s%s/", PANEL_TOPLEVEL_PATH"/org/mate/panel/toplevels/", toplevel_id);
1079
1080 screen = gdk_display_get_default_screen (gdk_display_get_default ());
1081
1082 if (screen == NULL((void*)0)) {
1083 g_free (toplevel_path);
1084 return NULL((void*)0);
1085 }
1086
1087 toplevel = g_object_new (PANEL_TYPE_TOPLEVEL(panel_toplevel_get_type ()),
1088 "screen", screen,
1089 NULL((void*)0));
1090
1091 panel_toplevel_set_settings_path (toplevel, toplevel_path);
1092 toplevel->settings = g_settings_new_with_path (PANEL_TOPLEVEL_SCHEMA"org.mate.panel.toplevel", toplevel_path);
1093 toplevel->queued_settings = g_settings_new_with_path (PANEL_TOPLEVEL_SCHEMA"org.mate.panel.toplevel", toplevel_path);
1094
1095 toplevel_background_path = g_strdup_printf ("%sbackground/", toplevel_path);
1096 toplevel->background_settings = g_settings_new_with_path (PANEL_TOPLEVEL_BACKGROUND_SCHEMA"org.mate.panel.toplevel.background", toplevel_background_path);
1097
1098#define GET_INT(k, fn){ int val; val = g_settings_get_int (toplevel->settings, k
); panel_toplevel_set_fn (toplevel, val); }
\
1099 { \
1100 int val; \
1101 val = g_settings_get_int (toplevel->settings, k); \
1102 panel_toplevel_set_##fn (toplevel, val); \
1103 }
1104
1105#define GET_BOOL(k, fn){ gboolean val; val = g_settings_get_boolean (toplevel->settings
, k); panel_toplevel_set_fn (toplevel, val); }
\
1106 { \
1107 gboolean val; \
1108 val = g_settings_get_boolean (toplevel->settings, k); \
1109 panel_toplevel_set_##fn (toplevel, val); \
1110 }
1111
1112#define GET_STRING(k, fn){ char *val; val = g_settings_get_string (toplevel->settings
, k); panel_toplevel_set_fn (toplevel, val); g_free (val); }
\
1113 { \
1114 char *val; \
1115 val = g_settings_get_string (toplevel->settings, k); \
1116 panel_toplevel_set_##fn (toplevel, val); \
1117 g_free (val); \
1118 }
1119
1120#define GET_ENUM(k, fn){ int val; val = g_settings_get_enum (toplevel->settings, k
); panel_toplevel_set_fn (toplevel, val); }
\
1121 { \
1122 int val; \
1123 val = g_settings_get_enum (toplevel->settings, k); \
1124 panel_toplevel_set_##fn (toplevel, val); \
1125 }
1126
1127 GET_STRING ("name", name){ char *val; val = g_settings_get_string (toplevel->settings
, "name"); panel_toplevel_set_name (toplevel, val); g_free (val
); }
;
1128 GET_INT ("monitor", monitor){ int val; val = g_settings_get_int (toplevel->settings, "monitor"
); panel_toplevel_set_monitor (toplevel, val); }
;
1129 GET_BOOL ("expand", expand){ gboolean val; val = g_settings_get_boolean (toplevel->settings
, "expand"); panel_toplevel_set_expand (toplevel, val); }
;
1130 GET_ENUM ("orientation", orientation){ int val; val = g_settings_get_enum (toplevel->settings, "orientation"
); panel_toplevel_set_orientation (toplevel, val); }
;
1131 GET_INT ("size", size){ int val; val = g_settings_get_int (toplevel->settings, "size"
); panel_toplevel_set_size (toplevel, val); }
;
1132 GET_BOOL ("auto-hide", auto_hide){ gboolean val; val = g_settings_get_boolean (toplevel->settings
, "auto-hide"); panel_toplevel_set_auto_hide (toplevel, val);
}
;
1133 GET_BOOL ("enable-animations", animate){ gboolean val; val = g_settings_get_boolean (toplevel->settings
, "enable-animations"); panel_toplevel_set_animate (toplevel,
val); }
;
1134 GET_BOOL ("enable-buttons", enable_buttons){ gboolean val; val = g_settings_get_boolean (toplevel->settings
, "enable-buttons"); panel_toplevel_set_enable_buttons (toplevel
, val); }
;
1135 GET_BOOL ("enable-arrows", enable_arrows){ gboolean val; val = g_settings_get_boolean (toplevel->settings
, "enable-arrows"); panel_toplevel_set_enable_arrows (toplevel
, val); }
;
1136 GET_INT ("hide-delay", hide_delay){ int val; val = g_settings_get_int (toplevel->settings, "hide-delay"
); panel_toplevel_set_hide_delay (toplevel, val); }
;
1137 GET_INT ("unhide-delay", unhide_delay){ int val; val = g_settings_get_int (toplevel->settings, "unhide-delay"
); panel_toplevel_set_unhide_delay (toplevel, val); }
;
1138 GET_INT ("auto-hide-size", auto_hide_size){ int val; val = g_settings_get_int (toplevel->settings, "auto-hide-size"
); panel_toplevel_set_auto_hide_size (toplevel, val); }
;
1139 GET_ENUM ("animation-speed", animation_speed){ int val; val = g_settings_get_enum (toplevel->settings, "animation-speed"
); panel_toplevel_set_animation_speed (toplevel, val); }
;
1140
1141#define GET_POSITION(a, b, c, fn){ gboolean centered; int position; int position2; centered = g_settings_get_boolean
(toplevel->settings, c); position = g_settings_get_int (toplevel
->settings, a); position2 = g_settings_get_int (toplevel->
settings, b); panel_toplevel_set_fn (toplevel, position, position2
, centered); }
\
1142 { \
1143 gboolean centered; \
1144 int position; \
1145 int position2; \
1146 centered = g_settings_get_boolean (toplevel->settings, c); \
1147 position = g_settings_get_int (toplevel->settings, a); \
1148 position2 = g_settings_get_int (toplevel->settings, b); \
1149 panel_toplevel_set_##fn (toplevel, position, position2, centered); \
1150 }
1151
1152 GET_POSITION ("x", "x-right", "x-centered", x){ gboolean centered; int position; int position2; centered = g_settings_get_boolean
(toplevel->settings, "x-centered"); position = g_settings_get_int
(toplevel->settings, "x"); position2 = g_settings_get_int
(toplevel->settings, "x-right"); panel_toplevel_set_x (toplevel
, position, position2, centered); }
;
1153 GET_POSITION ("y", "y-bottom", "y-centered", y){ gboolean centered; int position; int position2; centered = g_settings_get_boolean
(toplevel->settings, "y-centered"); position = g_settings_get_int
(toplevel->settings, "y"); position2 = g_settings_get_int
(toplevel->settings, "y-bottom"); panel_toplevel_set_y (toplevel
, position, position2, centered); }
;
1154
1155 panel_profile_load_background (toplevel);
1156
1157 panel_profile_set_toplevel_id (toplevel, toplevel_id);
1158
1159 panel_profile_connect_to_toplevel (toplevel);
1160
1161 g_signal_connect (toplevel->settings,g_signal_connect_data ((toplevel->settings), ("changed"), (
((GCallback) (panel_profile_toplevel_change_notify))), (toplevel
), ((void*)0), (GConnectFlags) 0)
1162 "changed",g_signal_connect_data ((toplevel->settings), ("changed"), (
((GCallback) (panel_profile_toplevel_change_notify))), (toplevel
), ((void*)0), (GConnectFlags) 0)
1163 G_CALLBACK (panel_profile_toplevel_change_notify),g_signal_connect_data ((toplevel->settings), ("changed"), (
((GCallback) (panel_profile_toplevel_change_notify))), (toplevel
), ((void*)0), (GConnectFlags) 0)
1164 toplevel)g_signal_connect_data ((toplevel->settings), ("changed"), (
((GCallback) (panel_profile_toplevel_change_notify))), (toplevel
), ((void*)0), (GConnectFlags) 0)
;
1165 g_signal_connect (toplevel->background_settings,g_signal_connect_data ((toplevel->background_settings), ("changed"
), (((GCallback) (panel_profile_background_change_notify))), (
toplevel), ((void*)0), (GConnectFlags) 0)
1166 "changed",g_signal_connect_data ((toplevel->background_settings), ("changed"
), (((GCallback) (panel_profile_background_change_notify))), (
toplevel), ((void*)0), (GConnectFlags) 0)
1167 G_CALLBACK (panel_profile_background_change_notify),g_signal_connect_data ((toplevel->background_settings), ("changed"
), (((GCallback) (panel_profile_background_change_notify))), (
toplevel), ((void*)0), (GConnectFlags) 0)
1168 toplevel)g_signal_connect_data ((toplevel->background_settings), ("changed"
), (((GCallback) (panel_profile_background_change_notify))), (
toplevel), ((void*)0), (GConnectFlags) 0)
;
1169
1170 g_free (toplevel_path);
1171 g_free (toplevel_background_path);
1172
1173 panel_setup (toplevel);
1174
1175 return toplevel;
1176}
1177
1178static void
1179panel_profile_load_and_show_toplevel (char *toplevel_id)
1180{
1181 PanelToplevel *toplevel;
1182 gchar **objects;
1183 gboolean loading_queued_applets;
1184
1185 toplevel = panel_profile_load_toplevel (toplevel_id);
1186 if (!toplevel)
1187 return;
1188
1189 gtk_widget_show (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
1190
1191 loading_queued_applets = FALSE(0);
1192
1193 /* reload list of objects to get those that might be on the new
1194 * toplevel */
1195 GSettings *panel_settings;
1196 panel_settings = g_settings_new (PANEL_SCHEMA"org.mate.panel");
1197 objects = g_settings_get_strv (panel_settings, PANEL_OBJECT_ID_LIST_KEY"object-id-list");
1198
1199 if (objects) {
1200 panel_profile_object_id_list_update (objects);
1201 loading_queued_applets = TRUE(!(0));
1202 }
1203
1204 if (!loading_queued_applets)
1205 mate_panel_applet_load_queued_applets (FALSE(0));
1206
1207 g_strfreev (objects);
1208 g_object_unref (panel_settings);
1209}
1210
1211static void
1212panel_profile_load_and_show_toplevel_startup (const char *toplevel_id)
1213{
1214 PanelToplevel *toplevel;
1215 toplevel = panel_profile_load_toplevel (toplevel_id);
1216 if (toplevel)
1217 gtk_widget_show (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
1218}
1219
1220static void
1221panel_profile_destroy_toplevel (const char *id)
1222{
1223 PanelToplevel *toplevel;
1224
1225 if (!(toplevel = panel_profile_get_toplevel_by_id (id)))
1226 return;
1227
1228 gtk_widget_destroy (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
1229}
1230
1231char *
1232panel_profile_prepare_object_with_id (PanelObjectType object_type,
1233 const char *toplevel_id,
1234 int position,
1235 gboolean right_stick)
1236{
1237 PanelGSettingsKeyType key_type;
1238 char *id;
1239 char *settings_path;
1240 GSettings *settings;
1241
1242 key_type = PANEL_GSETTINGS_OBJECTS;
1243 id = panel_profile_find_new_id (key_type);
1244
1245 settings_path = g_strdup_printf (PANEL_OBJECT_PATH"/org/mate/panel/objects/" "%s/", id);
1246
1247 settings = g_settings_new_with_path (PANEL_OBJECT_SCHEMA"org.mate.panel.object", settings_path);
1248
1249 g_settings_set_enum (settings, PANEL_OBJECT_TYPE_KEY"object-type", object_type);
1250 g_settings_set_string (settings, PANEL_OBJECT_TOPLEVEL_ID_KEY"toplevel-id", toplevel_id);
1251 g_settings_set_int (settings, PANEL_OBJECT_POSITION_KEY"position", position);
1252 g_settings_set_boolean (settings, PANEL_OBJECT_PANEL_RIGHT_STICK_KEY"panel-right-stick", right_stick);
1253
1254 /* Force writing the settings in order to reserve the object ID *now*,
1255 * so that a later call to panel_profile_find_new_id() won't find the same
1256 * one. */
1257 g_settings_sync ();
1258
1259 g_free (settings_path);
1260 g_object_unref (settings);
1261
1262 return id;
1263}
1264
1265char *
1266panel_profile_prepare_object (PanelObjectType object_type,
1267 PanelToplevel *toplevel,
1268 int position,
1269 gboolean right_stick)
1270{
1271 return panel_profile_prepare_object_with_id (object_type,
1272 panel_profile_get_toplevel_id (toplevel),
1273 position,
1274 right_stick);
1275}
1276
1277void
1278panel_profile_delete_object (AppletInfo *applet_info)
1279{
1280 PanelGSettingsKeyType type;
1281 const char *id;
1282
1283 type = PANEL_GSETTINGS_OBJECTS;
1284 id = mate_panel_applet_get_id (applet_info);
1285
1286 panel_profile_remove_from_list (type, id);
1287}
1288
1289static void
1290panel_profile_load_object (char *id)
1291{
1292 PanelObjectType object_type;
1293 char *object_path;
1294 char *toplevel_id;
1295 int position;
1296 gboolean right_stick;
1297 gboolean locked;
1298 GSettings *settings;
1299
1300 object_path = g_strdup_printf (PANEL_OBJECT_PATH"/org/mate/panel/objects/" "%s/", id);
1301 settings = g_settings_new_with_path (PANEL_OBJECT_SCHEMA"org.mate.panel.object", object_path);
1302
1303 object_type = g_settings_get_enum (settings, PANEL_OBJECT_TYPE_KEY"object-type");
1304 position = g_settings_get_int (settings, PANEL_OBJECT_POSITION_KEY"position");
1305 toplevel_id = g_settings_get_string (settings, PANEL_OBJECT_TOPLEVEL_ID_KEY"toplevel-id");
1306 right_stick = g_settings_get_boolean (settings, PANEL_OBJECT_PANEL_RIGHT_STICK_KEY"panel-right-stick");
1307 locked = g_settings_get_boolean (settings, PANEL_OBJECT_LOCKED_KEY"locked");
1308
1309 mate_panel_applet_queue_applet_to_load (id,
1310 object_type,
1311 toplevel_id,
1312 position,
1313 right_stick,
1314 locked);
1315
1316 g_free (toplevel_id);
1317 g_free (object_path);
1318 g_object_unref (settings);
1319}
1320
1321static void
1322panel_profile_destroy_object (const char *id)
1323{
1324 AppletInfo *info;
1325
1326 info = mate_panel_applet_get_by_id (id);
1327
1328 mate_panel_applet_clean (info);
1329}
1330
1331static void
1332panel_profile_delete_dir (PanelGSettingsKeyType type,
1333 const char *id)
1334{
1335 gchar *dir = NULL((void*)0);
1336
1337 switch (type) {
1338 case PANEL_GSETTINGS_TOPLEVELS:
1339 dir = g_strdup_printf (PANEL_TOPLEVEL_PATH"/org/mate/panel/toplevels/" "%s/", id);
1340 break;
1341 case PANEL_GSETTINGS_OBJECTS:
1342 dir = g_strdup_printf (PANEL_OBJECT_PATH"/org/mate/panel/objects/" "%s/", id);
1343 break;
1344 default:
1345 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-profile.c"
, 1345, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1346 break;
1347 }
1348
1349 if (type == PANEL_GSETTINGS_TOPLEVELS) {
1350 gchar *subdir;
1351 subdir = g_strdup_printf (PANEL_TOPLEVEL_PATH"/org/mate/panel/toplevels/" "%s/background/", id);
1352 mate_dconf_recursive_reset (subdir, NULL((void*)0));
1353 g_free (subdir);
1354 }
1355 else if (type == PANEL_GSETTINGS_OBJECTS) {
1356 gchar *subdir;
1357 subdir = g_strdup_printf (PANEL_TOPLEVEL_PATH"/org/mate/panel/toplevels/" "%s/prefs/", id);
1358 mate_dconf_recursive_reset (subdir, NULL((void*)0));
1359 unregister_dconf_editor_relocatable_schema (subdir);
1360 g_free (subdir);
1361 }
1362
1363 if (dir != NULL((void*)0)) {
1364 mate_dconf_recursive_reset (dir, NULL((void*)0));
1365 g_free (dir);
1366 }
1367}
1368
1369static gboolean
1370panel_profile_object_exists (GSList *list,
1371 const char *id,
1372 PanelProfileGetIdFunc get_id_func)
1373{
1374 GSList *l;
1375
1376 if (!list || !id)
1377 return FALSE(0);
1378
1379 for (l = list; l; l = l->next) {
1380 const char *check_id;
1381
1382 check_id = get_id_func (l->data);
1383 g_assert (check_id != NULL)do { if (check_id != ((void*)0)) ; else g_assertion_message_expr
(((gchar*) 0), "panel-profile.c", 1383, ((const char*) (__func__
)), "check_id != NULL"); } while (0)
;
1384
1385 if (!strcmp (check_id, id))
1386 return TRUE(!(0));
1387 }
1388
1389 return FALSE(0);
1390}
1391
1392static gboolean
1393panel_profile_id_exists (GSList *id_list,
1394 const char *id)
1395{
1396 GSList *l;
1397
1398 if (!id_list || !id)
1399 return FALSE(0);
1400
1401 for (l = id_list; l; l = l->next) {
1402 const char *check_id = l->data;
1403
1404 if (!strcmp (id, check_id))
1405 return TRUE(!(0));
1406 }
1407
1408 return FALSE(0);
1409}
1410
1411static void
1412panel_profile_load_added_ids (GSList *list,
1413 GSList *id_list,
1414 PanelProfileGetIdFunc get_id_func,
1415 PanelProfileLoadFunc load_handler,
1416 PanelProfileOnLoadQueue on_load_queue)
1417{
1418 GSList *added_ids = NULL((void*)0);
1419 GSList *l;
1420
1421 for (l = id_list; l; l = l->next) {
1422 const char *id = l->data;
1423
1424 if (!panel_profile_object_exists (list, id, get_id_func) &&
1425 (on_load_queue == NULL((void*)0) || !on_load_queue (id)))
1426 added_ids = g_slist_prepend (added_ids, g_strdup (id)g_strdup_inline (id));
1427 }
1428
1429 for (l = added_ids; l; l = l->next) {
1430 char *id;
1431 id = (char *) l->data;
1432
1433 if (id && id[0])
1434 load_handler (id);
1435
1436 g_clear_pointer (&l->data, g_free)do { _Static_assert (sizeof *(&l->data) == sizeof (gpointer
), "Expression evaluates to false"); __typeof__ ((&l->
data)) _pp = (&l->data); __typeof__ (*(&l->data
)) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (g_free) (_ptr);
} while (0)
;
1437 }
1438
1439 g_slist_free (added_ids);
1440}
1441
1442static void
1443panel_profile_delete_removed_ids (PanelGSettingsKeyType type,
1444 GSList *list,
1445 GSList *id_list,
1446 PanelProfileGetIdFunc get_id_func,
1447 PanelProfileDestroyFunc destroy_handler)
1448{
1449 GSList *removed_ids = NULL((void*)0);
1450 GSList *l;
1451
1452 for (l = list; l; l = l->next) {
1453 const char *id;
1454
1455 id = get_id_func (l->data);
1456
1457 if (!panel_profile_id_exists (id_list, id))
1458 removed_ids = g_slist_prepend (removed_ids, g_strdup (id)g_strdup_inline (id));
1459 }
1460
1461 for (l = removed_ids; l; l = l->next) {
1462 const char *id = l->data;
1463
1464 panel_profile_delete_dir (type, id);
1465 destroy_handler (id);
1466
1467 g_clear_pointer (&l->data, g_free)do { _Static_assert (sizeof *(&l->data) == sizeof (gpointer
), "Expression evaluates to false"); __typeof__ ((&l->
data)) _pp = (&l->data); __typeof__ (*(&l->data
)) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (g_free) (_ptr);
} while (0)
;
1468 }
1469 g_slist_free (removed_ids);
1470}
1471
1472static gboolean
1473load_default_layout_idle (gpointer unused) {
1474 if (g_slist_length (panel_toplevel_list_toplevels ()) != 0) {
1475 /* some toplevels are not destroyed yet, waiting */
1476 return TRUE(!(0));
1477 }
1478
1479 /* load the default layout and stop this handler */
1480 panel_profile_ensure_toplevel_per_screen ();
1481 return FALSE(0);
1482}
1483
1484static void
1485panel_profile_toplevel_id_list_notify (GSettings *settings,
1486 gchar *key,
1487 gpointer user_data)
1488{
1489 GSList *l, *existing_toplevels;
1490 GSList *toplevel_ids;
1491 gchar **toplevel_ids_strv;
1492
1493 toplevel_ids_strv = g_settings_get_strv (settings, key);
1494
1495 toplevel_ids = mate_gsettings_strv_to_gslist ((const gchar **) toplevel_ids_strv);
1496 toplevel_ids = panel_g_slist_make_unique (toplevel_ids,
1497 (GCompareFunc) g_strcmp0,
1498 TRUE(!(0)));
1499 g_strfreev (toplevel_ids_strv);
1500
1501 existing_toplevels = NULL((void*)0);
1502 for (l = panel_toplevel_list_toplevels (); l; l = l->next) {
1503 PanelToplevel *toplevel = l->data;
1504
1505 /* Attached toplevels aren't on the id list */
1506 if (panel_toplevel_get_is_attached (toplevel))
1507 continue;
1508
1509 existing_toplevels = g_slist_prepend (existing_toplevels, toplevel);
1510 }
1511
1512 panel_profile_load_added_ids (existing_toplevels,
1513 toplevel_ids,
1514 (PanelProfileGetIdFunc) panel_profile_get_toplevel_id,
1515 (PanelProfileLoadFunc) panel_profile_load_and_show_toplevel,
1516 (PanelProfileOnLoadQueue) NULL((void*)0));
1517
1518 panel_profile_delete_removed_ids (PANEL_GSETTINGS_TOPLEVELS,
1519 existing_toplevels,
1520 toplevel_ids,
1521 (PanelProfileGetIdFunc) panel_profile_get_toplevel_id,
1522 (PanelProfileDestroyFunc) panel_profile_destroy_toplevel);
1523
1524 /* if there are no panels, reset layout to default */
1525 if (g_slist_length (toplevel_ids) == 0)
1526 g_idle_add (load_default_layout_idle, NULL((void*)0));
1527
1528 g_slist_free (existing_toplevels);
1529 g_slist_free_full (toplevel_ids, g_free);
1530}
1531
1532static void
1533panel_profile_object_id_list_update (gchar **objects)
1534{
1535 GSList *existing_applets;
1536 GSList *sublist = NULL((void*)0), *l;
1537 GSList *object_ids;
1538
1539 object_ids = mate_gsettings_strv_to_gslist ((const gchar **) objects);
1540 object_ids = panel_g_slist_make_unique (object_ids,
1541 (GCompareFunc) g_strcmp0,
1542 TRUE(!(0)));
1543
1544 existing_applets = mate_panel_applet_list_applets ();
1545
1546 for (l = existing_applets; l; l = l->next) {
1547 AppletInfo *info = l->data;
1548 sublist = g_slist_prepend (sublist, info);
1549 }
1550
1551 panel_profile_load_added_ids (sublist,
1552 object_ids,
1553 (PanelProfileGetIdFunc) mate_panel_applet_get_id,
1554 (PanelProfileLoadFunc) panel_profile_load_object,
1555 (PanelProfileOnLoadQueue) mate_panel_applet_on_load_queue);
1556
1557 panel_profile_delete_removed_ids (PANEL_GSETTINGS_OBJECTS,
1558 sublist,
1559 object_ids,
1560 (PanelProfileGetIdFunc) mate_panel_applet_get_id,
1561 (PanelProfileDestroyFunc) panel_profile_destroy_object);
1562
1563 g_slist_free (sublist);
1564 g_slist_free_full (object_ids, g_free);
1565
1566 mate_panel_applet_load_queued_applets (FALSE(0));
1567}
1568
1569static void
1570panel_profile_object_id_list_notify (GSettings *settings,
1571 gchar *key,
1572 gpointer data)
1573{
1574 gchar **objects;
1575 objects = g_settings_get_strv (settings, key);
1576 panel_profile_object_id_list_update (objects);
1577 g_strfreev (objects);
1578}
1579
1580static void
1581panel_profile_load_list (GSettings *settings,
1582 PanelGSettingsKeyType type,
1583 PanelProfileLoadFunc load_handler,
1584 GCallback notify_handler)
1585{
1586 const gchar *key = key_from_type (type);
1587 gchar *changed_signal;
1588 gchar **list;
1589
1590 changed_signal = g_strdup_printf ("changed::%s", key);
1591 g_signal_connect (settings, changed_signal, G_CALLBACK (notify_handler), NULL)g_signal_connect_data ((settings), (changed_signal), (((GCallback
) (notify_handler))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
1592 g_free (changed_signal);
1593
1594 list = g_settings_get_strv (settings, key);
1595
1596 if (list) {
1597 for (gint i = 0; list[i]; i++) {
1598 load_handler (list[i]);
1599 }
1600
1601 g_strfreev (list);
1602 }
1603}
1604
1605static void
1606panel_profile_ensure_toplevel_per_screen ()
1607{
1608 GSList *toplevels;
1609 GSList *empty_screens = NULL((void*)0);
1610 GSList *l;
1611 GdkDisplay *display;
1612 GdkScreen *screen;
1613
1614 toplevels = panel_toplevel_list_toplevels ();
1615
1616 display = gdk_display_get_default ();
1617
1618 screen = gdk_display_get_default_screen (display);
1619
1620 for (l = toplevels; l; l = l->next)
1621 if (gtk_window_get_screen (l->data) == screen)
1622 break;
1623
1624 if (!l)
1625 empty_screens = g_slist_prepend (empty_screens, screen);
1626
1627 for (l = empty_screens; l; l = l->next)
1628 panel_layout_apply_default_from_gkeyfile (l->data);
1629
1630 g_slist_free (empty_screens);
1631}
1632
1633void
1634panel_profile_settings_load (void)
1635{
1636 profile_settings = g_settings_new ("org.mate.panel");
1637}
1638
1639void
1640panel_profile_load (void)
1641{
1642 panel_profile_settings_load();
1643
1644 panel_profile_load_list (profile_settings,
1645 PANEL_GSETTINGS_TOPLEVELS,
1646 (PanelProfileLoadFunc)panel_profile_load_and_show_toplevel_startup,
1647 G_CALLBACK (panel_profile_toplevel_id_list_notify)((GCallback) (panel_profile_toplevel_id_list_notify)));
1648 panel_profile_load_list (profile_settings,
1649 PANEL_GSETTINGS_OBJECTS,
1650 (PanelProfileLoadFunc)panel_profile_load_object,
1651 G_CALLBACK (panel_profile_object_id_list_notify)((GCallback) (panel_profile_object_id_list_notify)));
1652
1653 panel_profile_ensure_toplevel_per_screen ();
1654
1655 mate_panel_applet_load_queued_applets (TRUE(!(0)));
1656}
1657
1658static gboolean
1659get_program_listing_setting (const char *key)
1660{
1661 gboolean retval;
1662 retval = g_settings_get_boolean (profile_settings, key);
1663 return retval;
1664}
1665
1666gboolean
1667panel_profile_get_show_program_list (void)
1668{
1669 return get_program_listing_setting ("show-program-list");
1670}
1671
1672gboolean
1673panel_profile_get_enable_program_list (void)
1674{
1675 return get_program_listing_setting ("enable-program-list");
1676}
1677
1678gboolean
1679panel_profile_get_enable_autocompletion (void)
1680{
1681 return get_program_listing_setting ("enable-autocompletion");
1682}
1683
1684void
1685panel_profile_set_show_program_list (gboolean show_program_list)
1686{
1687 g_settings_set_boolean (profile_settings, "show-program-list", show_program_list);
1688}
1689
1690gboolean
1691panel_profile_is_writable_show_program_list (void)
1692{
1693 return g_settings_is_writable (profile_settings, "show-program-list");
1694}
1695
1696gboolean
1697panel_profile_can_be_moved_freely (PanelToplevel *toplevel)
1698{
1699 if (panel_lockdown_get_locked_down () ||
1700 !g_settings_is_writable (toplevel->settings, PANEL_TOPLEVEL_ORIENTATION_KEY"orientation"))
1701 return FALSE(0);
1702
1703 if (!g_settings_is_writable (toplevel->settings, PANEL_TOPLEVEL_SCREEN_KEY"screen"))
1704 return FALSE(0);
1705
1706 if (!g_settings_is_writable (toplevel->settings, PANEL_TOPLEVEL_MONITOR_KEY"monitor"))
1707 return FALSE(0);
1708
1709 /* For expanded panels we don't really have to check
1710 x and y */
1711 if (panel_toplevel_get_expand (toplevel))
1712 return TRUE(!(0));
1713
1714 if (!g_settings_is_writable (toplevel->settings, PANEL_TOPLEVEL_X_KEY"x"))
1715 return FALSE(0);
1716 if (!g_settings_is_writable (toplevel->settings, PANEL_TOPLEVEL_X_RIGHT_KEY"x-right"))
1717 return FALSE(0);
1718 if (!g_settings_is_writable (toplevel->settings, PANEL_TOPLEVEL_X_CENTERED_KEY"x-centered"))
1719 return FALSE(0);
1720
1721 if (!g_settings_is_writable (toplevel->settings, PANEL_TOPLEVEL_Y_KEY"y"))
1722 return FALSE(0);
1723 if (!g_settings_is_writable (toplevel->settings, PANEL_TOPLEVEL_Y_BOTTOM_KEY"y-bottom"))
1724 return FALSE(0);
1725 if (!g_settings_is_writable (toplevel->settings, PANEL_TOPLEVEL_Y_CENTERED_KEY"y-centered"))
1726 return FALSE(0);
1727
1728 return TRUE(!(0));
1729}
diff --git a/2024-06-18-172109-13286-1@e182420b844f_master/report-890f6c.html b/2024-06-18-172109-13286-1@e182420b844f_master/report-890f6c.html new file mode 100644 index 00000000..4c01020b --- /dev/null +++ b/2024-06-18-172109-13286-1@e182420b844f_master/report-890f6c.html @@ -0,0 +1,6243 @@ + + + +panel-toplevel.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:mate-panel/panel-toplevel.c
Warning:line 2554, column 2
Value stored to 'orientation' is never read
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name panel-toplevel.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/mate-panel -fcoverage-compilation-dir=/rootdir/mate-panel -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I .. -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/startup-notification-1.0 -I /usr/include/mate-menus -I /usr/include/gio-unix-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/dconf -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/dconf -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I . -I . -I ../mate-panel -I ../mate-panel/mate-submodules -I ../mate-panel/libpanel-util -D MATELOCALEDIR="/usr/local/share/locale" -D PANELDATADIR="/usr/local/share/mate-panel" -I /usr/include/gtk-layer-shell -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/gtk-3.0 -I /usr/include/cloudproviders -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/atk-1.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/gio-unix-2.0 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -D PANEL_MODULES_DIR="/usr/local/lib/mate-panel/modules" -D MATEMENU_I_KNOW_THIS_IS_UNSTABLE -I /usr/include/gtk-layer-shell -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/gtk-3.0 -I /usr/include/cloudproviders -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/atk-1.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/gio-unix-2.0 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-18-172109-13286-1 -x c panel-toplevel.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
2 *
3 * panel-toplevel.c: The panel's toplevel window object.
4 *
5 * Copyright (C) 2003 Sun Microsystems, Inc.
6 * Copyright (C) 2004 Rob Adams
7 * Copyright (C) 2012-2021 MATE Developers
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of the
12 * License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
22 * 02110-1301, USA.
23 *
24 * Authors:
25 * Mark McLoughlin <mark@skynet.ie>
26 */
27
28#include <config.h>
29
30#include "panel-toplevel.h"
31
32#include <stdlib.h>
33#include <string.h>
34
35#include <gtk/gtk.h>
36#include <gdk/gdkkeysyms.h>
37#include <glib/gi18n.h>
38
39#ifdef HAVE_X111
40#include <gdk/gdkx.h>
41#endif
42
43#include "panel-util.h"
44#include "panel-profile.h"
45#include "panel-frame.h"
46#include "panel-multimonitor.h"
47#include "panel-a11y.h"
48#include "panel-typebuiltins.h"
49#include "panel-marshal.h"
50#include "panel-widget.h"
51#include "panel-bindings.h"
52#include "panel-config-global.h"
53#include "panel-lockdown.h"
54#include "panel-schemas.h"
55
56#ifdef HAVE_X111
57#include "xstuff.h"
58#include "panel-xutils.h"
59#include "panel-struts.h"
60#endif
61#ifdef HAVE_WAYLAND1
62#include "wayland-backend.h"
63#endif
64
65#define DEFAULT_SIZE48 48
66#define DEFAULT_AUTO_HIDE_SIZE1 1
67#define DEFAULT_HIDE_DELAY300 300
68#define DEFAULT_UNHIDE_DELAY100 100
69#define DEFAULT_DND_THRESHOLD8 8
70#define MINIMUM_WIDTH100 100
71#define MAXIMUM_SIZE_SCREEN_RATIO5 5
72#define SNAP_TOLERANCE_FACTOR6 6
73#define DEFAULT_ARROW_SIZE20 20
74#define HANDLE_SIZE10 10
75#define N_ATTACH_TOPLEVEL_SIGNALS5 5
76#define N_ATTACH_WIDGET_SIGNALS5 5
77
78typedef enum {
79 PANEL_GRAB_OP_NONE,
80 PANEL_GRAB_OP_MOVE,
81 PANEL_GRAB_OP_RESIZE,
82 PANEL_GRAB_OP_RESIZE_UP,
83 PANEL_GRAB_OP_RESIZE_DOWN,
84 PANEL_GRAB_OP_RESIZE_LEFT,
85 PANEL_GRAB_OP_RESIZE_RIGHT
86} PanelGrabOpType;
87
88struct _PanelToplevelPrivate {
89 gchar *settings_path;
90
91 gboolean expand;
92 PanelOrientation orientation;
93 int size;
94 gint scale;
95
96 /* relative to the monitor origin */
97 int x;
98 int y;
99 /* relative to the bottom right corner, -1 to ignore and use x, y*/
100 int x_right;
101 int y_bottom;
102
103 int monitor;
104 /* this is used when the configured monitor is missing. We keep it so
105 * we can move the toplevel to the right monitor when it becomes
106 * available */
107 int configured_monitor;
108
109 int hide_delay;
110 int unhide_delay;
111 int auto_hide_size;
112 PanelAnimationSpeed animation_speed;
113
114 int snap_tolerance;
115 GtkSettings *gtk_settings;
116
117 PanelState state;
118
119 char *name;
120 char *description;
121
122 guint hide_timeout;
123 guint unhide_timeout;
124
125 GdkRectangle geometry;
126 PanelFrameEdge edges;
127
128 int original_width;
129 int original_height;
130
131 PanelGrabOpType grab_op;
132
133 /* The offset within the panel from which the panel
134 * drag was initiated relative to the screen origin.
135 */
136 int drag_offset_x;
137 int drag_offset_y;
138
139 /* Saved state before for cancelled grab op */
140 int orig_monitor;
141 int orig_x;
142 int orig_y;
143 int orig_x_right;
144 int orig_y_bottom;
145 int orig_size;
146 int orig_orientation;
147
148 /* relative to the monitor origin */
149 int animation_end_x;
150 int animation_end_y;
151 int animation_end_width;
152 int animation_end_height;
153 gint64 animation_start_time; /* monotonic start time in microseconds */
154 GTimeSpan animation_duration_time; /* monotonic duration time in microseconds */
155 guint animation_timeout;
156
157 PanelWidget *panel_widget;
158 PanelFrame *inner_frame;
159 GtkWidget *grid;
160 GtkWidget *hide_button_top;
161 GtkWidget *hide_button_bottom;
162 GtkWidget *hide_button_left;
163 GtkWidget *hide_button_right;
164
165 PanelToplevel *attach_toplevel;
166 gulong attach_toplevel_signals [N_ATTACH_TOPLEVEL_SIGNALS5];
167 GtkWidget *attach_widget;
168 gulong attach_widget_signals [N_ATTACH_WIDGET_SIGNALS5];
169 gint n_autohide_disablers;
170
171 guint auto_hide : 1;
172 guint animate : 1;
173 guint buttons_enabled : 1;
174 guint arrows_enabled : 1;
175
176 /* The co-ordinates are relative to center screen */
177 guint x_centered : 1;
178 guint y_centered : 1;
179
180 /* The panel is not lined up with th screen edge */
181 guint floating : 1;
182
183 /* We are currently animating a hide/show */
184 guint animating : 1;
185
186 /* This is a keyboard initiated grab operation */
187 guint grab_is_keyboard : 1;
188
189 /* The x-y co-ordinates temporarily specify the panel center.
190 * This is used when the panel is rotating, because the width/height
191 * of the toplevel might change, so we need to compute new values for
192 * those. */
193 guint position_centered : 1;
194
195 /* The toplevel is "attached" to another widget */
196 guint attached : 1;
197
198 /* Hidden temporarily because the attach_toplevel was hidden */
199 guint attach_hidden : 1;
200
201 /* More saved grab op state */
202 guint orig_x_centered : 1;
203 guint orig_y_centered : 1;
204
205 /* flag to see if we have already done geometry updating,
206 if not then we're still loading and can ignore many things */
207 guint updated_geometry_initial : 1;
208 /* flag to see if we have done the initial animation */
209 guint initial_animation_done : 1;
210};
211
212enum {
213 HIDE_SIGNAL,
214 UNHIDE_SIGNAL,
215 POPUP_PANEL_MENU_SIGNAL,
216 TOGGLE_EXPAND_SIGNAL,
217 EXPAND_SIGNAL,
218 UNEXPAND_SIGNAL,
219 TOGGLE_HIDDEN_SIGNAL,
220 BEGIN_MOVE_SIGNAL,
221 BEGIN_RESIZE_SIGNAL,
222 LAST_SIGNAL
223};
224
225enum {
226 PROP_0,
227 PROP_NAME,
228 PROP_SETTINGS_PATH,
229 PROP_EXPAND,
230 PROP_ORIENTATION,
231 PROP_SIZE,
232 PROP_X,
233 PROP_X_RIGHT,
234 PROP_X_CENTERED,
235 PROP_Y,
236 PROP_Y_BOTTOM,
237 PROP_Y_CENTERED,
238 PROP_MONITOR,
239 PROP_AUTOHIDE,
240 PROP_HIDE_DELAY,
241 PROP_UNHIDE_DELAY,
242 PROP_AUTOHIDE_SIZE,
243 PROP_ANIMATE,
244 PROP_ANIMATION_SPEED,
245 PROP_BUTTONS_ENABLED,
246 PROP_ARROWS_ENABLED
247};
248
249G_DEFINE_TYPE_WITH_PRIVATE (PanelToplevel, panel_toplevel, GTK_TYPE_WINDOW)static void panel_toplevel_init (PanelToplevel *self); static
void panel_toplevel_class_init (PanelToplevelClass *klass); static
GType panel_toplevel_get_type_once (void); static gpointer panel_toplevel_parent_class
= ((void*)0); static gint PanelToplevel_private_offset; static
void panel_toplevel_class_intern_init (gpointer klass) { panel_toplevel_parent_class
= g_type_class_peek_parent (klass); if (PanelToplevel_private_offset
!= 0) g_type_class_adjust_private_offset (klass, &PanelToplevel_private_offset
); panel_toplevel_class_init ((PanelToplevelClass*) klass); }
__attribute__ ((__unused__)) static inline gpointer panel_toplevel_get_instance_private
(PanelToplevel *self) { return (((gpointer) ((guint8*) (self
) + (glong) (PanelToplevel_private_offset)))); } GType panel_toplevel_get_type
(void) { static GType static_g_define_type_id = 0; if ((__extension__
({ _Static_assert (sizeof *(&static_g_define_type_id) ==
sizeof (gpointer), "Expression evaluates to false"); (void) (
0 ? (gpointer) * (&static_g_define_type_id) : ((void*)0))
; (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter_pointer (
&static_g_define_type_id)); })) ) { GType g_define_type_id
= panel_toplevel_get_type_once (); (__extension__ ({ _Static_assert
(sizeof *(&static_g_define_type_id) == sizeof (gpointer)
, "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id
) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer
((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id
)); })) ; } return static_g_define_type_id; } __attribute__ (
(__noinline__)) static GType panel_toplevel_get_type_once (void
) { GType g_define_type_id = g_type_register_static_simple ((
gtk_window_get_type ()), g_intern_static_string ("PanelToplevel"
), sizeof (PanelToplevelClass), (GClassInitFunc)(void (*)(void
)) panel_toplevel_class_intern_init, sizeof (PanelToplevel), (
GInstanceInitFunc)(void (*)(void)) panel_toplevel_init, (GTypeFlags
) 0); { {{ PanelToplevel_private_offset = g_type_add_instance_private
(g_define_type_id, sizeof (PanelToplevelPrivate)); };} } return
g_define_type_id; }
250
251static guint toplevel_signals[LAST_SIGNAL] = {0};
252static GSList* toplevel_list = NULL((void*)0);
253
254static void panel_toplevel_calculate_animation_end_geometry(PanelToplevel *toplevel);
255
256static void panel_toplevel_update_monitor(PanelToplevel* toplevel);
257static void panel_toplevel_set_monitor_internal(PanelToplevel* toplevel, int monitor, gboolean force_resize);
258
259static void panel_toplevel_drag_threshold_changed (PanelToplevel *toplevel);
260
261static void
262update_style_classes (PanelToplevel *toplevel)
263{
264 GtkStyleContext *context;
265
266 context = gtk_widget_get_style_context (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
267
268 /*ensure the panel BG can always be themed*/
269 /*Without this gtk3.19/20 cannot set the BG color and resetting the bg to system is not immediately applied*/
270 gtk_style_context_add_class(context,"gnome-panel-menu-bar");
271 gtk_style_context_add_class(context,"mate-panel-menu-bar");
272
273 gtk_style_context_remove_class (context, GTK_STYLE_CLASS_HORIZONTAL"horizontal");
274 gtk_style_context_remove_class (context, GTK_STYLE_CLASS_VERTICAL"vertical");
275 gtk_style_context_remove_class (context, GTK_STYLE_CLASS_RIGHT"right");
276 gtk_style_context_remove_class (context, GTK_STYLE_CLASS_LEFT"left");
277 gtk_style_context_remove_class (context, GTK_STYLE_CLASS_TOP"top");
278 gtk_style_context_remove_class (context, GTK_STYLE_CLASS_BOTTOM"bottom");
279
280 switch (toplevel->priv->orientation) {
281 case PANEL_ORIENTATION_TOP:
282 gtk_style_context_add_class (context, GTK_STYLE_CLASS_HORIZONTAL"horizontal");
283 gtk_style_context_add_class (context, GTK_STYLE_CLASS_TOP"top");
284 break;
285
286 case PANEL_ORIENTATION_LEFT:
287 gtk_style_context_add_class (context, GTK_STYLE_CLASS_VERTICAL"vertical");
288 gtk_style_context_add_class (context, GTK_STYLE_CLASS_LEFT"left");
289 break;
290
291 case PANEL_ORIENTATION_BOTTOM:
292 gtk_style_context_add_class (context, GTK_STYLE_CLASS_HORIZONTAL"horizontal");
293 gtk_style_context_add_class (context, GTK_STYLE_CLASS_BOTTOM"bottom");
294 break;
295
296 case PANEL_ORIENTATION_RIGHT:
297 gtk_style_context_add_class (context, GTK_STYLE_CLASS_VERTICAL"vertical");
298 gtk_style_context_add_class (context, GTK_STYLE_CLASS_RIGHT"right");
299 break;
300
301 default:
302 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 302, ((const char*) (__func__)), ((void*)0)); } while (0)
;
303 break;
304 }
305}
306
307GSList* panel_toplevel_list_toplevels(void)
308{
309 return toplevel_list;
310}
311
312/* Is this the last un-attached toplevel? */
313gboolean panel_toplevel_is_last_unattached(PanelToplevel* toplevel)
314{
315 GSList* l;
316
317 if (panel_toplevel_get_is_attached(toplevel))
318 {
319 return FALSE(0);
320 }
321
322 for (l = toplevel_list; l; l = l->next)
323 {
324 PanelToplevel* t = l->data;
325
326 if (t != toplevel && !panel_toplevel_get_is_attached(t))
327 {
328 return FALSE(0);
329 }
330 }
331
332 return TRUE(!(0));
333}
334
335static void panel_toplevel_get_monitor_geometry(PanelToplevel* toplevel, GdkRectangle *geom)
336{
337 g_return_if_fail(PANEL_IS_TOPLEVEL(toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL(toplevel)"); return; } } while
(0)
;
338 g_return_if_fail(geom)do { if ((geom)) { } else { g_return_if_fail_warning (((gchar
*) 0), ((const char*) (__func__)), "geom"); return; } } while
(0)
;
339
340 geom->x = panel_multimonitor_x(toplevel->priv->monitor);
341 geom->y = panel_multimonitor_y(toplevel->priv->monitor);
342 geom->width = panel_multimonitor_width(toplevel->priv->monitor);
343 geom->height = panel_multimonitor_height(toplevel->priv->monitor);
344}
345
346static GdkCursorType panel_toplevel_grab_op_cursor(PanelToplevel* toplevel, PanelGrabOpType grab_op)
347{
348 GdkCursorType retval = -1;
349
350 switch (grab_op) {
351 case PANEL_GRAB_OP_MOVE:
352 case PANEL_GRAB_OP_RESIZE:
353 if (toplevel->priv->grab_is_keyboard)
354 retval = GDK_CROSS;
355 else
356 retval = GDK_FLEUR;
357 break;
358 case PANEL_GRAB_OP_RESIZE_UP:
359 retval = GDK_TOP_SIDE;
360 break;
361 case PANEL_GRAB_OP_RESIZE_DOWN:
362 retval = GDK_BOTTOM_SIDE;
363 break;
364 case PANEL_GRAB_OP_RESIZE_LEFT:
365 retval = GDK_LEFT_SIDE;
366 break;
367 case PANEL_GRAB_OP_RESIZE_RIGHT:
368 retval = GDK_RIGHT_SIDE;
369 break;
370 default:
371 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 371, ((const char*) (__func__)), ((void*)0)); } while (0)
;
372 break;
373 }
374
375 return retval;
376}
377
378#ifdef HAVE_X111
379static void panel_toplevel_init_resize_drag_offsets(PanelToplevel* toplevel, PanelGrabOpType grab_op)
380{
381 g_assert (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel))))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((gtk_widget_get_display (((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((toplevel)), ((gtk_widget_get_type ()))))
))))); GType __t = ((gdk_x11_display_get_type())); gboolean __r
; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))) ; else
g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c", 381
, ((const char*) (__func__)), "GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel)))"
); } while (0)
;
382
383 toplevel->priv->drag_offset_x = 0;
384 toplevel->priv->drag_offset_y = 0;
385
386 switch (grab_op) {
387 case PANEL_GRAB_OP_RESIZE_DOWN:
388 toplevel->priv->drag_offset_y = toplevel->priv->geometry.y;
389 break;
390 case PANEL_GRAB_OP_RESIZE_UP:
391 toplevel->priv->drag_offset_y =
392 toplevel->priv->geometry.y + toplevel->priv->geometry.height;
393 break;
394 case PANEL_GRAB_OP_RESIZE_RIGHT:
395 toplevel->priv->drag_offset_x = toplevel->priv->geometry.x;
396 break;
397 case PANEL_GRAB_OP_RESIZE_LEFT:
398 toplevel->priv->drag_offset_x =
399 toplevel->priv->geometry.x + toplevel->priv->geometry.width;
400 break;
401 default:
402 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 402, ((const char*) (__func__)), ((void*)0)); } while (0)
;
403 break;
404 }
405}
406
407static void panel_toplevel_warp_pointer(PanelToplevel* toplevel)
408{
409 GtkWidget *widget;
410 GdkRectangle geometry;
411 int x, y;
412
413 widget = GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
;
414 g_return_if_fail (GDK_IS_X11_DISPLAY (gtk_widget_get_display (widget)))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((gtk_widget_get_display (widget))); GType __t = ((gdk_x11_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0
), ((const char*) (__func__)), "GDK_IS_X11_DISPLAY (gtk_widget_get_display (widget))"
); return; } } while (0)
;
415
416 geometry = toplevel->priv->geometry;
417
418 x = y = 0;
419
420 switch (toplevel->priv->grab_op) {
421 case PANEL_GRAB_OP_MOVE:
422 case PANEL_GRAB_OP_RESIZE:
423 x = (geometry.width / 2);
424 y = (geometry.height / 2);
425 break;
426 case PANEL_GRAB_OP_RESIZE_UP:
427 x = (geometry.width / 2);
428 break;
429 case PANEL_GRAB_OP_RESIZE_DOWN:
430 x = (geometry.width / 2);
431 y = geometry.height;
432 break;
433 case PANEL_GRAB_OP_RESIZE_LEFT:
434 y = (geometry.height / 2);
435 break;
436 case PANEL_GRAB_OP_RESIZE_RIGHT:
437 x = geometry.width;
438 y = (geometry.height / 2);
439 break;
440 default:
441 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 441, ((const char*) (__func__)), ((void*)0)); } while (0)
;
442 break;
443 }
444
445 if (toplevel->priv->grab_op == PANEL_GRAB_OP_MOVE ||
446 toplevel->priv->grab_op == PANEL_GRAB_OP_RESIZE) {
447 toplevel->priv->drag_offset_x = x;
448 toplevel->priv->drag_offset_y = y;
449 } else
450 panel_toplevel_init_resize_drag_offsets (toplevel, toplevel->priv->grab_op);
451
452 panel_warp_pointer (gtk_widget_get_window (widget), x, y);
453}
454#endif /* HAVE_X11 */
455
456static void panel_toplevel_begin_attached_move(PanelToplevel* toplevel, gboolean is_keyboard, guint32 time_)
457{
458 PanelWidget *attached_panel_widget;
459
460 attached_panel_widget = panel_toplevel_get_panel_widget (toplevel->priv->attach_toplevel);
461
462 panel_widget_applet_drag_start (attached_panel_widget,
463 toplevel->priv->attach_widget,
464 is_keyboard ? PW_DRAG_OFF_CENTER-2 : PW_DRAG_OFF_CURSOR-1,
465 time_);
466}
467
468static void panel_toplevel_begin_grab_op(PanelToplevel* toplevel, PanelGrabOpType op_type, gboolean grab_keyboard, guint32 time_)
469{
470 GtkWidget *widget;
471 GdkWindow *window;
472 GdkCursorType cursor_type;
473 GdkCursor *cursor;
474 GdkDisplay *display;
475 GdkSeat *seat;
476 GdkSeatCapabilities capabilities;
477
478 if (toplevel->priv->state != PANEL_STATE_NORMAL ||
479 toplevel->priv->grab_op != PANEL_GRAB_OP_NONE)
480 return;
481
482 if (panel_lockdown_get_locked_down ())
483 return;
484
485 /* If any of the position/orientation are not writable,
486 then we can't really move freely */
487 if (op_type == PANEL_GRAB_OP_MOVE &&
488 ! panel_profile_can_be_moved_freely (toplevel))
489 return;
490
491 /* If size is not writable, then we can't resize */
492 if ((op_type == PANEL_GRAB_OP_RESIZE ||
493 op_type == PANEL_GRAB_OP_RESIZE_UP ||
494 op_type == PANEL_GRAB_OP_RESIZE_DOWN ||
495 op_type == PANEL_GRAB_OP_RESIZE_LEFT ||
496 op_type == PANEL_GRAB_OP_RESIZE_RIGHT) &&
497 ! panel_profile_key_is_writable (toplevel, PANEL_TOPLEVEL_SIZE_KEY"size"))
498 return;
499
500 if (toplevel->priv->attached && op_type == PANEL_GRAB_OP_MOVE) {
501 panel_toplevel_begin_attached_move (toplevel, grab_keyboard, time_);
502 return;
503 }
504
505 widget = GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
;
506 window = gtk_widget_get_window (widget);
507
508 toplevel->priv->grab_op = op_type;
509 toplevel->priv->grab_is_keyboard = (grab_keyboard != FALSE(0));
510
511 toplevel->priv->orig_monitor = toplevel->priv->monitor;
512 toplevel->priv->orig_x = toplevel->priv->x;
513 toplevel->priv->orig_x_right = toplevel->priv->x_right;
514 toplevel->priv->orig_x_centered = toplevel->priv->x_centered;
515 toplevel->priv->orig_y = toplevel->priv->y;
516 toplevel->priv->orig_y_bottom = toplevel->priv->y_bottom;
517 toplevel->priv->orig_y_centered = toplevel->priv->y_centered;
518 toplevel->priv->orig_size = toplevel->priv->size;
519 toplevel->priv->orig_orientation = toplevel->priv->orientation;
520
521 gtk_grab_add (widget);
522
523#ifdef HAVE_X111
524 if (GDK_IS_X11_DISPLAY (gtk_widget_get_display (widget))(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gtk_widget_get_display (widget))); GType __t = ((gdk_x11_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
&&
525 toplevel->priv->grab_is_keyboard) {
526 panel_toplevel_warp_pointer (toplevel);
527 }
528#endif /* HAVE_X11 */
529
530 cursor_type = panel_toplevel_grab_op_cursor (
531 toplevel, toplevel->priv->grab_op);
532
533 cursor = gdk_cursor_new_for_display (gdk_display_get_default (),
534 cursor_type);
535 display = gdk_window_get_display (window);
536 seat = gdk_display_get_default_seat (display);
537 capabilities = GDK_SEAT_CAPABILITY_POINTER;
538 if (grab_keyboard)
539 capabilities |= GDK_SEAT_CAPABILITY_KEYBOARD;
540
541 gdk_seat_grab (seat, window, capabilities, FALSE(0), cursor,
542 NULL((void*)0), NULL((void*)0), NULL((void*)0));
543
544 g_object_unref (cursor);
545}
546
547static void panel_toplevel_end_grab_op (PanelToplevel* toplevel, guint32 time_)
548{
549 GtkWidget *widget;
550 GdkDisplay *display;
551 GdkSeat *seat;
552
553 g_return_if_fail (toplevel->priv->grab_op != PANEL_GRAB_OP_NONE)do { if ((toplevel->priv->grab_op != PANEL_GRAB_OP_NONE
)) { } else { g_return_if_fail_warning (((gchar*) 0), ((const
char*) (__func__)), "toplevel->priv->grab_op != PANEL_GRAB_OP_NONE"
); return; } } while (0)
;
554
555 widget = GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
;
556
557 toplevel->priv->grab_op = PANEL_GRAB_OP_NONE;
558 toplevel->priv->grab_is_keyboard = FALSE(0);
559
560 gtk_grab_remove (widget);
561
562 display = gtk_widget_get_display (widget);
563 seat = gdk_display_get_default_seat (display);
564
565 gdk_seat_ungrab (seat);
566}
567
568static void panel_toplevel_cancel_grab_op(PanelToplevel* toplevel, guint32 time_)
569{
570 panel_toplevel_set_orientation (toplevel, toplevel->priv->orig_orientation);
571 panel_toplevel_set_monitor (toplevel, toplevel->priv->orig_monitor);
572 panel_toplevel_set_size (toplevel, toplevel->priv->orig_size);
573 panel_toplevel_set_x (toplevel,
574 toplevel->priv->orig_x,
575 toplevel->priv->orig_x_right,
576 toplevel->priv->orig_x_centered);
577 panel_toplevel_set_y (toplevel,
578 toplevel->priv->orig_y,
579 toplevel->priv->orig_y_bottom,
580 toplevel->priv->orig_y_centered);
581}
582
583static void panel_toplevel_resize_to_pointer(PanelToplevel* toplevel, int x, int y)
584{
585 int new_size;
586 int new_x, new_y;
587 int new_x_right, new_y_bottom;
588 int new_x_centered, new_y_centered;
589 GdkRectangle monitor_geom;
590
591 new_size = toplevel->priv->size;
592 new_x = toplevel->priv->x;
593 new_y = toplevel->priv->y;
594 new_x_right = toplevel->priv->x_right;
595 new_y_bottom = toplevel->priv->y_bottom;
596 new_x_centered = toplevel->priv->x_centered;
597 new_y_centered = toplevel->priv->y_centered;
598
599 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
600
601 switch (toplevel->priv->grab_op) {
602 case PANEL_GRAB_OP_RESIZE_UP:
603 new_size = toplevel->priv->drag_offset_y - y;
604 new_size = CLAMP (new_size, 0, monitor_geom.height / 4)(((new_size) > (monitor_geom.height / 4)) ? (monitor_geom.
height / 4) : (((new_size) < (0)) ? (0) : (new_size)))
;
605 new_y -= (new_size - toplevel->priv->size);
606 if (!toplevel->priv->y_centered && (new_y + new_size / 2) > monitor_geom.height / 2)
607 new_y_bottom = monitor_geom.height - (new_y + new_size);
608 else
609 new_y_bottom = -1;
610 break;
611 case PANEL_GRAB_OP_RESIZE_DOWN:
612 new_size = y - toplevel->priv->drag_offset_y;
613 new_size = CLAMP (new_size, 0, monitor_geom.height / 4)(((new_size) > (monitor_geom.height / 4)) ? (monitor_geom.
height / 4) : (((new_size) < (0)) ? (0) : (new_size)))
;
614 if (!toplevel->priv->y_centered && (new_y + new_size / 2) > monitor_geom.height / 2)
615 new_y_bottom = monitor_geom.height - (new_y + new_size);
616 else
617 new_y_bottom = -1;
618 break;
619 case PANEL_GRAB_OP_RESIZE_LEFT:
620 new_size = toplevel->priv->drag_offset_x - x;
621 new_size = CLAMP (new_size, 0, monitor_geom.width / 4)(((new_size) > (monitor_geom.width / 4)) ? (monitor_geom.width
/ 4) : (((new_size) < (0)) ? (0) : (new_size)))
;
622 new_x -= (new_size - toplevel->priv->size);
623 if (!toplevel->priv->x_centered && (new_x + new_size / 2) > monitor_geom.width / 2)
624 new_x_right = monitor_geom.width - (new_x + new_size);
625 else
626 new_x_right = -1;
627 break;
628 case PANEL_GRAB_OP_RESIZE_RIGHT:
629 new_size = x - toplevel->priv->drag_offset_x;
630 new_size = CLAMP (new_size, 0, monitor_geom.width / 4)(((new_size) > (monitor_geom.width / 4)) ? (monitor_geom.width
/ 4) : (((new_size) < (0)) ? (0) : (new_size)))
;
631 if (!toplevel->priv->x_centered && (new_x + new_size / 2) > monitor_geom.width / 2)
632 new_x_right = monitor_geom.width - (new_x + new_size);
633 else
634 new_x_right = -1;
635 break;
636 default:
637 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 637, ((const char*) (__func__)), ((void*)0)); } while (0)
;
638 break;
639 }
640
641 if (new_size == 0)
642 return;
643
644 panel_toplevel_set_x (toplevel, new_x, new_x_right, new_x_centered);
645 panel_toplevel_set_y (toplevel, new_y, new_y_bottom, new_y_centered);
646 panel_toplevel_set_size (toplevel, new_size);
647}
648
649/* this is called for expanded panels that are dragged around */
650static void panel_toplevel_calc_new_orientation(PanelToplevel* toplevel, int pointer_x, int pointer_y)
651{
652 PanelOrientation new_orientation;
653 int hborder, vborder;
654 int monitor;
655 int monitor_width, monitor_height;
656 int new_x, new_y;
657
658 monitor = panel_multimonitor_get_monitor_at_point (pointer_x, pointer_y);
659
660 if (toplevel->priv->geometry.height < toplevel->priv->geometry.width)
661 vborder = hborder = (3 * toplevel->priv->geometry.height) >> 1;
662 else
663 vborder = hborder = (3 * toplevel->priv->geometry.width) >> 1;
664
665 new_x = pointer_x - panel_multimonitor_x (monitor);
666 new_y = pointer_y - panel_multimonitor_y (monitor);
667 monitor_width = panel_multimonitor_width (monitor);
668 monitor_height = panel_multimonitor_height (monitor);
669
670 new_orientation = toplevel->priv->orientation;
671
672 switch (toplevel->priv->orientation) {
673 case PANEL_ORIENTATION_TOP:
674 if (new_y > (monitor_height - hborder))
675 new_orientation = PANEL_ORIENTATION_BOTTOM;
676
677 else if (new_y > hborder) {
678 if (new_x > (monitor_width - vborder))
679 new_orientation = PANEL_ORIENTATION_RIGHT;
680 else if (new_x < vborder)
681 new_orientation = PANEL_ORIENTATION_LEFT;
682 }
683 break;
684 case PANEL_ORIENTATION_BOTTOM:
685 if (new_y < hborder)
686 new_orientation = PANEL_ORIENTATION_TOP;
687
688 else if (new_y < (monitor_height - hborder)) {
689 if (new_x > (monitor_width - vborder))
690 new_orientation = PANEL_ORIENTATION_RIGHT;
691 else if (new_x < vborder)
692 new_orientation = PANEL_ORIENTATION_LEFT;
693 }
694 break;
695 case PANEL_ORIENTATION_LEFT:
696 if (new_x > (monitor_width - vborder))
697 new_orientation = PANEL_ORIENTATION_RIGHT;
698
699 else if (new_x > vborder) {
700 if (new_y > (monitor_height - hborder))
701 new_orientation = PANEL_ORIENTATION_BOTTOM;
702 else if (new_y < hborder)
703 new_orientation = PANEL_ORIENTATION_TOP;
704 }
705 break;
706 case PANEL_ORIENTATION_RIGHT:
707 if (new_x < vborder)
708 new_orientation = PANEL_ORIENTATION_LEFT;
709
710 else if (new_x < (monitor_width - vborder)) {
711 if (new_y > (monitor_height - hborder))
712 new_orientation = PANEL_ORIENTATION_BOTTOM;
713 else if (new_y < hborder)
714 new_orientation = PANEL_ORIENTATION_TOP;
715 }
716 break;
717 default:
718 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 718, ((const char*) (__func__)), ((void*)0)); } while (0)
;
719 break;
720 }
721
722 panel_toplevel_set_monitor (toplevel, monitor);
723 panel_toplevel_set_orientation (toplevel, new_orientation);
724}
725
726static void panel_toplevel_move_to(PanelToplevel* toplevel, int new_x, int new_y)
727{
728 PanelOrientation new_orientation;
729 gboolean x_centered, y_centered;
730 GdkPoint display_min, display_max;
731 GdkRectangle monitor_geom;
732 int width, height;
733 int new_monitor;
734 int x, y, x_right, y_bottom;
735 int snap_tolerance;
736
737 panel_multimonitor_get_bounds (&display_min, &display_max);
738
739 width = toplevel->priv->geometry.width;
740 height = toplevel->priv->geometry.height;
741
742 snap_tolerance = toplevel->priv->snap_tolerance;
743
744 new_x = CLAMP (new_x, 0, display_max.x - width)(((new_x) > (display_max.x - width)) ? (display_max.x - width
) : (((new_x) < (0)) ? (0) : (new_x)))
;
745 new_y = CLAMP (new_y, 0, display_max.y - height)(((new_y) > (display_max.y - height)) ? (display_max.y - height
) : (((new_y) < (0)) ? (0) : (new_y)))
;
746
747 new_orientation = toplevel->priv->orientation;
748
749 if (new_x <= (display_min.x + snap_tolerance) &&
750 toplevel->priv->orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT))
751 new_orientation = PANEL_ORIENTATION_LEFT;
752
753 else if ((new_x + width) >= (display_max.x - snap_tolerance) &&
754 toplevel->priv->orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT))
755 new_orientation = PANEL_ORIENTATION_RIGHT;
756
757 if (new_y <= (display_min.y + snap_tolerance) &&
758 toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM))
759 new_orientation = PANEL_ORIENTATION_TOP;
760
761 else if ((new_y + height) >= (display_max.y - snap_tolerance) &&
762 toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM))
763 new_orientation = PANEL_ORIENTATION_BOTTOM;
764
765 new_monitor = panel_multimonitor_get_monitor_at_point (new_x, new_y);
766
767 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
768
769 x_centered = toplevel->priv->x_centered;
770 y_centered = toplevel->priv->y_centered;
771
772 x = new_x - panel_multimonitor_x (new_monitor);
773 y = new_y - panel_multimonitor_y (new_monitor);
774
775 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)) {
776 if (new_y <= display_min.y + snap_tolerance ||
777 new_y + height >= display_max.y - snap_tolerance)
778 x_centered = abs (x - ((monitor_geom.width - width) / 2))
779 <= snap_tolerance;
780 else
781 x_centered = FALSE(0);
782 } else {
783 if (new_x <= display_min.x + snap_tolerance ||
784 new_x + width >= display_max.x - snap_tolerance)
785 y_centered = abs (y - ((monitor_geom.height - height) / 2))
786 <= snap_tolerance;
787 else
788 y_centered = FALSE(0);
789 }
790
791 if (x_centered)
792 x = (monitor_geom.width - width) / 2;
793 if (y_centered)
794 y = (monitor_geom.height - height) / 2;
795
796 if (!x_centered && (x + width / 2) > monitor_geom.width / 2)
797 x_right = monitor_geom.width - (x + width);
798 else
799 x_right = -1;
800
801 if (!y_centered && (y + height / 2) > monitor_geom.height / 2)
802 y_bottom = monitor_geom.height - (y + height);
803 else
804 y_bottom = -1;
805
806 panel_toplevel_set_monitor (toplevel, new_monitor);
807 panel_toplevel_set_orientation (toplevel, new_orientation);
808 panel_toplevel_set_x (toplevel, x, x_right, x_centered);
809 panel_toplevel_set_y (toplevel, y, y_bottom, y_centered);
810}
811
812static void panel_toplevel_move_to_pointer(PanelToplevel* toplevel, int pointer_x, int pointer_y)
813{
814 int new_x, new_y;
815
816 new_x = pointer_x - toplevel->priv->drag_offset_x;
817 new_y = pointer_y - toplevel->priv->drag_offset_y;
818
819 panel_toplevel_move_to (toplevel, new_x, new_y);
820}
821
822static void panel_toplevel_rotate_to_pointer(PanelToplevel* toplevel, int pointer_x, int pointer_y)
823{
824 int x_diff, y_diff;
825 int x, y;
826 int snap_tolerance;
827
828 x = toplevel->priv->geometry.x;
829 y = toplevel->priv->geometry.y;
830 snap_tolerance = toplevel->priv->snap_tolerance;
831
832 x_diff = pointer_x - (x + toplevel->priv->geometry.width / 2);
833 y_diff = pointer_y - (y + toplevel->priv->geometry.height / 2);
834
835 if (((-y_diff > x_diff + snap_tolerance) && x_diff > 0 && y_diff < 0) ||
836 (( y_diff < x_diff + snap_tolerance) && x_diff < 0 && y_diff < 0))
837 panel_toplevel_set_orientation (toplevel, PANEL_ORIENTATION_RIGHT);
838
839 else if (((-x_diff < y_diff - snap_tolerance) && x_diff > 0 && y_diff < 0) ||
840 (( x_diff > y_diff - snap_tolerance) && x_diff > 0 && y_diff > 0))
841 panel_toplevel_set_orientation (toplevel, PANEL_ORIENTATION_BOTTOM);
842
843 else if ((( y_diff > x_diff + snap_tolerance) && x_diff > 0 && y_diff > 0) ||
844 ((-y_diff < x_diff + snap_tolerance) && x_diff < 0 && y_diff > 0))
845 panel_toplevel_set_orientation (toplevel, PANEL_ORIENTATION_LEFT);
846
847 else if (((-x_diff > y_diff - snap_tolerance) && x_diff < 0 && y_diff > 0) ||
848 (( x_diff < y_diff - snap_tolerance) && x_diff < 0 && y_diff < 0))
849 panel_toplevel_set_orientation (toplevel, PANEL_ORIENTATION_TOP);
850}
851
852#ifdef HAVE_X111
853static gboolean panel_toplevel_warp_pointer_increment(PanelToplevel* toplevel, int keyval, int increment)
854{
855 GdkScreen *screen;
856 GdkWindow *root_window;
857 GdkDevice *device;
858 int new_x, new_y;
859
860 screen = gtk_window_get_screen (GTK_WINDOW (toplevel)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_window_get_type ()))))))
);
861 g_return_val_if_fail (GDK_IS_X11_SCREEN (screen), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((screen)); GType __t = ((gdk_x11_screen_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "GDK_IS_X11_SCREEN (screen)"); return ((0)); }
} while (0)
;
862 root_window = gdk_screen_get_root_window (screen);
863 device = gdk_seat_get_pointer (gdk_display_get_default_seat (gtk_widget_get_display (GTK_WIDGET(root_window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((root_window)), ((gtk_widget_get_type ()))))))
)));
864 gdk_window_get_device_position (gtk_widget_get_window (GTK_WIDGET (root_window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((root_window)), ((gtk_widget_get_type ()))))))
), device, &new_x, &new_y, NULL((void*)0));
865
866 switch (keyval) {
867 case GDK_KEY_Up0xff52:
868 case GDK_KEY_KP_Up0xff97:
869 new_y -= increment;
870 break;
871 case GDK_KEY_Left0xff51:
872 case GDK_KEY_KP_Left0xff96:
873 new_x -= increment;
874 break;
875 case GDK_KEY_Down0xff54:
876 case GDK_KEY_KP_Down0xff99:
877 new_y += increment;
878 break;
879 case GDK_KEY_Right0xff53:
880 case GDK_KEY_KP_Right0xff98:
881 new_x += increment;
882 break;
883 default:
884 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 884, ((const char*) (__func__)), ((void*)0)); } while (0)
;
885 return FALSE(0);
886 }
887
888 panel_warp_pointer (root_window, new_x, new_y);
889
890 return TRUE(!(0));
891}
892
893static gboolean panel_toplevel_move_keyboard_floating(PanelToplevel* toplevel, GdkEventKey* event)
894{
895#define SMALL_INCREMENT 1
896#define NORMAL_INCREMENT 10
897
898 int increment = NORMAL_INCREMENT;
899
900 if ((event->state & gtk_accelerator_get_default_mod_mask ()) == GDK_SHIFT_MASK)
901 increment = SMALL_INCREMENT;
902
903 return panel_toplevel_warp_pointer_increment (
904 toplevel, event->keyval, increment);
905
906#undef SMALL_INCREMENT
907#undef NORMAL_INCREMENT
908}
909
910#endif /* HAVE_X11 */
911
912static gboolean panel_toplevel_move_keyboard_expanded(PanelToplevel* toplevel, GdkEventKey* event)
913{
914 PanelOrientation new_orientation;
915
916 switch (event->keyval) {
917 case GDK_KEY_Up0xff52:
918 case GDK_KEY_KP_Up0xff97:
919 new_orientation = PANEL_ORIENTATION_TOP;
920 break;
921 case GDK_KEY_Left0xff51:
922 case GDK_KEY_KP_Left0xff96:
923 new_orientation = PANEL_ORIENTATION_LEFT;
924 break;
925 case GDK_KEY_Down0xff54:
926 case GDK_KEY_KP_Down0xff99:
927 new_orientation = PANEL_ORIENTATION_BOTTOM;
928 break;
929 case GDK_KEY_Right0xff53:
930 case GDK_KEY_KP_Right0xff98:
931 new_orientation = PANEL_ORIENTATION_RIGHT;
932 break;
933 default:
934 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 934, ((const char*) (__func__)), ((void*)0)); } while (0)
;
935 return FALSE(0);
936 }
937
938 panel_toplevel_set_orientation (toplevel, new_orientation);
939
940 return TRUE(!(0));
941}
942
943static gboolean panel_toplevel_initial_resize_keypress(PanelToplevel* toplevel, GdkEventKey* event)
944{
945 PanelGrabOpType grab_op;
946
947 switch (event->keyval) {
948 case GDK_KEY_Up0xff52:
949 case GDK_KEY_KP_Up0xff97:
950 if (!(toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)))
951 return FALSE(0);
952 grab_op = PANEL_GRAB_OP_RESIZE_UP;
953 break;
954 case GDK_KEY_Left0xff51:
955 case GDK_KEY_KP_Left0xff96:
956 if (!(toplevel->priv->orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT)))
957 return FALSE(0);
958 grab_op = PANEL_GRAB_OP_RESIZE_LEFT;
959 break;
960 case GDK_KEY_Down0xff54:
961 case GDK_KEY_KP_Down0xff99:
962 if (!(toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)))
963 return FALSE(0);
964 grab_op = PANEL_GRAB_OP_RESIZE_DOWN;
965 break;
966 case GDK_KEY_Right0xff53:
967 case GDK_KEY_KP_Right0xff98:
968 if (!(toplevel->priv->orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT)))
969 return FALSE(0);
970 grab_op = PANEL_GRAB_OP_RESIZE_RIGHT;
971 break;
972 default:
973 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 973, ((const char*) (__func__)), ((void*)0)); } while (0)
;
974 return FALSE(0);
975 }
976
977 panel_toplevel_end_grab_op (toplevel, event->time);
978 panel_toplevel_begin_grab_op (toplevel, grab_op, TRUE(!(0)), event->time);
979
980 return TRUE(!(0));
981}
982
983static gboolean panel_toplevel_handle_grab_op_key_event(PanelToplevel* toplevel, GdkEventKey* event)
984{
985 gboolean retval = FALSE(0);
986
987 switch (event->keyval) {
988 case GDK_KEY_Up0xff52:
989 case GDK_KEY_KP_Up0xff97:
990 case GDK_KEY_Left0xff51:
991 case GDK_KEY_KP_Left0xff96:
992 case GDK_KEY_Down0xff54:
993 case GDK_KEY_KP_Down0xff99:
994 case GDK_KEY_Right0xff53:
995 case GDK_KEY_KP_Right0xff98:
996 switch (toplevel->priv->grab_op) {
997 case PANEL_GRAB_OP_MOVE:
998 if (toplevel->priv->expand) {
999 retval = panel_toplevel_move_keyboard_expanded (
1000 toplevel, event);
1001 }
1002#ifdef HAVE_X111
1003 else if (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel)))(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gtk_widget_get_display (((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((toplevel)), ((gtk_widget_get_type ()))))
))))); GType __t = ((gdk_x11_display_get_type())); gboolean __r
; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
) {
1004 retval = panel_toplevel_move_keyboard_floating (
1005 toplevel, event);
1006 }
1007#endif /* HAVE_X11 */
1008 break;
1009 case PANEL_GRAB_OP_RESIZE:
1010 retval = panel_toplevel_initial_resize_keypress (toplevel, event);
1011 break;
1012 case PANEL_GRAB_OP_RESIZE_UP:
1013 case PANEL_GRAB_OP_RESIZE_DOWN:
1014 case PANEL_GRAB_OP_RESIZE_LEFT:
1015 case PANEL_GRAB_OP_RESIZE_RIGHT:
1016#ifdef HAVE_X111
1017 if (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel)))(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gtk_widget_get_display (((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((toplevel)), ((gtk_widget_get_type ()))))
))))); GType __t = ((gdk_x11_display_get_type())); gboolean __r
; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
)
1018 retval = panel_toplevel_warp_pointer_increment (toplevel, event->keyval, 1);
1019#endif /* HAVE_X11 */
1020 break;
1021 default:
1022 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 1022, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1023 break;
1024 }
1025 break;
1026 case GDK_KEY_Escape0xff1b:
1027 panel_toplevel_cancel_grab_op (toplevel, event->time);
1028 case GDK_KEY_Return0xff0d: /* drop through*/
1029 case GDK_KEY_KP_Enter0xff8d:
1030 case GDK_KEY_space0x020:
1031 case GDK_KEY_KP_Space0xff80:
1032 panel_toplevel_end_grab_op (toplevel, event->time);
1033 retval = TRUE(!(0));
1034 default: /* drop through*/
1035 break;
1036 }
1037
1038 return retval;
1039}
1040
1041static gboolean panel_toplevel_handle_grab_op_motion_event(PanelToplevel* toplevel, GdkEventMotion* event)
1042{
1043 switch (toplevel->priv->grab_op) {
1044 case PANEL_GRAB_OP_MOVE:
1045 if (toplevel->priv->expand)
1046 panel_toplevel_calc_new_orientation (
1047 toplevel, event->x_root, event->y_root);
1048
1049 else if ((event->state & gtk_accelerator_get_default_mod_mask ()) == GDK_CONTROL_MASK)
1050 panel_toplevel_rotate_to_pointer (
1051 toplevel, event->x_root, event->y_root);
1052
1053 else
1054 panel_toplevel_move_to_pointer (
1055 toplevel, event->x_root, event->y_root);
1056 return TRUE(!(0));
1057 case PANEL_GRAB_OP_RESIZE_UP:
1058 case PANEL_GRAB_OP_RESIZE_DOWN:
1059 case PANEL_GRAB_OP_RESIZE_LEFT:
1060 case PANEL_GRAB_OP_RESIZE_RIGHT:
1061 panel_toplevel_resize_to_pointer (toplevel, event->x_root, event->y_root);
1062 return TRUE(!(0));
1063 default:
1064 break;
1065 }
1066
1067 return FALSE(0);
1068}
1069
1070static void panel_toplevel_calc_floating(PanelToplevel* toplevel)
1071{
1072 GdkRectangle monitor_geom;
1073 GdkPoint position_on_monitor;
1074 int snap_tolerance;
1075
1076 if (toplevel->priv->expand) {
1077 toplevel->priv->floating = FALSE(0);
1078 return;
1079 }
1080
1081 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
1082
1083 if (toplevel->priv->x_right == -1)
1084 position_on_monitor.x = toplevel->priv->x;
1085 else
1086 position_on_monitor.x = monitor_geom.width - (toplevel->priv->x_right + toplevel->priv->geometry.width);
1087 if (toplevel->priv->y_bottom == -1)
1088 position_on_monitor.y = toplevel->priv->y;
1089 else
1090 position_on_monitor.y = monitor_geom.height - (toplevel->priv->y_bottom + toplevel->priv->geometry.height);
1091
1092 snap_tolerance = toplevel->priv->snap_tolerance;
1093
1094 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM))
1095 toplevel->priv->floating =
1096 (position_on_monitor.y > snap_tolerance) &&
1097 (position_on_monitor.y < (monitor_geom.height - toplevel->priv->geometry.height - snap_tolerance));
1098 else
1099 toplevel->priv->floating =
1100 (position_on_monitor.x > snap_tolerance) &&
1101 (position_on_monitor.x < (monitor_geom.width - toplevel->priv->geometry.width - snap_tolerance));
1102}
1103
1104void panel_toplevel_push_autohide_disabler(PanelToplevel* toplevel)
1105{
1106 g_return_if_fail (toplevel != NULL)do { if ((toplevel != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "toplevel != NULL"
); return; } } while (0)
;
1107
1108 if (!toplevel->priv->n_autohide_disablers++)
1109 panel_toplevel_queue_auto_hide (toplevel);
1110}
1111
1112void panel_toplevel_pop_autohide_disabler(PanelToplevel* toplevel)
1113{
1114 g_return_if_fail (toplevel != NULL)do { if ((toplevel != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "toplevel != NULL"
); return; } } while (0)
;
1115 g_return_if_fail (toplevel->priv->n_autohide_disablers > 0)do { if ((toplevel->priv->n_autohide_disablers > 0))
{ } else { g_return_if_fail_warning (((gchar*) 0), ((const char
*) (__func__)), "toplevel->priv->n_autohide_disablers > 0"
); return; } } while (0)
;
1116
1117 if (!--toplevel->priv->n_autohide_disablers)
1118 panel_toplevel_queue_auto_hide (toplevel);
1119}
1120
1121static gboolean panel_toplevel_get_autohide_disabled(PanelToplevel* toplevel)
1122{
1123 return toplevel->priv->n_autohide_disablers > 0 ? TRUE(!(0)) : FALSE(0);
1124}
1125
1126static gboolean panel_toplevel_hide_button_event(PanelToplevel* toplevel, GdkEventButton* event, GtkButton* button)
1127{
1128 if (event->button == 1)
1129 return FALSE(0);
1130
1131 return gtk_widget_event (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
, (GdkEvent *) event);
1132}
1133
1134static void panel_toplevel_hide_button_clicked(PanelToplevel* toplevel, GtkButton* button)
1135{
1136 GtkArrowType arrow_type;
1137 gboolean ltr;
1138
1139 if (toplevel->priv->animating ||
1140 toplevel->priv->state == PANEL_STATE_AUTO_HIDDEN)
1141 return;
1142
1143 ltr = gtk_widget_get_direction (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
) == GTK_TEXT_DIR_LTR;
1144 arrow_type = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button), "arrow-type"))((gint) (glong) (g_object_get_data (((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((button)), (((GType) ((20) << (2)))
))))), "arrow-type")))
;
1145
1146 if (toplevel->priv->state == PANEL_STATE_NORMAL) {
1147 GtkDirectionType direction;
1148
1149 switch (arrow_type) {
1150 case GTK_ARROW_UP:
1151 direction = GTK_DIR_UP;
1152 break;
1153 case GTK_ARROW_DOWN:
1154 direction = GTK_DIR_DOWN;
1155 break;
1156 case GTK_ARROW_LEFT:
1157 direction = ltr ? GTK_DIR_LEFT : GTK_DIR_RIGHT;
1158 break;
1159 case GTK_ARROW_RIGHT:
1160 direction = ltr ? GTK_DIR_RIGHT : GTK_DIR_LEFT;
1161 break;
1162 default:
1163 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 1163, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1164 break;
1165 }
1166
1167 panel_toplevel_hide (toplevel, FALSE(0), (gint) direction);
1168 } else
1169 panel_toplevel_unhide (toplevel);
1170}
1171
1172static void
1173set_arrow_type (GtkImage *image,
1174 GtkArrowType arrow_type)
1175{
1176 switch (arrow_type)
1177 {
1178 case GTK_ARROW_NONE:
1179 case GTK_ARROW_DOWN:
1180 gtk_image_set_from_icon_name (image, "pan-down-symbolic", GTK_ICON_SIZE_BUTTON);
1181 break;
1182 case GTK_ARROW_UP:
1183 gtk_image_set_from_icon_name (image, "pan-up-symbolic", GTK_ICON_SIZE_BUTTON);
1184 break;
1185 case GTK_ARROW_LEFT:
1186 gtk_image_set_from_icon_name (image, "pan-start-symbolic", GTK_ICON_SIZE_BUTTON);
1187 break;
1188 case GTK_ARROW_RIGHT:
1189 gtk_image_set_from_icon_name (image, "pan-end-symbolic", GTK_ICON_SIZE_BUTTON);
1190 break;
1191 }
1192}
1193
1194static GtkWidget *
1195panel_toplevel_add_hide_button (PanelToplevel *toplevel,
1196 GtkArrowType arrow_type,
1197 int left,
1198 int top)
1199{
1200
1201 GtkWidget *button;
1202 AtkObject *obj;
1203 GtkWidget *arrow;
1204
1205 button = gtk_button_new ();
1206 obj = gtk_widget_get_accessible (button);
1207 atk_object_set_name (obj, _("Hide Panel")gettext ("Hide Panel"));
1208 gtk_widget_set_can_default (button, FALSE(0));
1209
1210 arrow = gtk_image_new ();
1211 set_arrow_type (GTK_IMAGE (arrow)((((GtkImage*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((arrow)), ((gtk_image_get_type ()))))))
, arrow_type);
1212 gtk_container_add (GTK_CONTAINER (button)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), ((gtk_container_get_type ()))))))
, arrow);
1213 gtk_widget_show (arrow);
1214
1215 g_object_set_data (G_OBJECT (button)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), (((GType) ((20) << (2))))))))
,
1216 "arrow-type",
1217 GINT_TO_POINTER (arrow_type)((gpointer) (glong) (arrow_type)));
1218
1219 g_signal_connect_swapped (button, "clicked",g_signal_connect_data ((button), ("clicked"), (((GCallback) (
panel_toplevel_hide_button_clicked))), (toplevel), ((void*)0)
, G_CONNECT_SWAPPED)
1220 G_CALLBACK (panel_toplevel_hide_button_clicked), toplevel)g_signal_connect_data ((button), ("clicked"), (((GCallback) (
panel_toplevel_hide_button_clicked))), (toplevel), ((void*)0)
, G_CONNECT_SWAPPED)
;
1221 g_signal_connect_swapped (button, "button-press-event",g_signal_connect_data ((button), ("button-press-event"), (((GCallback
) (panel_toplevel_hide_button_event))), (toplevel), ((void*)0
), G_CONNECT_SWAPPED)
1222 G_CALLBACK (panel_toplevel_hide_button_event), toplevel)g_signal_connect_data ((button), ("button-press-event"), (((GCallback
) (panel_toplevel_hide_button_event))), (toplevel), ((void*)0
), G_CONNECT_SWAPPED)
;
1223 g_signal_connect_swapped (button, "button-release-event",g_signal_connect_data ((button), ("button-release-event"), ((
(GCallback) (panel_toplevel_hide_button_event))), (toplevel),
((void*)0), G_CONNECT_SWAPPED)
1224 G_CALLBACK (panel_toplevel_hide_button_event), toplevel)g_signal_connect_data ((button), ("button-release-event"), ((
(GCallback) (panel_toplevel_hide_button_event))), (toplevel),
((void*)0), G_CONNECT_SWAPPED)
;
1225
1226 gtk_grid_attach (GTK_GRID (toplevel->priv->grid)((((GtkGrid*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->grid)), ((gtk_grid_get_type ()))))
))
, button, left, top, 1, 1);
1227
1228 return button;
1229}
1230
1231static void panel_toplevel_update_buttons_showing(PanelToplevel* toplevel)
1232{
1233 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)) {
1234 gtk_widget_hide (toplevel->priv->hide_button_top);
1235 gtk_widget_hide (toplevel->priv->hide_button_bottom);
1236 gtk_widget_show (toplevel->priv->hide_button_left);
1237 gtk_widget_show (toplevel->priv->hide_button_right);
1238 } else {
1239 gtk_widget_show (toplevel->priv->hide_button_top);
1240 gtk_widget_show (toplevel->priv->hide_button_bottom);
1241 gtk_widget_hide (toplevel->priv->hide_button_left);
1242 gtk_widget_hide (toplevel->priv->hide_button_right);
1243 }
1244
1245 if (toplevel->priv->attached) {
1246 switch (panel_toplevel_get_orientation (toplevel->priv->attach_toplevel)) {
1247 case PANEL_ORIENTATION_TOP:
1248 gtk_widget_hide (toplevel->priv->hide_button_top);
1249 break;
1250 case PANEL_ORIENTATION_BOTTOM:
1251 gtk_widget_hide (toplevel->priv->hide_button_bottom);
1252 break;
1253 case PANEL_ORIENTATION_LEFT:
1254 gtk_widget_hide (toplevel->priv->hide_button_left);
1255 break;
1256 case PANEL_ORIENTATION_RIGHT:
1257 gtk_widget_hide (toplevel->priv->hide_button_right);
1258 break;
1259 default:
1260 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 1260, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1261 break;
1262 }
1263 }
1264}
1265
1266/* force set hide button size on panel size < 30px */
1267static void panel_toplevel_update_hide_buttons_size (GtkWidget *button, int panel_size)
1268{
1269 GtkCssProvider *css_provider;
1270 GtkStyleContext *context;
1271 GtkWidget *arrow;
1272 GtkSettings *settings;
1273 gchar *gtk_theme_name = NULL((void*)0);
1274
1275 context = gtk_widget_get_style_context (button);
1276 gtk_style_context_add_class (context, "panel-button");
1277
1278 /* get defaults from theme */
1279 settings = gtk_settings_get_default ();
1280 g_object_get (settings, "gtk-theme-name", &gtk_theme_name, NULL((void*)0));
1281 css_provider = gtk_css_provider_get_named (gtk_theme_name, NULL((void*)0));
1282 g_free (gtk_theme_name);
1283
1284 /* set custom css by adding our custom code to the default theme css
1285 *
1286 * NOTE that contriary to the documentation:
1287 * https://developer.gnome.org/gtk3/stable/GtkCssProvider.html#gtk-css-provider-load-from-data
1288 * the previously loaded theme is NOT cleared from the css_provider. (reason unknown)
1289 * In other words, this works exactly, how we need it here.
1290 * ALSO NOTE that using gtk_css_provider_to_string () to convert the theme css data into a string
1291 * and then adding the custom css, then adding this updated css to a css_provider
1292 * with the gtk_css_provider_load_from_data () also works,
1293 * however some themes can't be easily converted to strings, beacuse of the binary data
1294 * they contain. This causes a delay of minutes in loading the mate-panel,
1295 * and so this approach is not viable. */
1296 if (panel_size < 30) {
1297 gtk_css_provider_load_from_data (css_provider, ".panel-button {min-height: 13px; min-width: 13px; padding: 0px;}", -1, NULL((void*)0));
1298 }
1299
1300 gtk_style_context_add_provider (context, GTK_STYLE_PROVIDER (css_provider)((((GtkStyleProvider*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((css_provider)), ((gtk_style_provider_get_type
()))))))
, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION600);
1301
1302 /* get arrow image */
1303 arrow = gtk_bin_get_child (GTK_BIN (button)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), ((gtk_bin_get_type ()))))))
);
1304
1305 /* set image size */
1306 if (panel_size < 20) {
1307 gtk_image_set_pixel_size (GTK_IMAGE (arrow)((((GtkImage*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((arrow)), ((gtk_image_get_type ()))))))
, 12);
1308 } else if (panel_size < 40) {
1309 gtk_image_set_pixel_size (GTK_IMAGE (arrow)((((GtkImage*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((arrow)), ((gtk_image_get_type ()))))))
, 16);
1310 } else if (panel_size < 60) {
1311 gtk_image_set_pixel_size (GTK_IMAGE (arrow)((((GtkImage*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((arrow)), ((gtk_image_get_type ()))))))
, 22);
1312 } else {
1313 gtk_image_set_pixel_size (GTK_IMAGE (arrow)((((GtkImage*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((arrow)), ((gtk_image_get_type ()))))))
, 24);
1314 }
1315}
1316
1317static void panel_toplevel_update_hide_buttons(PanelToplevel* toplevel)
1318{
1319
1320 int panel_size = toplevel->priv->size;
1321
1322 if (toplevel->priv->buttons_enabled) {
1323 panel_toplevel_update_buttons_showing (toplevel);
1324
1325 panel_toplevel_update_hide_buttons_size (toplevel->priv->hide_button_top, panel_size);
1326 panel_toplevel_update_hide_buttons_size (toplevel->priv->hide_button_bottom, panel_size);
1327 panel_toplevel_update_hide_buttons_size (toplevel->priv->hide_button_left, panel_size);
1328 panel_toplevel_update_hide_buttons_size (toplevel->priv->hide_button_right, panel_size);
1329
1330 } else {
1331 g_object_set (
1332 G_OBJECT (toplevel->priv->hide_button_top)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->hide_button_top)), (((GType) ((20)
<< (2))))))))
,
1333 "visible", toplevel->priv->state == PANEL_STATE_HIDDEN_DOWN,
1334 NULL((void*)0));
1335 g_object_set (
1336 G_OBJECT (toplevel->priv->hide_button_bottom)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->hide_button_bottom)), (((GType) ((
20) << (2))))))))
,
1337 "visible", toplevel->priv->state == PANEL_STATE_HIDDEN_UP,
1338 NULL((void*)0));
1339 g_object_set (
1340 G_OBJECT (toplevel->priv->hide_button_left)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->hide_button_left)), (((GType) ((20
) << (2))))))))
,
1341 "visible", toplevel->priv->state == PANEL_STATE_HIDDEN_RIGHT,
1342 NULL((void*)0));
1343 g_object_set (
1344 G_OBJECT (toplevel->priv->hide_button_right)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->hide_button_right)), (((GType) ((20
) << (2))))))))
,
1345 "visible", toplevel->priv->state == PANEL_STATE_HIDDEN_LEFT,
1346 NULL((void*)0));
1347 }
1348
1349 if (toplevel->priv->arrows_enabled) {
1350
1351 gtk_widget_show (gtk_bin_get_child (GTK_BIN (toplevel->priv->hide_button_top)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->hide_button_top)), ((gtk_bin_get_type
()))))))
));
1352 gtk_widget_show (gtk_bin_get_child (GTK_BIN (toplevel->priv->hide_button_bottom)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->hide_button_bottom)), ((gtk_bin_get_type
()))))))
));
1353 gtk_widget_show (gtk_bin_get_child (GTK_BIN (toplevel->priv->hide_button_left)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->hide_button_left)), ((gtk_bin_get_type
()))))))
));
1354 gtk_widget_show (gtk_bin_get_child (GTK_BIN (toplevel->priv->hide_button_right)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->hide_button_right)), ((gtk_bin_get_type
()))))))
));
1355
1356 } else {
1357
1358 gtk_widget_hide (gtk_bin_get_child (GTK_BIN (toplevel->priv->hide_button_top)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->hide_button_top)), ((gtk_bin_get_type
()))))))
));
1359 gtk_widget_hide (gtk_bin_get_child (GTK_BIN (toplevel->priv->hide_button_bottom)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->hide_button_bottom)), ((gtk_bin_get_type
()))))))
));
1360 gtk_widget_hide (gtk_bin_get_child (GTK_BIN (toplevel->priv->hide_button_left)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->hide_button_left)), ((gtk_bin_get_type
()))))))
));
1361 gtk_widget_hide (gtk_bin_get_child (GTK_BIN (toplevel->priv->hide_button_right)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->hide_button_right)), ((gtk_bin_get_type
()))))))
));
1362 }
1363
1364 /* set size after setting the arrow */
1365 if (toplevel->priv->buttons_enabled) {
1366 int hb_size;
1367
1368 if (panel_size < 20)
1369 hb_size = 16;
1370 else if (panel_size < 40)
1371 hb_size = 20;
1372 else if (panel_size < 60)
1373 hb_size = 26;
1374 else
1375 hb_size = 30;
1376
1377 gtk_widget_set_size_request (toplevel->priv->hide_button_top, panel_size, hb_size);
1378 gtk_widget_set_size_request (toplevel->priv->hide_button_bottom, panel_size, hb_size);
1379 gtk_widget_set_size_request (toplevel->priv->hide_button_left, hb_size, panel_size);
1380 gtk_widget_set_size_request (toplevel->priv->hide_button_right, hb_size, panel_size);
1381 }
1382}
1383
1384static gboolean panel_toplevel_contains_pointer(PanelToplevel* toplevel)
1385{
1386 GdkDisplay *display;
1387 GdkScreen *screen;
1388 GtkWidget *widget;
1389 GdkSeat *seat;
1390 GdkDevice *pointer;
1391 int x, y;
1392
1393 display = gdk_display_get_default ();
1394 seat = gdk_display_get_default_seat (display);
1395 pointer = gdk_seat_get_pointer (seat);
1396 widget = GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
;
1397
1398 if (!gtk_widget_get_realized (widget))
1399 return FALSE(0);
1400
1401 screen = NULL((void*)0);
1402 x = y = -1;
1403 gdk_device_get_position (pointer, &screen, &x, &y);
1404
1405 if (screen != gtk_window_get_screen (GTK_WINDOW (toplevel)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_window_get_type ()))))))
))
1406 return FALSE(0);
1407
1408 if (x == -1 || y == -1)
1409 return FALSE(0);
1410
1411 if (x < toplevel->priv->geometry.x || x >= (toplevel->priv->geometry.x + toplevel->priv->geometry.width) ||
1412 y < toplevel->priv->geometry.y || y >= (toplevel->priv->geometry.y + toplevel->priv->geometry.height))
1413 return FALSE(0);
1414
1415 return TRUE(!(0));
1416}
1417
1418static inline int panel_toplevel_get_effective_auto_hide_size(PanelToplevel* toplevel)
1419{
1420 int size;
1421
1422 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM))
1423 size = CLAMP (toplevel->priv->auto_hide_size,(((toplevel->priv->auto_hide_size) > (toplevel->priv
->original_height / 2)) ? (toplevel->priv->original_height
/ 2) : (((toplevel->priv->auto_hide_size) < (1)) ? (
1) : (toplevel->priv->auto_hide_size)))
1424 1, toplevel->priv->original_height / 2)(((toplevel->priv->auto_hide_size) > (toplevel->priv
->original_height / 2)) ? (toplevel->priv->original_height
/ 2) : (((toplevel->priv->auto_hide_size) < (1)) ? (
1) : (toplevel->priv->auto_hide_size)))
;
1425 else
1426 size = CLAMP (toplevel->priv->auto_hide_size,(((toplevel->priv->auto_hide_size) > (toplevel->priv
->original_width / 2)) ? (toplevel->priv->original_width
/ 2) : (((toplevel->priv->auto_hide_size) < (1)) ? (
1) : (toplevel->priv->auto_hide_size)))
1427 1, toplevel->priv->original_width / 2)(((toplevel->priv->auto_hide_size) > (toplevel->priv
->original_width / 2)) ? (toplevel->priv->original_width
/ 2) : (((toplevel->priv->auto_hide_size) < (1)) ? (
1) : (toplevel->priv->auto_hide_size)))
;
1428
1429 /* paranoia */
1430 return (size <= 0) ? DEFAULT_AUTO_HIDE_SIZE1 : size;
1431}
1432
1433static gboolean panel_toplevel_update_struts(PanelToplevel* toplevel, gboolean end_of_animation)
1434{
1435 PanelOrientation orientation;
1436 gboolean geometry_changed = FALSE(0);
1437 int strut, strut_start, strut_end;
1438 int x, y, width, height;
1439 GdkRectangle monitor_geom;
1440
1441 if (!toplevel->priv->updated_geometry_initial)
1442 return FALSE(0);
1443
1444#ifdef HAVE_X111
1445 if (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel)))(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gtk_widget_get_display (((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((toplevel)), ((gtk_widget_get_type ()))))
))))); GType __t = ((gdk_x11_display_get_type())); gboolean __r
; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
&& toplevel->priv->attached) {
1446 panel_struts_unregister_strut (toplevel);
1447 panel_struts_set_window_hint (toplevel);
1448 return FALSE(0);
1449 }
1450#endif /* HAVE_X11 */
1451
1452 /* In the case of the initial animation, we really want the struts to
1453 * represent what is at the end of the animation, to avoid desktop
1454 * icons jumping around. */
1455 if (!toplevel->priv->initial_animation_done) {
1456 end_of_animation = TRUE(!(0));
1457
1458 /* We've not started the animation yet, so we have to compute
1459 * where we want to end. Note that we don't want to compute
1460 * this everytime, since the struts conflict resolution will be
1461 * overridden if we do so */
1462 if (!toplevel->priv->animating)
1463 panel_toplevel_calculate_animation_end_geometry (toplevel);
1464 }
1465
1466 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
1467
1468 if (end_of_animation) {
1469 x = toplevel->priv->animation_end_x;
1470 y = toplevel->priv->animation_end_y;
1471 x += panel_multimonitor_x (toplevel->priv->monitor);
1472 y += panel_multimonitor_y (toplevel->priv->monitor);
1473 if (toplevel->priv->animation_end_width != -1)
1474 width = toplevel->priv->animation_end_width;
1475 else
1476 width = toplevel->priv->geometry.width;
1477 if (toplevel->priv->animation_end_height != -1)
1478 height = toplevel->priv->animation_end_height;
1479 else
1480 height = toplevel->priv->geometry.height;
1481 } else {
1482 x = toplevel->priv->geometry.x;
1483 y = toplevel->priv->geometry.y;
1484 width = toplevel->priv->geometry.width;
1485 height = toplevel->priv->geometry.height;
1486 }
1487
1488 orientation = toplevel->priv->orientation;
1489
1490 strut = strut_start = strut_end = 0;
1491
1492 if (orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)) {
1493 if (y <= monitor_geom.y) {
1494 orientation = PANEL_ORIENTATION_TOP;
1495 strut = y + height - monitor_geom.y;
1496 } else if (y >= monitor_geom.y + monitor_geom.height - height) {
1497 orientation = PANEL_ORIENTATION_BOTTOM;
1498 strut = monitor_geom.y + monitor_geom.height - y;
1499 }
1500
1501 if (strut > 0) {
1502 strut_start = MAX (x, monitor_geom.x)(((x) > (monitor_geom.x)) ? (x) : (monitor_geom.x));
1503 strut_end = MIN (x + width, monitor_geom.x + monitor_geom.width)(((x + width) < (monitor_geom.x + monitor_geom.width)) ? (
x + width) : (monitor_geom.x + monitor_geom.width))
- 1;
1504 }
1505 } else {
1506 if (x <= monitor_geom.x) {
1507 orientation = PANEL_ORIENTATION_LEFT;
1508 strut = x + width - monitor_geom.x;
1509 } else if (x >= monitor_geom.x + monitor_geom.width - width) {
1510 orientation = PANEL_ORIENTATION_RIGHT;
1511 strut = monitor_geom.x + monitor_geom.width - x;
1512 }
1513
1514 if (strut > 0) {
1515 strut_start = MAX (y, monitor_geom.y)(((y) > (monitor_geom.y)) ? (y) : (monitor_geom.y));
1516 strut_end = MIN (y + height, monitor_geom.y + monitor_geom.height)(((y + height) < (monitor_geom.y + monitor_geom.height)) ?
(y + height) : (monitor_geom.y + monitor_geom.height))
- 1;
1517 }
1518 }
1519
1520 if (orientation != toplevel->priv->orientation) {
1521 toplevel->priv->orientation = orientation;
1522 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "orientation");
1523 }
1524
1525 if (toplevel->priv->auto_hide && strut > 0)
1526 strut = panel_toplevel_get_effective_auto_hide_size (toplevel);
1527
1528#ifdef HAVE_X111
1529 if (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel)))(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gtk_widget_get_display (((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((toplevel)), ((gtk_widget_get_type ()))))
))))); GType __t = ((gdk_x11_display_get_type())); gboolean __r
; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
) {
1530 if (strut > 0) {
1531 GdkScreen *screen;
1532 screen = gtk_widget_get_screen (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
1533 geometry_changed = panel_struts_register_strut (toplevel,
1534 screen,
1535 toplevel->priv->monitor,
1536 orientation,
1537 strut,
1538 strut_start,
1539 strut_end);
1540 }
1541 else {
1542 panel_struts_unregister_strut (toplevel);
1543 }
1544
1545 if (toplevel->priv->state == PANEL_STATE_NORMAL ||
1546 toplevel->priv->state == PANEL_STATE_AUTO_HIDDEN ||
1547 toplevel->priv->animating)
1548 panel_struts_set_window_hint (toplevel);
1549 else
1550 panel_struts_unset_window_hint (toplevel);
1551 }
1552#endif /* HAVE_X11 */
1553
1554#ifdef HAVE_WAYLAND1
1555 if (GDK_IS_WAYLAND_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel)))(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gtk_widget_get_display (((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((toplevel)), ((gtk_widget_get_type ()))))
))))); GType __t = ((gdk_wayland_display_get_type())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
) {
1556 wayland_panel_toplevel_update_placement (toplevel);
1557 }
1558#endif /* HAVE_WAYLAND */
1559 return geometry_changed;
1560}
1561
1562void panel_toplevel_update_edges(PanelToplevel* toplevel)
1563{
1564 GtkWidget *widget;
1565 PanelFrameEdge edges;
1566 PanelFrameEdge inner_edges;
1567 PanelFrameEdge outer_edges;
1568 GdkRectangle monitor_geom;
1569 int width, height;
1570 gboolean inner_frame = FALSE(0);
1571
1572 widget = GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
;
1573
1574 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
1575
1576 width = toplevel->priv->geometry.width;
1577 height = toplevel->priv->geometry.height;
1578
1579 edges = PANEL_EDGE_NONE;
1580
1581 /* We don't want any bevels with a color/image background */
1582 if (toplevel->priv->geometry.y > 0)
1583 edges |= PANEL_EDGE_TOP;
1584
1585 if (toplevel->priv->geometry.x > 0)
1586 edges |= PANEL_EDGE_LEFT;
1587
1588 if (toplevel->priv->geometry.y < (monitor_geom.height - height))
1589 edges |= PANEL_EDGE_BOTTOM;
1590
1591 if (toplevel->priv->geometry.x < (monitor_geom.width - width))
1592 edges |= PANEL_EDGE_RIGHT;
1593
1594 /* There is a conflict in the position algorithm when a
1595 * non-expanded centered panel is nearly the size of the
1596 * screen. This is similar to the one we have in
1597 * panel_toplevel_update_position(). A simple solution is
1598 * to keep the bevels in this case. */
1599 if (!toplevel->priv->expand &&
1600 toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM) &&
1601 toplevel->priv->x_centered)
1602 edges |= PANEL_EDGE_LEFT | PANEL_EDGE_RIGHT;
1603
1604 if (!toplevel->priv->expand &&
1605 toplevel->priv->orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT) &&
1606 toplevel->priv->y_centered)
1607 edges |= PANEL_EDGE_TOP | PANEL_EDGE_BOTTOM;
1608
1609 if (gtk_widget_get_visible (toplevel->priv->hide_button_left) ||
1610 gtk_widget_get_visible (toplevel->priv->hide_button_right)) {
1611 inner_frame = TRUE(!(0));
1612 edges |= PANEL_EDGE_LEFT | PANEL_EDGE_RIGHT;
1613 }
1614
1615 if (gtk_widget_get_visible (toplevel->priv->hide_button_top) ||
1616 gtk_widget_get_visible (toplevel->priv->hide_button_bottom)) {
1617 inner_frame = TRUE(!(0));
1618 edges |= PANEL_EDGE_TOP | PANEL_EDGE_BOTTOM;
1619 }
1620
1621 if (!inner_frame) {
1622 inner_edges = PANEL_EDGE_NONE;
1623 outer_edges = edges;
1624 } else {
1625 inner_edges = edges;
1626 outer_edges = PANEL_EDGE_NONE;
1627 }
1628
1629 panel_frame_set_edges (toplevel->priv->inner_frame, inner_edges);
1630
1631 if (toplevel->priv->edges != outer_edges) {
1632 toplevel->priv->edges = outer_edges;
1633 gtk_widget_queue_resize (widget);
1634 }
1635}
1636
1637static const char* panel_toplevel_construct_description(PanelToplevel *toplevel)
1638{
1639 if (toplevel->priv->attached)
1640 return _("Drawer")gettext ("Drawer");
1641
1642 switch (toplevel->priv->orientation) {
1643 case PANEL_ORIENTATION_TOP:
1644 /* translators: these string will be shown in MetaCity's switch window
1645 * popup when you pass the focus to a panel */
1646 return _("Top Panel")gettext ("Top Panel");
1647 case PANEL_ORIENTATION_BOTTOM:
1648 return _("Bottom Panel")gettext ("Bottom Panel");
1649 case PANEL_ORIENTATION_LEFT:
1650 return _("Left Panel")gettext ("Left Panel");
1651 case PANEL_ORIENTATION_RIGHT:
1652 return _("Right Panel")gettext ("Right Panel");
1653 }
1654
1655 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 1655, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1656 return _("Top Panel")gettext ("Top Panel");
1657}
1658
1659static void panel_toplevel_update_description(PanelToplevel* toplevel)
1660{
1661 const char *description;
1662
1663 description = panel_toplevel_construct_description (toplevel);
1664
1665 if (toplevel->priv->description &&
1666 !strcmp (toplevel->priv->description, description))
1667 return;
1668
1669 if (toplevel->priv->description)
1670 g_free (toplevel->priv->description);
1671 toplevel->priv->description = g_strdup (description)g_strdup_inline (description);
1672
1673 if (!toplevel->priv->name)
1674 gtk_window_set_title (GTK_WINDOW (toplevel)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_window_get_type ()))))))
,
1675 toplevel->priv->description);
1676
1677 panel_a11y_set_atk_name_desc (
1678 GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
,
1679 toplevel->priv->name ? toplevel->priv->name :
1680 toplevel->priv->description,
1681 toplevel->priv->description);
1682}
1683
1684static void panel_toplevel_update_attached_position(PanelToplevel* toplevel, gboolean hidden, int* x, int* y, int* w, int* h)
1685{
1686 GtkAllocation attach_allocation;
1687 PanelOrientation attach_orientation;
1688 GdkRectangle toplevel_box;
1689 GdkRectangle parent_box;
1690 GdkRectangle attach_box;
1691 int x_origin = 0, y_origin = 0;
1692 GdkRectangle monitor_geom;
1693
1694 if (!gtk_widget_get_realized (GTK_WIDGET (toplevel->priv->attach_toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->attach_toplevel)), ((gtk_widget_get_type
()))))))
) ||
1695 !gtk_widget_get_realized (toplevel->priv->attach_widget))
1696 return;
1697
1698 gtk_widget_get_allocation (GTK_WIDGET (toplevel->priv->attach_widget)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->attach_widget)), ((gtk_widget_get_type
()))))))
, &attach_allocation);
1699
1700 toplevel_box = toplevel->priv->geometry;
1701 parent_box = toplevel->priv->attach_toplevel->priv->geometry;
1702 attach_box = attach_allocation;
1703
1704 if (attach_box.x != -1) {
1705 gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (toplevel->priv->attach_widget)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->attach_widget)), ((gtk_widget_get_type
()))))))
),
1706 &x_origin, &y_origin);
1707
1708 attach_box.x += x_origin;
1709 attach_box.y += y_origin;
1710 } else {
1711 /* attach_widget isn't allocated. Put the toplevel
1712 * off screen.
1713 */
1714 attach_box.x = -toplevel_box.width;
1715 attach_box.y = -toplevel_box.height;
1716 }
1717
1718 attach_orientation = panel_toplevel_get_orientation (
1719 toplevel->priv->attach_toplevel);
1720
1721 if (attach_orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM))
1722 *x = attach_box.x + attach_box.width / 2 - toplevel_box.width / 2;
1723 else
1724 *y = attach_box.y + attach_box.height / 2 - toplevel_box.height / 2;
1725
1726 switch (attach_orientation) {
1727 case PANEL_ORIENTATION_TOP:
1728 *y = parent_box.y;
1729 if (!hidden)
1730 *y += parent_box.height;
1731 else
1732 *h = parent_box.height;
1733 break;
1734 case PANEL_ORIENTATION_BOTTOM:
1735 *y = parent_box.y;
1736 if (!hidden)
1737 *y -= toplevel_box.height;
1738 else
1739 *h = parent_box.height;
1740 break;
1741 case PANEL_ORIENTATION_LEFT:
1742 *x = parent_box.x;
1743 if (!hidden)
1744 *x += parent_box.width;
1745 else
1746 *w = parent_box.width;
1747 break;
1748 case PANEL_ORIENTATION_RIGHT:
1749 *x = parent_box.x;
1750 if (!hidden)
1751 *x -= toplevel_box.width;
1752 else
1753 *w = parent_box.width;
1754 break;
1755 default:
1756 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 1756, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1757 break;
1758 }
1759
1760 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
1761
1762 *x -= monitor_geom.x;
1763 *y -= monitor_geom.y;
1764
1765 if (toplevel->priv->orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT))
1766 *x = CLAMP (*x, 0, monitor_geom.width - toplevel->priv->original_width)(((*x) > (monitor_geom.width - toplevel->priv->original_width
)) ? (monitor_geom.width - toplevel->priv->original_width
) : (((*x) < (0)) ? (0) : (*x)))
;
1767 else
1768 *y = CLAMP (*y, 0, monitor_geom.height - toplevel->priv->original_height)(((*y) > (monitor_geom.height - toplevel->priv->original_height
)) ? (monitor_geom.height - toplevel->priv->original_height
) : (((*y) < (0)) ? (0) : (*y)))
;
1769}
1770
1771static void panel_toplevel_update_normal_position(PanelToplevel* toplevel, int* x, int* y, int* w, int* h)
1772{
1773 GdkRectangle monitor_geom;
1774 int width, height;
1775 int snap_tolerance;
1776
1777 g_assert (x != NULL && y != NULL)do { if (x != ((void*)0) && y != ((void*)0)) ; else g_assertion_message_expr
(((gchar*) 0), "panel-toplevel.c", 1777, ((const char*) (__func__
)), "x != NULL && y != NULL"); } while (0)
;
1778
1779 if (toplevel->priv->attached) {
1780 panel_toplevel_update_attached_position (toplevel, FALSE(0), x, y, w, h);
1781 return;
1782 }
1783
1784 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
1785
1786 width = toplevel->priv->original_width;
1787 height = toplevel->priv->original_height;
1788 snap_tolerance = toplevel->priv->snap_tolerance;
1789
1790 *x = CLAMP (*x, 0, monitor_geom.width - width)(((*x) > (monitor_geom.width - width)) ? (monitor_geom.width
- width) : (((*x) < (0)) ? (0) : (*x)))
;
1791 *y = CLAMP (*y, 0, monitor_geom.height - height)(((*y) > (monitor_geom.height - height)) ? (monitor_geom.height
- height) : (((*y) < (0)) ? (0) : (*y)))
;
1792
1793 if (toplevel->priv->x <= snap_tolerance &&
1794 toplevel->priv->x_right == -1 &&
1795 !toplevel->priv->x_centered)
1796 *x = 0;
1797 else if (toplevel->priv->x_right != -1 &&
1798 toplevel->priv->x_right <= snap_tolerance &&
1799 !toplevel->priv->x_centered)
1800 *x = monitor_geom.width - width;
1801
1802 if (toplevel->priv->y <= snap_tolerance &&
1803 toplevel->priv->y_bottom == -1 &&
1804 !toplevel->priv->y_centered)
1805 *y = 0;
1806 else if (toplevel->priv->y_bottom != -1 &&
1807 toplevel->priv->y_bottom <= snap_tolerance &&
1808 !toplevel->priv->y_centered)
1809 *y = monitor_geom.height - height;
1810}
1811
1812static void
1813panel_toplevel_update_auto_hide_position (PanelToplevel *toplevel,
1814 int *x,
1815 int *y,
1816 int *w,
1817 int *h,
1818 gboolean for_end_position)
1819{
1820 int width, height;
1821 GdkRectangle monitor_geom;
1822 int auto_hide_size;
1823 int snap_tolerance;
1824
1825 g_assert (x != NULL && y != NULL)do { if (x != ((void*)0) && y != ((void*)0)) ; else g_assertion_message_expr
(((gchar*) 0), "panel-toplevel.c", 1825, ((const char*) (__func__
)), "x != NULL && y != NULL"); } while (0)
;
1826
1827 if (toplevel->priv->floating) {
1828 panel_toplevel_update_normal_position (toplevel, x, y, w, h);
1829 return;
1830 }
1831
1832 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
1833
1834 width = toplevel->priv->original_width;
1835 height = toplevel->priv->original_height;
1836 snap_tolerance = toplevel->priv->snap_tolerance;
1837
1838 /* For the initial animation, we animate from outside the screen, and
1839 * so we don't want the toplevel to be visible at all. But when the
1840 * request is for the end position, then we give the real result (it's
1841 * useful for struts) */
1842 if (for_end_position || toplevel->priv->initial_animation_done) {
1843 auto_hide_size = panel_toplevel_get_effective_auto_hide_size (toplevel);
1844 } else {
1845 auto_hide_size = 0;
1846 }
1847
1848 switch (toplevel->priv->orientation) {
1849 case PANEL_ORIENTATION_TOP:
1850 *y = - (height - auto_hide_size);
1851 break;
1852 case PANEL_ORIENTATION_BOTTOM:
1853 *y = monitor_geom.height - auto_hide_size;
1854 break;
1855 case PANEL_ORIENTATION_LEFT:
1856 *x = - (width - auto_hide_size);
1857 break;
1858 case PANEL_ORIENTATION_RIGHT:
1859 *x = monitor_geom.width - auto_hide_size;
1860 break;
1861 default:
1862 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 1862, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1863 break;
1864 }
1865
1866 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)) {
1867 if (toplevel->priv->x <= snap_tolerance &&
1868 toplevel->priv->x_right == -1 &&
1869 !toplevel->priv->x_centered)
1870 *x = 0;
1871 else if (toplevel->priv->x_right != -1 &&
1872 toplevel->priv->x_right <= snap_tolerance &&
1873 !toplevel->priv->x_centered)
1874 *x = monitor_geom.width - width;
1875 } else /* if (toplevel->priv->orientation & PANEL_VERTICAL_MASK) */ {
1876 if (toplevel->priv->y <= snap_tolerance &&
1877 toplevel->priv->y_bottom == -1 &&
1878 !toplevel->priv->y_centered)
1879 *y = 0;
1880 else if (toplevel->priv->y_bottom != -1 &&
1881 toplevel->priv->y_bottom <= snap_tolerance &&
1882 !toplevel->priv->y_centered)
1883 *y = monitor_geom.height - height;
1884 }
1885}
1886
1887/* FIXME: this is wrong for Xinerama. In the Xinerama case
1888 * I think if hiding it requires it to go onto the
1889 * next monitor then it should just move it on to
1890 * the next monitor and set its state back to normal
1891 */
1892static void
1893panel_toplevel_update_hidden_position (PanelToplevel *toplevel,
1894 int *x,
1895 int *y,
1896 int *w,
1897 int *h)
1898{
1899 int width, height;
1900 int min_hide_size;
1901 GdkRectangle monitor_geom;
1902 GtkAllocation hide_allocation;
1903
1904 g_assert (x != NULL && y != NULL)do { if (x != ((void*)0) && y != ((void*)0)) ; else g_assertion_message_expr
(((gchar*) 0), "panel-toplevel.c", 1904, ((const char*) (__func__
)), "x != NULL && y != NULL"); } while (0)
;
1905
1906 g_assert (toplevel->priv->state == PANEL_STATE_HIDDEN_UP ||do { if (toplevel->priv->state == PANEL_STATE_HIDDEN_UP
|| toplevel->priv->state == PANEL_STATE_HIDDEN_DOWN ||
toplevel->priv->state == PANEL_STATE_HIDDEN_LEFT || toplevel
->priv->state == PANEL_STATE_HIDDEN_RIGHT) ; else g_assertion_message_expr
(((gchar*) 0), "panel-toplevel.c", 1909, ((const char*) (__func__
)), "toplevel->priv->state == PANEL_STATE_HIDDEN_UP || toplevel->priv->state == PANEL_STATE_HIDDEN_DOWN || toplevel->priv->state == PANEL_STATE_HIDDEN_LEFT || toplevel->priv->state == PANEL_STATE_HIDDEN_RIGHT"
); } while (0)
1907 toplevel->priv->state == PANEL_STATE_HIDDEN_DOWN ||do { if (toplevel->priv->state == PANEL_STATE_HIDDEN_UP
|| toplevel->priv->state == PANEL_STATE_HIDDEN_DOWN ||
toplevel->priv->state == PANEL_STATE_HIDDEN_LEFT || toplevel
->priv->state == PANEL_STATE_HIDDEN_RIGHT) ; else g_assertion_message_expr
(((gchar*) 0), "panel-toplevel.c", 1909, ((const char*) (__func__
)), "toplevel->priv->state == PANEL_STATE_HIDDEN_UP || toplevel->priv->state == PANEL_STATE_HIDDEN_DOWN || toplevel->priv->state == PANEL_STATE_HIDDEN_LEFT || toplevel->priv->state == PANEL_STATE_HIDDEN_RIGHT"
); } while (0)
1908 toplevel->priv->state == PANEL_STATE_HIDDEN_LEFT ||do { if (toplevel->priv->state == PANEL_STATE_HIDDEN_UP
|| toplevel->priv->state == PANEL_STATE_HIDDEN_DOWN ||
toplevel->priv->state == PANEL_STATE_HIDDEN_LEFT || toplevel
->priv->state == PANEL_STATE_HIDDEN_RIGHT) ; else g_assertion_message_expr
(((gchar*) 0), "panel-toplevel.c", 1909, ((const char*) (__func__
)), "toplevel->priv->state == PANEL_STATE_HIDDEN_UP || toplevel->priv->state == PANEL_STATE_HIDDEN_DOWN || toplevel->priv->state == PANEL_STATE_HIDDEN_LEFT || toplevel->priv->state == PANEL_STATE_HIDDEN_RIGHT"
); } while (0)
1909 toplevel->priv->state == PANEL_STATE_HIDDEN_RIGHT)do { if (toplevel->priv->state == PANEL_STATE_HIDDEN_UP
|| toplevel->priv->state == PANEL_STATE_HIDDEN_DOWN ||
toplevel->priv->state == PANEL_STATE_HIDDEN_LEFT || toplevel
->priv->state == PANEL_STATE_HIDDEN_RIGHT) ; else g_assertion_message_expr
(((gchar*) 0), "panel-toplevel.c", 1909, ((const char*) (__func__
)), "toplevel->priv->state == PANEL_STATE_HIDDEN_UP || toplevel->priv->state == PANEL_STATE_HIDDEN_DOWN || toplevel->priv->state == PANEL_STATE_HIDDEN_LEFT || toplevel->priv->state == PANEL_STATE_HIDDEN_RIGHT"
); } while (0)
;
1910
1911 if (toplevel->priv->attached) {
1912 panel_toplevel_update_attached_position (toplevel, TRUE(!(0)), x, y, w, h);
1913 return;
1914 }
1915
1916 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
1917
1918 width = toplevel->priv->original_width;
1919 height = toplevel->priv->original_height;
1920
1921 /* FIXME should find a better default */
1922 min_hide_size = DEFAULT_AUTO_HIDE_SIZE1;
1923
1924 switch (toplevel->priv->state) {
1925 case PANEL_STATE_HIDDEN_UP:
1926 gtk_widget_get_allocation (toplevel->priv->hide_button_bottom,
1927 &hide_allocation);
1928 *y = - (height - MAX (hide_allocation.height, min_hide_size)(((hide_allocation.height) > (min_hide_size)) ? (hide_allocation
.height) : (min_hide_size))
);
1929 break;
1930 case PANEL_STATE_HIDDEN_DOWN:
1931 gtk_widget_get_allocation (toplevel->priv->hide_button_top,
1932 &hide_allocation);
1933 *y = monitor_geom.height - MAX (hide_allocation.height, min_hide_size)(((hide_allocation.height) > (min_hide_size)) ? (hide_allocation
.height) : (min_hide_size))
;
1934 break;
1935 case PANEL_STATE_HIDDEN_LEFT:
1936 gtk_widget_get_allocation (toplevel->priv->hide_button_right,
1937 &hide_allocation);
1938 *x = - (width - MAX (hide_allocation.width, min_hide_size)(((hide_allocation.width) > (min_hide_size)) ? (hide_allocation
.width) : (min_hide_size))
);
1939 break;
1940 case PANEL_STATE_HIDDEN_RIGHT:
1941 gtk_widget_get_allocation (toplevel->priv->hide_button_left,
1942 &hide_allocation);
1943 *x = monitor_geom.width - MAX (hide_allocation.width, min_hide_size)(((hide_allocation.width) > (min_hide_size)) ? (hide_allocation
.width) : (min_hide_size))
;
1944 break;
1945 default:
1946 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 1946, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1947 break;
1948 }
1949}
1950
1951/*
1952 * This is "almost" like the double sine movement
1953 * from the original panel except that it uses
1954 * a cubic (twice again). I suppose it looks less
1955 * mathematical now :) -- _v_
1956 */
1957static int
1958get_delta (int src,
1959 int dest,
1960 GTimeSpan elapsed_time,
1961 GTimeSpan duration_time)
1962{
1963 double x, percentage;
1964
1965 if (abs (dest - src) <= 1 || elapsed_time >= duration_time)
1966 return dest - src;
1967
1968 /* The cubic is: p(x) = (-2) x^2 (x-1.5) */
1969 /* running p(p(x)) to make it more "pronounced",
1970 * effectively making it a ninth-degree polynomial */
1971
1972 x = (double)elapsed_time/duration_time;
1973 x = -2 * (x*x) * (x-1.5);
1974 /* run it again */
1975 percentage = -2 * (x*x) * (x-1.5);
1976
1977 percentage = CLAMP (percentage, 0.0, 1.0)(((percentage) > (1.0)) ? (1.0) : (((percentage) < (0.0
)) ? (0.0) : (percentage)))
;
1978
1979 return ((dest - src) * percentage);
1980}
1981
1982static void
1983panel_toplevel_update_animating_position (PanelToplevel *toplevel)
1984{
1985 GTimeSpan animation_elapsed_time;
1986 int deltax, deltay, deltaw = 0, deltah = 0;
1987 int monitor_offset_x, monitor_offset_y;
1988
1989 if ((toplevel->priv->animation_start_time <= 0) ||
1990 (toplevel->priv->animation_duration_time <= 0))
1991 return;
1992
1993 animation_elapsed_time = g_get_monotonic_time () - toplevel->priv->animation_start_time;
1994
1995 monitor_offset_x = panel_multimonitor_x (toplevel->priv->monitor);
1996 monitor_offset_y = panel_multimonitor_y (toplevel->priv->monitor);
1997
1998 if (toplevel->priv->animation_end_width != -1)
1999 deltaw = get_delta (toplevel->priv->geometry.width,
2000 toplevel->priv->animation_end_width,
2001 animation_elapsed_time,
2002 toplevel->priv->animation_duration_time);
2003
2004 if (toplevel->priv->animation_end_height != -1)
2005 deltah = get_delta (toplevel->priv->geometry.height,
2006 toplevel->priv->animation_end_height,
2007 animation_elapsed_time,
2008 toplevel->priv->animation_duration_time);
2009
2010 deltax = get_delta (toplevel->priv->geometry.x - monitor_offset_x,
2011 toplevel->priv->animation_end_x,
2012 animation_elapsed_time,
2013 toplevel->priv->animation_duration_time);
2014
2015 deltay = get_delta (toplevel->priv->geometry.y - monitor_offset_y,
2016 toplevel->priv->animation_end_y,
2017 animation_elapsed_time,
2018 toplevel->priv->animation_duration_time);
2019
2020 if (deltaw != 0 && abs (deltaw) > abs (deltax))
2021 deltax = deltaw;
2022 if (deltah != 0 && abs (deltah) > abs (deltay))
2023 deltay = deltah;
2024
2025 toplevel->priv->geometry.x += deltax;
2026 toplevel->priv->geometry.y += deltay;
2027
2028 toplevel->priv->geometry.width += deltaw;
2029 toplevel->priv->geometry.height += deltah;
2030
2031 if (toplevel->priv->geometry.x - monitor_offset_x == toplevel->priv->animation_end_x &&
2032 toplevel->priv->geometry.y - monitor_offset_y == toplevel->priv->animation_end_y) {
2033 toplevel->priv->animating = FALSE(0);
2034 /* Note: it's important to set initial_animation_done to TRUE
2035 * as soon as possible (hence, here) since we don't want to
2036 * have a wrong value in a size request event */
2037 toplevel->priv->initial_animation_done = TRUE(!(0));
2038
2039 if (toplevel->priv->attached && panel_toplevel_get_is_hidden (toplevel))
2040 gtk_widget_unmap (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
2041 else
2042 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
2043
2044 if (toplevel->priv->state == PANEL_STATE_NORMAL)
2045 g_signal_emit (toplevel, toplevel_signals [UNHIDE_SIGNAL], 0);
2046 }
2047}
2048
2049static void
2050panel_toplevel_update_expanded_position (PanelToplevel *toplevel)
2051{
2052 GdkRectangle monitor_geom;
2053 int x, y;
2054 int x_right, y_bottom;
2055 int monitor;
2056
2057 if (!toplevel->priv->expand)
2058 return;
2059
2060 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
2061
2062 x = -1;
2063 y = -1;
2064 x_right = -1;
2065 y_bottom = -1;
2066
2067 switch (toplevel->priv->orientation) {
2068 case PANEL_ORIENTATION_TOP:
2069 x = monitor_geom.x;
2070 y = monitor_geom.y;
2071 break;
2072 case PANEL_ORIENTATION_LEFT:
2073 x = monitor_geom.x;
2074 y = monitor_geom.y;
2075 break;
2076 case PANEL_ORIENTATION_BOTTOM:
2077 x = monitor_geom.x;
2078 y = monitor_geom.y + monitor_geom.height - toplevel->priv->geometry.height;
2079 y_bottom = 0;
2080 break;
2081 case PANEL_ORIENTATION_RIGHT:
2082 x = monitor_geom.x + monitor_geom.width - toplevel->priv->geometry.width;
2083 y = monitor_geom.y;
2084 x_right = 0;
2085 break;
2086 default:
2087 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 2087, ((const char*) (__func__)), ((void*)0)); } while (0)
;
2088 break;
2089 }
2090
2091 monitor = panel_multimonitor_get_monitor_at_point (x, y);
2092
2093 panel_toplevel_set_monitor_internal (toplevel, monitor, TRUE(!(0)));
2094
2095 x -= panel_multimonitor_x (monitor);
2096 y -= panel_multimonitor_y (monitor);
2097
2098 g_object_freeze_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
);
2099
2100 if (toplevel->priv->x != x) {
2101 toplevel->priv->x = x;
2102 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "x");
2103 }
2104
2105 if (toplevel->priv->y != y) {
2106 toplevel->priv->y = y;
2107 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "y");
2108 }
2109
2110 if (toplevel->priv->x_right != x_right) {
2111 toplevel->priv->x_right = x_right;
2112 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "x_right");
2113 }
2114
2115 if (toplevel->priv->y_bottom != y_bottom) {
2116 toplevel->priv->y_bottom = y_bottom;
2117 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "y_bottom");
2118 }
2119
2120 g_object_thaw_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
);
2121}
2122
2123static void
2124panel_toplevel_update_position (PanelToplevel *toplevel)
2125{
2126 PanelBackground *background;
2127 int x, y;
2128 int w, h;
2129 GdkRectangle monitor_geom;
2130
2131 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
2132
2133 if (toplevel->priv->animating) {
2134 panel_toplevel_update_animating_position (toplevel);
2135 return;
2136 }
2137
2138 if (toplevel->priv->position_centered) {
2139 toplevel->priv->position_centered = FALSE(0);
2140
2141 g_object_freeze_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
);
2142
2143 if (!toplevel->priv->x_centered) {
2144 int x_right;
2145
2146 toplevel->priv->x -= toplevel->priv->geometry.width / 2;
2147 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "x");
2148
2149 if ((toplevel->priv->x + toplevel->priv->geometry.width / 2) > monitor_geom.width / 2)
2150 x_right = monitor_geom.width - (toplevel->priv->x + toplevel->priv->geometry.width);
2151 else
2152 x_right = -1;
2153 if (toplevel->priv->x_right != x_right) {
2154 toplevel->priv->x_right = x_right;
2155 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
,
2156 "x-right");
2157 }
2158 }
2159
2160 if (!toplevel->priv->y_centered) {
2161 int y_bottom;
2162
2163 toplevel->priv->y -= toplevel->priv->geometry.height / 2;
2164 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "y");
2165
2166 if ((toplevel->priv->y + toplevel->priv->geometry.height / 2) > monitor_geom.height / 2)
2167 y_bottom = monitor_geom.height - (toplevel->priv->y + toplevel->priv->geometry.height);
2168 else
2169 y_bottom = -1;
2170 if (toplevel->priv->y_bottom != y_bottom) {
2171 toplevel->priv->y_bottom = y_bottom;
2172 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
,
2173 "y-bottom");
2174 }
2175 }
2176
2177 g_object_thaw_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
);
2178 }
2179
2180 panel_toplevel_update_expanded_position (toplevel);
2181 panel_toplevel_calc_floating (toplevel); /* FIXME should probably be done after panel_toplevel_update_normal_position() too */
2182
2183 if (toplevel->priv->x_right == -1)
2184 x = toplevel->priv->x;
2185 else
2186 x = monitor_geom.width - (toplevel->priv->x_right + toplevel->priv->geometry.width);
2187 if (toplevel->priv->y_bottom == -1)
2188 y = toplevel->priv->y;
2189 else
2190 y = monitor_geom.height - (toplevel->priv->y_bottom + toplevel->priv->geometry.height);
2191
2192 if (!toplevel->priv->expand) {
2193 if (toplevel->priv->x_centered)
2194 x = (monitor_geom.width - toplevel->priv->geometry.width) / 2;
2195 if (toplevel->priv->y_centered)
2196 y = (monitor_geom.height - toplevel->priv->geometry.height) / 2;
2197 }
2198
2199 w = h = -1;
2200
2201 if (toplevel->priv->state == PANEL_STATE_NORMAL)
2202 panel_toplevel_update_normal_position (toplevel, &x, &y, &w, &h);
2203
2204 else if (toplevel->priv->state == PANEL_STATE_AUTO_HIDDEN)
2205 panel_toplevel_update_auto_hide_position (toplevel, &x, &y, &w, &h, FALSE(0));
2206
2207 else
2208 panel_toplevel_update_hidden_position (toplevel, &x, &y, &w, &h);
2209
2210 if (w != -1)
2211 toplevel->priv->geometry.width = w;
2212 if (h != -1)
2213 toplevel->priv->geometry.height = h;
2214
2215 /* This is some kind of snap: there's a possibility of an infinite loop
2216 * because of the bevels of the frame that are set in
2217 * panel_toplevel_update_edges(). The bevels change the width/height of
2218 * the toplevel. The typical loop is:
2219 * x = 1 => outer bevel => x = 0 => no outer bevel = > x = 1 => ...
2220 * FIXME: maybe the real bug is that we enter into this loop (see bug
2221 * #160748 to learn how to reproduce.) */
2222 background = &toplevel->background;
2223
2224 /* There's no bevels with a color/image background */
2225 if (panel_background_effective_type (background) == PANEL_BACK_NONE) {
2226 GtkStyleContext *context;
2227 GtkStateFlags state;
2228 GdkRectangle *geometry;
2229 GtkBorder padding;
2230 int max_size;
2231
2232 state = gtk_widget_get_state_flags (GTK_WIDGET (toplevel->priv->inner_frame)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->inner_frame)), ((gtk_widget_get_type
()))))))
);
2233 context = gtk_widget_get_style_context (GTK_WIDGET (toplevel->priv->inner_frame)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->inner_frame)), ((gtk_widget_get_type
()))))))
);
2234 gtk_style_context_get_padding (context, state, &padding);
2235 geometry = &toplevel->priv->geometry;
2236
2237 if (x <= padding.left && x > 0 &&
2238 !toplevel->priv->x_centered)
2239 x = 0;
2240
2241 if (y <= padding.top && y > 0 &&
2242 !toplevel->priv->y_centered)
2243 y = 0;
2244
2245 max_size = monitor_geom.width - geometry->width - padding.right;
2246 if (x + padding.left >= max_size && x < max_size &&
2247 !toplevel->priv->x_centered)
2248 x = max_size;
2249
2250 max_size = monitor_geom.height - geometry->height - padding.bottom;
2251 if (y + padding.top >= max_size && y < max_size &&
2252 !toplevel->priv->y_centered)
2253 y = max_size;
2254 }
2255
2256 x += panel_multimonitor_x (toplevel->priv->monitor);
2257 y += panel_multimonitor_y (toplevel->priv->monitor);
2258
2259 toplevel->priv->geometry.x = x;
2260 toplevel->priv->geometry.y = y;
2261}
2262
2263static int
2264calculate_minimum_height (GtkWidget *widget,
2265 PanelOrientation orientation)
2266{
2267 GtkStateFlags state;
2268 GtkStyleContext *style_context;
2269 PangoFontDescription *font_desc;
2270 GtkBorder padding;
2271 PangoContext *pango_context;
2272 PangoFontMetrics *metrics;
2273 int ascent;
2274 int descent;
2275 int thickness;
2276
2277 state = gtk_widget_get_state_flags (widget);
2278 style_context = gtk_widget_get_style_context (widget);
2279 gtk_style_context_get(style_context, state, GTK_STYLE_PROPERTY_FONT"font", &font_desc, NULL((void*)0));
2280
2281 pango_context = gtk_widget_get_pango_context (widget);
2282 metrics = pango_context_get_metrics (pango_context,
2283 font_desc,
2284 pango_context_get_language (pango_context));
2285 gtk_style_context_get_padding (style_context, state, &padding);
2286
2287 ascent = pango_font_metrics_get_ascent (metrics);
2288 descent = pango_font_metrics_get_descent (metrics);
2289
2290 pango_font_description_free (font_desc);
2291 pango_font_metrics_unref (metrics);
2292
2293 thickness = (orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)) ?
2294 padding.top + padding.bottom :
2295 padding.left + padding.right;
2296
2297 return PANGO_PIXELS (ascent + descent)(((int)(ascent + descent) + 512) >> 10) + thickness;
2298}
2299
2300static int
2301panel_toplevel_update_size_from_hints (PanelToplevel *toplevel,
2302 int requisition_size,
2303 int monitor_size,
2304 int non_panel_widget_size)
2305{
2306 int nb_size_hints;
2307 AppletSizeHints *applets_hints;
2308 AppletSizeHintsAlloc *using_hint;
2309
2310 int i;
2311 int total_size;
2312 int full_hints;
2313
2314 /* Scale down the size so that the panel only takes what it needs for the applets it has. */
2315 total_size = non_panel_widget_size + (requisition_size / toplevel->priv->scale);
2316
2317 nb_size_hints = toplevel->priv->panel_widget->nb_applets_size_hints;
2318 if (nb_size_hints <= 0)
2319 return total_size;
2320
2321 applets_hints = toplevel->priv->panel_widget->applets_hints;
2322 using_hint = toplevel->priv->panel_widget->applets_using_hint;
2323
2324 for (i = 0; i < nb_size_hints; i++) {
2325 using_hint[i].index = applets_hints[i].len - 2;
2326 using_hint[i].size = applets_hints[i].hints[applets_hints[i].len - 1];
2327 total_size += using_hint[i].size;
2328 }
2329
2330 if (total_size > monitor_size)
2331 return monitor_size;
2332
2333 full_hints = 0;
2334 while (full_hints != nb_size_hints && total_size < monitor_size) {
2335 int bonus;
2336 int extra_bonus;
2337
2338 bonus = (monitor_size - total_size)
2339 / (nb_size_hints - full_hints);
2340 extra_bonus = (monitor_size - total_size)
2341 % (nb_size_hints - full_hints);
2342 full_hints = 0;
2343
2344 for (i = 0; i < nb_size_hints; i++) {
2345 int new_size;
2346 int current_bonus;
2347
2348 current_bonus = bonus;
2349
2350 while (using_hint[i].index > 0 && applets_hints[i].hints[using_hint[i].index - 1] < using_hint[i].size + current_bonus) {
2351 new_size = applets_hints[i].hints[using_hint[i].index - 1];
2352 current_bonus = using_hint[i].size
2353 + current_bonus - new_size;
2354 total_size = total_size - using_hint[i].size
2355 + new_size;
2356
2357 using_hint[i].index -= 2;
2358 using_hint[i].size = new_size;
2359 }
2360
2361 new_size = MIN (applets_hints[i].hints[using_hint[i].index],(((applets_hints[i].hints[using_hint[i].index]) < (using_hint
[i].size + current_bonus)) ? (applets_hints[i].hints[using_hint
[i].index]) : (using_hint[i].size + current_bonus))
2362 using_hint[i].size + current_bonus)(((applets_hints[i].hints[using_hint[i].index]) < (using_hint
[i].size + current_bonus)) ? (applets_hints[i].hints[using_hint
[i].index]) : (using_hint[i].size + current_bonus))
;
2363 if (new_size > using_hint[i].size) {
2364 total_size += (new_size - using_hint[i].size);
2365 using_hint[i].size = new_size;
2366 }
2367
2368 if (extra_bonus > 0) {
2369 new_size = MIN (applets_hints[i].hints[using_hint[i].index],(((applets_hints[i].hints[using_hint[i].index]) < (using_hint
[i].size + extra_bonus)) ? (applets_hints[i].hints[using_hint
[i].index]) : (using_hint[i].size + extra_bonus))
2370 using_hint[i].size + extra_bonus)(((applets_hints[i].hints[using_hint[i].index]) < (using_hint
[i].size + extra_bonus)) ? (applets_hints[i].hints[using_hint
[i].index]) : (using_hint[i].size + extra_bonus))
;
2371 if (new_size > using_hint[i].size) {
2372 total_size += (new_size
2373 - using_hint[i].size);
2374 extra_bonus -= (new_size
2375 - using_hint[i].size);
2376 using_hint[i].size = new_size;
2377 }
2378 }
2379
2380 if (using_hint[i].size == applets_hints[i].hints[using_hint[i].index])
2381 full_hints++;
2382 }
2383 }
2384
2385 return total_size;
2386}
2387
2388static void
2389panel_toplevel_update_size (PanelToplevel *toplevel,
2390 GtkRequisition *requisition)
2391{
2392 GtkWidget *widget;
2393 GtkStyleContext *context;
2394 GtkStateFlags state;
2395 GtkBorder padding;
2396 GdkRectangle monitor_geom;
2397 int width, height;
2398 int minimum_height;
2399 int non_panel_widget_size;
2400
2401 if (toplevel->priv->animating)
2402 return;
2403
2404 widget = GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
;
2405 context = gtk_widget_get_style_context (widget);
2406 state = gtk_widget_get_state_flags (widget);
2407 gtk_style_context_get_padding (context, state, &padding);
2408
2409 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
2410
2411 width = requisition->width;
2412 height = requisition->height;
2413
2414 if (!toplevel->priv->expand &&
2415 !toplevel->priv->buttons_enabled && !toplevel->priv->attached)
2416 non_panel_widget_size = 2 * HANDLE_SIZE10;
2417 else
2418 non_panel_widget_size = 0;
2419
2420 minimum_height = calculate_minimum_height (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
,
2421 toplevel->priv->orientation);
2422
2423 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)) {
2424
2425 height = MAX (MIN (MAX (height, toplevel->priv->size),(((((((((height) > (toplevel->priv->size)) ? (height
) : (toplevel->priv->size))) < (panel_toplevel_get_maximum_size
(toplevel))) ? ((((height) > (toplevel->priv->size)
) ? (height) : (toplevel->priv->size))) : (panel_toplevel_get_maximum_size
(toplevel)))) > (minimum_height)) ? (((((((height) > (
toplevel->priv->size)) ? (height) : (toplevel->priv->
size))) < (panel_toplevel_get_maximum_size (toplevel))) ? (
(((height) > (toplevel->priv->size)) ? (height) : (toplevel
->priv->size))) : (panel_toplevel_get_maximum_size (toplevel
)))) : (minimum_height))
2426 panel_toplevel_get_maximum_size (toplevel)),(((((((((height) > (toplevel->priv->size)) ? (height
) : (toplevel->priv->size))) < (panel_toplevel_get_maximum_size
(toplevel))) ? ((((height) > (toplevel->priv->size)
) ? (height) : (toplevel->priv->size))) : (panel_toplevel_get_maximum_size
(toplevel)))) > (minimum_height)) ? (((((((height) > (
toplevel->priv->size)) ? (height) : (toplevel->priv->
size))) < (panel_toplevel_get_maximum_size (toplevel))) ? (
(((height) > (toplevel->priv->size)) ? (height) : (toplevel
->priv->size))) : (panel_toplevel_get_maximum_size (toplevel
)))) : (minimum_height))
2427 minimum_height)(((((((((height) > (toplevel->priv->size)) ? (height
) : (toplevel->priv->size))) < (panel_toplevel_get_maximum_size
(toplevel))) ? ((((height) > (toplevel->priv->size)
) ? (height) : (toplevel->priv->size))) : (panel_toplevel_get_maximum_size
(toplevel)))) > (minimum_height)) ? (((((((height) > (
toplevel->priv->size)) ? (height) : (toplevel->priv->
size))) < (panel_toplevel_get_maximum_size (toplevel))) ? (
(((height) > (toplevel->priv->size)) ? (height) : (toplevel
->priv->size))) : (panel_toplevel_get_maximum_size (toplevel
)))) : (minimum_height))
;
2428
2429 if (toplevel->priv->expand)
2430 width = monitor_geom.width;
2431 else {
2432 int max_width;
2433
2434 if (!toplevel->priv->attached)
2435 max_width = monitor_geom.width;
2436 else {
2437 if (panel_toplevel_get_orientation (toplevel->priv->attach_toplevel) == PANEL_ORIENTATION_LEFT)
2438 max_width = monitor_geom.width
2439 - toplevel->priv->geometry.x;
2440 else
2441 max_width = toplevel->priv->geometry.x +
2442 toplevel->priv->geometry.width;
2443 }
2444
2445 width = panel_toplevel_update_size_from_hints (
2446 toplevel,
2447 requisition->width,
2448 max_width,
2449 non_panel_widget_size);
2450 }
2451
2452 width = MAX (MINIMUM_WIDTH, width)(((100) > (width)) ? (100) : (width));
2453 } else {
2454 width = MAX (MIN (MAX (width, toplevel->priv->size),(((((((((width) > (toplevel->priv->size)) ? (width) :
(toplevel->priv->size))) < (panel_toplevel_get_maximum_size
(toplevel))) ? ((((width) > (toplevel->priv->size))
? (width) : (toplevel->priv->size))) : (panel_toplevel_get_maximum_size
(toplevel)))) > (minimum_height)) ? (((((((width) > (toplevel
->priv->size)) ? (width) : (toplevel->priv->size)
)) < (panel_toplevel_get_maximum_size (toplevel))) ? ((((width
) > (toplevel->priv->size)) ? (width) : (toplevel->
priv->size))) : (panel_toplevel_get_maximum_size (toplevel
)))) : (minimum_height))
2455 panel_toplevel_get_maximum_size (toplevel)),(((((((((width) > (toplevel->priv->size)) ? (width) :
(toplevel->priv->size))) < (panel_toplevel_get_maximum_size
(toplevel))) ? ((((width) > (toplevel->priv->size))
? (width) : (toplevel->priv->size))) : (panel_toplevel_get_maximum_size
(toplevel)))) > (minimum_height)) ? (((((((width) > (toplevel
->priv->size)) ? (width) : (toplevel->priv->size)
)) < (panel_toplevel_get_maximum_size (toplevel))) ? ((((width
) > (toplevel->priv->size)) ? (width) : (toplevel->
priv->size))) : (panel_toplevel_get_maximum_size (toplevel
)))) : (minimum_height))
2456 minimum_height)(((((((((width) > (toplevel->priv->size)) ? (width) :
(toplevel->priv->size))) < (panel_toplevel_get_maximum_size
(toplevel))) ? ((((width) > (toplevel->priv->size))
? (width) : (toplevel->priv->size))) : (panel_toplevel_get_maximum_size
(toplevel)))) > (minimum_height)) ? (((((((width) > (toplevel
->priv->size)) ? (width) : (toplevel->priv->size)
)) < (panel_toplevel_get_maximum_size (toplevel))) ? ((((width
) > (toplevel->priv->size)) ? (width) : (toplevel->
priv->size))) : (panel_toplevel_get_maximum_size (toplevel
)))) : (minimum_height))
;
2457
2458 if (toplevel->priv->expand)
2459 height = monitor_geom.height;
2460 else {
2461 int max_height;
2462
2463 if (!toplevel->priv->attached)
2464 max_height = monitor_geom.height;
2465 else {
2466 if (panel_toplevel_get_orientation (toplevel->priv->attach_toplevel) == PANEL_ORIENTATION_TOP)
2467 max_height = monitor_geom.height
2468 - toplevel->priv->geometry.y;
2469 else
2470 max_height = toplevel->priv->geometry.y +
2471 toplevel->priv->geometry.height;
2472 }
2473
2474 height = panel_toplevel_update_size_from_hints (
2475 toplevel,
2476 requisition->height,
2477 max_height,
2478 non_panel_widget_size);
2479 }
2480
2481 height = MAX (MINIMUM_WIDTH, height)(((100) > (height)) ? (100) : (height));
2482 }
2483
2484 if (toplevel->priv->edges & PANEL_EDGE_TOP)
2485 height += padding.top;
2486 if (toplevel->priv->edges & PANEL_EDGE_BOTTOM)
2487 height += padding.bottom;
2488 if (toplevel->priv->edges & PANEL_EDGE_LEFT)
2489 width += padding.left;
2490 if (toplevel->priv->edges & PANEL_EDGE_RIGHT)
2491 width += padding.right;
2492
2493 toplevel->priv->geometry.width = CLAMP (width, 0, monitor_geom.width)(((width) > (monitor_geom.width)) ? (monitor_geom.width) :
(((width) < (0)) ? (0) : (width)))
;
2494 toplevel->priv->geometry.height = CLAMP (height, 0, monitor_geom.height)(((height) > (monitor_geom.height)) ? (monitor_geom.height
) : (((height) < (0)) ? (0) : (height)))
;
2495 toplevel->priv->original_width = toplevel->priv->geometry.width;
2496 toplevel->priv->original_height = toplevel->priv->geometry.height;
2497}
2498
2499static void
2500panel_toplevel_update_geometry (PanelToplevel *toplevel,
2501 GtkRequisition *requisition)
2502{
2503 toplevel->priv->updated_geometry_initial = TRUE(!(0));
2504 panel_toplevel_update_size (toplevel, requisition);
2505 panel_toplevel_update_position (toplevel);
2506
2507 panel_toplevel_update_struts (toplevel, FALSE(0));
2508
2509#ifdef HAVE_X111
2510 if (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel)))(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gtk_widget_get_display (((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((toplevel)), ((gtk_widget_get_type ()))))
))))); GType __t = ((gdk_x11_display_get_type())); gboolean __r
; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
) {
2511 if (toplevel->priv->state == PANEL_STATE_NORMAL ||
2512 toplevel->priv->state != PANEL_STATE_AUTO_HIDDEN) {
2513 panel_struts_update_toplevel_geometry (toplevel,
2514 &toplevel->priv->geometry.x,
2515 &toplevel->priv->geometry.y,
2516 &toplevel->priv->geometry.width,
2517 &toplevel->priv->geometry.height);
2518 } else {
2519 panel_struts_update_toplevel_geometry (toplevel,
2520 &toplevel->priv->geometry.x,
2521 &toplevel->priv->geometry.y,
2522 NULL((void*)0), NULL((void*)0));
2523 }
2524 }
2525#endif /* HAVE_X11 */
2526
2527 panel_toplevel_update_edges (toplevel);
2528 panel_toplevel_update_description (toplevel);
2529}
2530
2531static void
2532panel_toplevel_attach_widget_destroyed (PanelToplevel *toplevel)
2533{
2534 panel_toplevel_detach (toplevel);
2535}
2536
2537static gboolean
2538panel_toplevel_attach_widget_configure (PanelToplevel *toplevel)
2539{
2540 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
2541
2542 return FALSE(0);
2543}
2544
2545static void
2546panel_toplevel_update_attach_orientation (PanelToplevel *toplevel)
2547{
2548 PanelOrientation attach_orientation;
2549 PanelOrientation orientation;
2550
2551 attach_orientation =
2552 panel_toplevel_get_orientation (toplevel->priv->attach_toplevel);
2553
2554 orientation = toplevel->priv->orientation;
Value stored to 'orientation' is never read
2555
2556 switch (attach_orientation) {
2557 case PANEL_ORIENTATION_TOP:
2558 orientation = PANEL_ORIENTATION_LEFT;
2559 break;
2560 case PANEL_ORIENTATION_BOTTOM:
2561 orientation = PANEL_ORIENTATION_RIGHT;
2562 break;
2563 case PANEL_ORIENTATION_LEFT:
2564 orientation = PANEL_ORIENTATION_TOP;
2565 break;
2566 case PANEL_ORIENTATION_RIGHT:
2567 orientation = PANEL_ORIENTATION_BOTTOM;
2568 break;
2569 default:
2570 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 2570, ((const char*) (__func__)), ((void*)0)); } while (0)
;
2571 break;
2572 }
2573
2574 panel_toplevel_set_orientation (toplevel, orientation);
2575}
2576
2577static void
2578panel_toplevel_attach_widget_parent_set (PanelToplevel *toplevel,
2579 GtkWidget *previous_parent,
2580 GtkWidget *attach_widget)
2581{
2582 GtkWidget *panel_widget;
2583
2584 panel_widget = gtk_widget_get_parent (GTK_WIDGET (attach_widget)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((attach_widget)), ((gtk_widget_get_type ()))))))
);
2585 if (!panel_widget)
2586 return;
2587
2588 g_assert (PANEL_IS_WIDGET (panel_widget))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((panel_widget)); GType __t = ((panel_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_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 2588, ((const char*) (__func__)), "PANEL_IS_WIDGET (panel_widget)"
); } while (0)
;
2589
2590 toplevel->priv->attach_toplevel = PANEL_WIDGET (panel_widget)((((PanelWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((panel_widget)), ((panel_widget_get_type()))))))
->toplevel;
2591 panel_toplevel_update_attach_orientation (toplevel);
2592 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
2593}
2594
2595static void
2596panel_toplevel_attach_toplevel_hiding (PanelToplevel *toplevel)
2597{
2598 if (!panel_toplevel_get_is_hidden (toplevel)) {
2599 panel_toplevel_hide (toplevel, FALSE(0), -1);
2600
2601 toplevel->priv->attach_hidden = TRUE(!(0));
2602 }
2603}
2604
2605static void
2606panel_toplevel_attach_toplevel_unhiding (PanelToplevel *toplevel)
2607{
2608 if (!toplevel->priv->attach_hidden)
2609 return;
2610
2611 toplevel->priv->attach_hidden = FALSE(0);
2612
2613 panel_toplevel_unhide (toplevel);
2614}
2615
2616static void
2617panel_toplevel_reverse_arrow (PanelToplevel *toplevel,
2618 GtkWidget *button)
2619{
2620 GtkArrowType arrow_type;
2621
2622 arrow_type = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button), "arrow-type"))((gint) (glong) (g_object_get_data (((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((button)), (((GType) ((20) << (2)))
))))), "arrow-type")))
;
2623
2624 switch (arrow_type) {
2625 case GTK_ARROW_UP:
2626 arrow_type = GTK_ARROW_DOWN;
2627 break;
2628 case GTK_ARROW_DOWN:
2629 arrow_type = GTK_ARROW_UP;
2630 break;
2631 case GTK_ARROW_LEFT:
2632 arrow_type = GTK_ARROW_RIGHT;
2633 break;
2634 case GTK_ARROW_RIGHT:
2635 arrow_type = GTK_ARROW_LEFT;
2636 break;
2637 default:
2638 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 2638, ((const char*) (__func__)), ((void*)0)); } while (0)
;
2639 break;
2640 }
2641
2642 g_object_set_data (G_OBJECT (button)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), (((GType) ((20) << (2))))))))
, "arrow-type", GINT_TO_POINTER (arrow_type)((gpointer) (glong) (arrow_type)));
2643
2644 set_arrow_type (GTK_IMAGE (gtk_bin_get_child (GTK_BIN (button)))((((GtkImage*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_bin_get_child (((((GtkBin*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((button)), ((gtk_bin_get_type ())))))))))
, ((gtk_image_get_type ()))))))
, arrow_type);
2645}
2646
2647static void
2648panel_toplevel_reverse_arrows (PanelToplevel *toplevel)
2649{
2650 panel_toplevel_reverse_arrow (toplevel, toplevel->priv->hide_button_top);
2651 panel_toplevel_reverse_arrow (toplevel, toplevel->priv->hide_button_bottom);
2652 panel_toplevel_reverse_arrow (toplevel, toplevel->priv->hide_button_left);
2653 panel_toplevel_reverse_arrow (toplevel, toplevel->priv->hide_button_right);
2654}
2655
2656static void
2657panel_toplevel_disconnect_attached (PanelToplevel *toplevel)
2658{
2659 guint i;
2660
2661#if GLIB_CHECK_VERSION(2,62,0)(2 > (2) || (2 == (2) && 80 > (62)) || (2 == (2
) && 80 == (62) && 2 >= (0)))
2662 for (i = 0; i < N_ATTACH_TOPLEVEL_SIGNALS5; i++) {
2663 g_clear_signal_handler (&toplevel->priv->attach_toplevel_signals [i],do { gpointer const _instance = (toplevel->priv->attach_toplevel
); gulong *const _handler_id_ptr = (&toplevel->priv->
attach_toplevel_signals [i]); const gulong _handler_id = *_handler_id_ptr
; if (_handler_id > 0) { *_handler_id_ptr = 0; g_signal_handler_disconnect
(_instance, _handler_id); } } while (0)
2664 toplevel->priv->attach_toplevel)do { gpointer const _instance = (toplevel->priv->attach_toplevel
); gulong *const _handler_id_ptr = (&toplevel->priv->
attach_toplevel_signals [i]); const gulong _handler_id = *_handler_id_ptr
; if (_handler_id > 0) { *_handler_id_ptr = 0; g_signal_handler_disconnect
(_instance, _handler_id); } } while (0)
;
2665 }
2666
2667 for (i = 0; i < N_ATTACH_WIDGET_SIGNALS5; i++) {
2668 g_clear_signal_handler (&toplevel->priv->attach_widget_signals [i],do { gpointer const _instance = (toplevel->priv->attach_widget
); gulong *const _handler_id_ptr = (&toplevel->priv->
attach_widget_signals [i]); const gulong _handler_id = *_handler_id_ptr
; if (_handler_id > 0) { *_handler_id_ptr = 0; g_signal_handler_disconnect
(_instance, _handler_id); } } while (0)
2669 toplevel->priv->attach_widget)do { gpointer const _instance = (toplevel->priv->attach_widget
); gulong *const _handler_id_ptr = (&toplevel->priv->
attach_widget_signals [i]); const gulong _handler_id = *_handler_id_ptr
; if (_handler_id > 0) { *_handler_id_ptr = 0; g_signal_handler_disconnect
(_instance, _handler_id); } } while (0)
;
2670 }
2671#else
2672 for (i = 0; i < N_ATTACH_TOPLEVEL_SIGNALS5; i++) {
2673 if (toplevel->priv->attach_toplevel_signals [i] != 0) {
2674 g_signal_handler_disconnect (toplevel->priv->attach_toplevel,
2675 toplevel->priv->attach_toplevel_signals [i]);
2676 toplevel->priv->attach_toplevel_signals [i] = 0;
2677 }
2678 }
2679
2680 for (i = 0; i < N_ATTACH_WIDGET_SIGNALS5; i++) {
2681 if (toplevel->priv->attach_widget_signals [i] != 0) {
2682 g_signal_handler_disconnect (toplevel->priv->attach_widget,
2683 toplevel->priv->attach_widget_signals [i]);
2684 toplevel->priv->attach_widget_signals [i] = 0;
2685 }
2686 }
2687#endif
2688}
2689
2690static void
2691panel_toplevel_connect_attached (PanelToplevel *toplevel)
2692{
2693 gulong *signals;
2694 int i = 0;
2695
2696 signals = toplevel->priv->attach_toplevel_signals;
2697
2698 signals [i++] = g_signal_connect_swapped (g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("destroy"), (((GCallback) (panel_toplevel_attach_widget_destroyed
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2699 toplevel->priv->attach_toplevel, "destroy",g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("destroy"), (((GCallback) (panel_toplevel_attach_widget_destroyed
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2700 G_CALLBACK (panel_toplevel_attach_widget_destroyed), toplevel)g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("destroy"), (((GCallback) (panel_toplevel_attach_widget_destroyed
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
;
2701 signals [i++] = g_signal_connect_swapped (g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("notify::orientation"), (((GCallback) (panel_toplevel_update_attach_orientation
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2702 toplevel->priv->attach_toplevel, "notify::orientation",g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("notify::orientation"), (((GCallback) (panel_toplevel_update_attach_orientation
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2703 G_CALLBACK (panel_toplevel_update_attach_orientation), toplevel)g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("notify::orientation"), (((GCallback) (panel_toplevel_update_attach_orientation
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
;
2704 signals [i++] = g_signal_connect_swapped (g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("configure-event"), (((GCallback) (panel_toplevel_attach_widget_configure
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2705 toplevel->priv->attach_toplevel, "configure-event",g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("configure-event"), (((GCallback) (panel_toplevel_attach_widget_configure
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2706 G_CALLBACK (panel_toplevel_attach_widget_configure), toplevel)g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("configure-event"), (((GCallback) (panel_toplevel_attach_widget_configure
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
;
2707 signals [i++] = g_signal_connect_swapped (g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("hiding"), (((GCallback) (panel_toplevel_attach_toplevel_hiding
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2708 toplevel->priv->attach_toplevel, "hiding",g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("hiding"), (((GCallback) (panel_toplevel_attach_toplevel_hiding
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2709 G_CALLBACK (panel_toplevel_attach_toplevel_hiding), toplevel)g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("hiding"), (((GCallback) (panel_toplevel_attach_toplevel_hiding
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
;
2710 signals [i++] = g_signal_connect_swapped (g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("unhiding"), (((GCallback) (panel_toplevel_attach_toplevel_unhiding
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2711 toplevel->priv->attach_toplevel, "unhiding",g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("unhiding"), (((GCallback) (panel_toplevel_attach_toplevel_unhiding
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2712 G_CALLBACK (panel_toplevel_attach_toplevel_unhiding), toplevel)g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("unhiding"), (((GCallback) (panel_toplevel_attach_toplevel_unhiding
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
;
2713
2714 g_assert (i == N_ATTACH_TOPLEVEL_SIGNALS)do { if (i == 5) ; else g_assertion_message_expr (((gchar*) 0
), "panel-toplevel.c", 2714, ((const char*) (__func__)), "i == N_ATTACH_TOPLEVEL_SIGNALS"
); } while (0)
;
2715
2716 signals = toplevel->priv->attach_widget_signals;
2717 i = 0;
2718
2719 signals [i++] = g_signal_connect_swapped (g_signal_connect_data ((toplevel->priv->attach_widget),
("destroy"), (((GCallback) (panel_toplevel_attach_widget_destroyed
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2720 toplevel->priv->attach_widget, "destroy",g_signal_connect_data ((toplevel->priv->attach_widget),
("destroy"), (((GCallback) (panel_toplevel_attach_widget_destroyed
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2721 G_CALLBACK (panel_toplevel_attach_widget_destroyed), toplevel)g_signal_connect_data ((toplevel->priv->attach_widget),
("destroy"), (((GCallback) (panel_toplevel_attach_widget_destroyed
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
;
2722 signals [i++] = g_signal_connect_swapped (g_signal_connect_data ((toplevel->priv->attach_widget),
("configure-event"), (((GCallback) (panel_toplevel_attach_widget_configure
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2723 toplevel->priv->attach_widget, "configure-event",g_signal_connect_data ((toplevel->priv->attach_widget),
("configure-event"), (((GCallback) (panel_toplevel_attach_widget_configure
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2724 G_CALLBACK (panel_toplevel_attach_widget_configure), toplevel)g_signal_connect_data ((toplevel->priv->attach_widget),
("configure-event"), (((GCallback) (panel_toplevel_attach_widget_configure
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
;
2725 signals [i++] = g_signal_connect_swapped (g_signal_connect_data ((toplevel->priv->attach_widget),
("parent-set"), (((GCallback) (panel_toplevel_attach_widget_parent_set
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2726 toplevel->priv->attach_widget, "parent-set",g_signal_connect_data ((toplevel->priv->attach_widget),
("parent-set"), (((GCallback) (panel_toplevel_attach_widget_parent_set
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2727 G_CALLBACK (panel_toplevel_attach_widget_parent_set), toplevel)g_signal_connect_data ((toplevel->priv->attach_widget),
("parent-set"), (((GCallback) (panel_toplevel_attach_widget_parent_set
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
;
2728 signals [i++] = g_signal_connect_swapped (g_signal_connect_data ((toplevel->priv->attach_widget),
("show"), (((GCallback) (gtk_widget_show))), (toplevel), ((void
*)0), G_CONNECT_SWAPPED)
2729 toplevel->priv->attach_widget, "show",g_signal_connect_data ((toplevel->priv->attach_widget),
("show"), (((GCallback) (gtk_widget_show))), (toplevel), ((void
*)0), G_CONNECT_SWAPPED)
2730 G_CALLBACK (gtk_widget_show), toplevel)g_signal_connect_data ((toplevel->priv->attach_widget),
("show"), (((GCallback) (gtk_widget_show))), (toplevel), ((void
*)0), G_CONNECT_SWAPPED)
;
2731 signals [i++] = g_signal_connect_swapped (g_signal_connect_data ((toplevel->priv->attach_widget),
("hide"), (((GCallback) (gtk_widget_hide))), (toplevel), ((void
*)0), G_CONNECT_SWAPPED)
2732 toplevel->priv->attach_widget, "hide",g_signal_connect_data ((toplevel->priv->attach_widget),
("hide"), (((GCallback) (gtk_widget_hide))), (toplevel), ((void
*)0), G_CONNECT_SWAPPED)
2733 G_CALLBACK (gtk_widget_hide), toplevel)g_signal_connect_data ((toplevel->priv->attach_widget),
("hide"), (((GCallback) (gtk_widget_hide))), (toplevel), ((void
*)0), G_CONNECT_SWAPPED)
;
2734
2735 g_assert (i == N_ATTACH_WIDGET_SIGNALS)do { if (i == 5) ; else g_assertion_message_expr (((gchar*) 0
), "panel-toplevel.c", 2735, ((const char*) (__func__)), "i == N_ATTACH_WIDGET_SIGNALS"
); } while (0)
;
2736}
2737
2738void
2739panel_toplevel_attach_to_widget (PanelToplevel *toplevel,
2740 PanelToplevel *attach_toplevel,
2741 GtkWidget *attach_widget)
2742{
2743 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
2744 g_return_if_fail (PANEL_IS_TOPLEVEL (attach_toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((attach_toplevel)); GType __t = ((panel_toplevel_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0
), ((const char*) (__func__)), "PANEL_IS_TOPLEVEL (attach_toplevel)"
); return; } } while (0)
;
2745 g_return_if_fail (GTK_IS_WIDGET (attach_widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((attach_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 (((gchar*) 0), ((const
char*) (__func__)), "GTK_IS_WIDGET (attach_widget)"); return
; } } while (0)
;
2746
2747 if (toplevel->priv->attached)
2748 panel_toplevel_disconnect_attached (toplevel);
2749
2750 toplevel->priv->attached = TRUE(!(0));
2751
2752 /* Cancelling the initial animation for drawers in
2753 * panel_toplevel_initially_hide() is not enough, since this will
2754 * happen only when the toplevel is realized, which might be too late
2755 * for drawers (since it's realized when the drawer is clicked) */
2756 toplevel->priv->initial_animation_done = TRUE(!(0));
2757
2758 toplevel->priv->attach_toplevel = attach_toplevel;
2759 toplevel->priv->attach_widget = attach_widget;
2760
2761 panel_toplevel_connect_attached (toplevel);
2762
2763 panel_toplevel_reverse_arrows (toplevel);
2764 panel_toplevel_set_expand (toplevel, FALSE(0));
2765 panel_toplevel_update_attach_orientation (toplevel);
2766 panel_toplevel_update_hide_buttons (toplevel);
2767
2768 gtk_window_set_screen (GTK_WINDOW (toplevel)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_window_get_type ()))))))
,
2769 gtk_widget_get_screen (GTK_WIDGET (attach_toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((attach_toplevel)), ((gtk_widget_get_type ()))))))
));
2770 panel_toplevel_set_monitor (toplevel,
2771 panel_toplevel_get_monitor (attach_toplevel));
2772 if (toplevel->priv->state == PANEL_STATE_NORMAL)
2773 panel_toplevel_push_autohide_disabler (toplevel->priv->attach_toplevel);
2774
2775 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
2776}
2777
2778void
2779panel_toplevel_detach (PanelToplevel *toplevel)
2780{
2781 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
2782
2783 if (!toplevel->priv->attached)
2784 return;
2785
2786 if (toplevel->priv->state == PANEL_STATE_NORMAL)
2787 panel_toplevel_pop_autohide_disabler (toplevel->priv->attach_toplevel);
2788
2789 panel_toplevel_disconnect_attached (toplevel);
2790
2791 panel_toplevel_reverse_arrows (toplevel);
2792
2793 toplevel->priv->attached = FALSE(0);
2794
2795 toplevel->priv->attach_toplevel = NULL((void*)0);
2796 toplevel->priv->attach_widget = NULL((void*)0);
2797
2798 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
2799}
2800
2801gboolean
2802panel_toplevel_get_is_attached (PanelToplevel *toplevel)
2803{
2804 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return ((0));
} } while (0)
;
2805
2806 return toplevel->priv->attached;
2807}
2808
2809PanelToplevel *
2810panel_toplevel_get_attach_toplevel (PanelToplevel *toplevel)
2811{
2812 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return (((void
*)0)); } } while (0)
;
2813
2814 return toplevel->priv->attach_toplevel;
2815}
2816
2817GtkWidget *
2818panel_toplevel_get_attach_widget (PanelToplevel *toplevel)
2819{
2820 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return (((void
*)0)); } } while (0)
;
2821
2822 return toplevel->priv->attach_widget;
2823}
2824
2825static gboolean
2826panel_toplevel_popup_panel_menu (PanelToplevel *toplevel)
2827{
2828 gboolean retval = FALSE(0);
2829
2830 g_signal_emit_by_name (toplevel, "popup-menu", &retval);
2831
2832 return retval;
2833}
2834
2835static gboolean
2836panel_toplevel_toggle_expand (PanelToplevel *toplevel)
2837{
2838 panel_toplevel_set_expand (toplevel, !toplevel->priv->expand);
2839
2840 return TRUE(!(0));
2841}
2842
2843static gboolean
2844panel_toplevel_expand (PanelToplevel *toplevel)
2845{
2846 panel_toplevel_set_expand (toplevel, TRUE(!(0)));
2847
2848 return TRUE(!(0));
2849}
2850
2851static gboolean
2852panel_toplevel_unexpand (PanelToplevel *toplevel)
2853{
2854 panel_toplevel_set_expand (toplevel, FALSE(0));
2855
2856 return TRUE(!(0));
2857}
2858
2859static gboolean
2860panel_toplevel_toggle_hidden (PanelToplevel *toplevel)
2861{
2862 if (toplevel->priv->state == PANEL_STATE_NORMAL)
2863 panel_toplevel_hide (toplevel, toplevel->priv->auto_hide, -1);
2864 else
2865 panel_toplevel_unhide (toplevel);
2866
2867 return FALSE(0);
2868}
2869
2870static gboolean
2871panel_toplevel_begin_move (PanelToplevel *toplevel)
2872{
2873 if (toplevel->priv->grab_op != PANEL_GRAB_OP_NONE)
2874 return FALSE(0);
2875
2876 panel_toplevel_begin_grab_op (
2877 toplevel, PANEL_GRAB_OP_MOVE, TRUE(!(0)), GDK_CURRENT_TIME0L);
2878
2879 return TRUE(!(0));
2880}
2881
2882static gboolean
2883panel_toplevel_begin_resize (PanelToplevel *toplevel)
2884{
2885 if (toplevel->priv->grab_op != PANEL_GRAB_OP_NONE)
2886 return FALSE(0);
2887
2888 panel_toplevel_begin_grab_op (
2889 toplevel, PANEL_GRAB_OP_RESIZE, TRUE(!(0)), GDK_CURRENT_TIME0L);
2890
2891 return TRUE(!(0));
2892}
2893
2894static void
2895panel_toplevel_move_resize_window (PanelToplevel *toplevel,
2896 gboolean move,
2897 gboolean resize)
2898{
2899 GtkWidget *widget;
2900
2901 GList *list;
2902 gboolean stick;
2903
2904 widget = GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
;
2905
2906 g_assert (gtk_widget_get_realized (widget))do { if (gtk_widget_get_realized (widget)) ; else g_assertion_message_expr
(((gchar*) 0), "panel-toplevel.c", 2906, ((const char*) (__func__
)), "gtk_widget_get_realized (widget)"); } while (0)
;
2907
2908 if (move && resize)
2909 gdk_window_move_resize (gtk_widget_get_window (widget),
2910 toplevel->priv->geometry.x,
2911 toplevel->priv->geometry.y,
2912 toplevel->priv->geometry.width,
2913 toplevel->priv->geometry.height);
2914 else if (move)
2915 gdk_window_move (gtk_widget_get_window (widget),
2916 toplevel->priv->geometry.x,
2917 toplevel->priv->geometry.y);
2918 else if (resize)
2919 gdk_window_resize (gtk_widget_get_window (widget),
2920 toplevel->priv->geometry.width,
2921 toplevel->priv->geometry.height);
2922
2923 if (resize || move) {
2924 for (list = toplevel->priv->panel_widget->applet_list; list != NULL((void*)0); list = g_list_next (list)((list) ? (((GList *)(list))->next) : ((void*)0))) {
2925 AppletData *ad = list->data;
2926 const char *id = mate_panel_applet_get_id_by_widget (ad->applet);
2927
2928 if (!id)
2929 return;
2930
2931 AppletInfo *info;
2932 info = mate_panel_applet_get_by_id (id);
2933
2934 stick = g_settings_get_boolean (info->settings, PANEL_OBJECT_PANEL_RIGHT_STICK_KEY"panel-right-stick");
2935
2936 if (stick) {
2937 int position = g_settings_get_int (info->settings, PANEL_OBJECT_POSITION_KEY"position");
2938 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)) {
2939 ad->pos = toplevel->priv->geometry.width - position;
2940 } else {
2941 ad->pos = toplevel->priv->geometry.height - position;
2942 }
2943 }
2944 }
2945 }
2946}
2947
2948static void
2949panel_toplevel_initially_hide (PanelToplevel *toplevel)
2950{
2951 if (!toplevel->priv->attached) {
2952 toplevel->priv->initial_animation_done = FALSE(0);
2953
2954 /* We start the panel off hidden until all the applets are
2955 * loaded, and then finally slide it down when it's ready to be
2956 * used */
2957 toplevel->priv->state = PANEL_STATE_AUTO_HIDDEN;
2958 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
2959 } else
2960 toplevel->priv->initial_animation_done = TRUE(!(0));
2961}
2962
2963static void
2964set_background_default_style (GtkWidget *widget)
2965{
2966 PanelToplevel *toplevel;
2967 GtkStyleContext *context;
2968 GtkStateFlags state;
2969 GdkRGBA *bg_color;
2970 cairo_pattern_t *bg_image;
2971
2972 if (!gtk_widget_get_realized (widget))
2973 return;
2974
2975 toplevel = PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
;
2976
2977 context = gtk_widget_get_style_context (widget);
2978 state = gtk_style_context_get_state (context);
2979
2980 gtk_style_context_get (context, state,
2981 "background-color", &bg_color,
2982 "background-image", &bg_image,
2983 NULL((void*)0));
2984
2985 panel_background_set_default_style (&toplevel->background,
2986 bg_color, bg_image);
2987
2988 if (bg_color)
2989 gdk_rgba_free (bg_color);
2990
2991 if (bg_image)
2992 cairo_pattern_destroy (bg_image);
2993}
2994
2995static void
2996panel_toplevel_realize (GtkWidget *widget)
2997{
2998 PanelToplevel *toplevel;
2999 GdkScreen *screen;
3000 GdkVisual *visual;
3001 GdkWindow *window;
3002
3003 toplevel = PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
;
3004
3005 screen = gtk_widget_get_screen (widget);
3006 visual = gdk_screen_get_rgba_visual (screen);
3007
3008 if (visual == NULL((void*)0))
3009 visual = gdk_screen_get_system_visual (screen);
3010
3011 gtk_widget_set_visual (widget, visual);
3012 gtk_window_stick (GTK_WINDOW (widget)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_window_get_type ()))))))
);
3013 gtk_window_set_decorated (GTK_WINDOW (widget)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_window_get_type ()))))))
, FALSE(0));
3014 gtk_window_stick (GTK_WINDOW (widget)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_window_get_type ()))))))
);
3015 gtk_window_set_type_hint (GTK_WINDOW (widget)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_window_get_type ()))))))
, GDK_WINDOW_TYPE_HINT_DOCK);
3016
3017 GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->realize (widget);
3018
3019 window = gtk_widget_get_window (widget);
3020 set_background_default_style (widget);
3021 panel_background_realized (&toplevel->background, window);
3022
3023#ifdef HAVE_X111
3024 if (GDK_IS_X11_WINDOW (window)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(window)); GType __t = ((gdk_x11_window_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
) {
3025 panel_struts_set_window_hint (toplevel);
3026 gdk_window_set_geometry_hints (window, NULL((void*)0), 0);
3027 }
3028#endif /* HAVE_X11 */
3029
3030 gdk_window_set_group (window, window);
3031 panel_toplevel_initially_hide (toplevel);
3032
3033 panel_toplevel_move_resize_window (toplevel, TRUE(!(0)), TRUE(!(0)));
3034}
3035
3036static void
3037panel_toplevel_disconnect_timeouts (PanelToplevel *toplevel)
3038{
3039 if (toplevel->priv->hide_timeout)
3040 g_source_remove (toplevel->priv->hide_timeout);
3041 toplevel->priv->hide_timeout = 0;
3042
3043 if (toplevel->priv->unhide_timeout)
3044 g_source_remove (toplevel->priv->unhide_timeout);
3045 toplevel->priv->unhide_timeout = 0;
3046
3047 if (toplevel->priv->animation_timeout)
3048 g_source_remove (toplevel->priv->animation_timeout);
3049 toplevel->priv->animation_timeout = 0;
3050}
3051
3052static void
3053panel_toplevel_unrealize (GtkWidget *widget)
3054{
3055 PanelToplevel *toplevel;
3056 toplevel = PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
;
3057 panel_toplevel_disconnect_timeouts (toplevel);
3058 panel_background_unrealized (&toplevel->background);
3059 GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->unrealize (widget);
3060}
3061
3062static void
3063panel_toplevel_dispose (GObject *widget)
3064{
3065 PanelToplevel *toplevel = (PanelToplevel *) widget;
3066
3067 g_clear_pointer (&toplevel->priv->settings_path, g_free)do { _Static_assert (sizeof *(&toplevel->priv->settings_path
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
((&toplevel->priv->settings_path)) _pp = (&toplevel
->priv->settings_path); __typeof__ (*(&toplevel->
priv->settings_path)) _ptr = *_pp; *_pp = ((void*)0); if (
_ptr) (g_free) (_ptr); } while (0)
;
3068
3069 if (toplevel->settings) {
3070 g_signal_handlers_disconnect_by_data (toplevel->settings, toplevel)g_signal_handlers_disconnect_matched ((toplevel->settings)
, G_SIGNAL_MATCH_DATA, 0, 0, ((void*)0), ((void*)0), (toplevel
))
;
3071 g_clear_object (&toplevel->settings)do { _Static_assert (sizeof *((&toplevel->settings)) ==
sizeof (gpointer), "Expression evaluates to false"); __typeof__
(((&toplevel->settings))) _pp = ((&toplevel->settings
)); __typeof__ (*((&toplevel->settings))) _ptr = *_pp;
*_pp = ((void*)0); if (_ptr) (g_object_unref) (_ptr); } while
(0)
;
3072 }
3073
3074 g_clear_object (&toplevel->queued_settings)do { _Static_assert (sizeof *((&toplevel->queued_settings
)) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(((&toplevel->queued_settings))) _pp = ((&toplevel
->queued_settings)); __typeof__ (*((&toplevel->queued_settings
))) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (g_object_unref
) (_ptr); } while (0)
;
3075
3076 if (toplevel->background_settings) {
3077 g_signal_handlers_disconnect_by_data (toplevel->background_settings, toplevel)g_signal_handlers_disconnect_matched ((toplevel->background_settings
), G_SIGNAL_MATCH_DATA, 0, 0, ((void*)0), ((void*)0), (toplevel
))
;
3078 g_clear_object (&toplevel->background_settings)do { _Static_assert (sizeof *((&toplevel->background_settings
)) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(((&toplevel->background_settings))) _pp = ((&toplevel
->background_settings)); __typeof__ (*((&toplevel->
background_settings))) _ptr = *_pp; *_pp = ((void*)0); if (_ptr
) (g_object_unref) (_ptr); } while (0)
;
3079 }
3080
3081 if (toplevel->priv->gtk_settings) {
3082 g_signal_handlers_disconnect_by_func (toplevel->priv->gtk_settings,g_signal_handlers_disconnect_matched ((toplevel->priv->
gtk_settings), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (panel_toplevel_drag_threshold_changed
))), (toplevel))
3083 G_CALLBACK (panel_toplevel_drag_threshold_changed),g_signal_handlers_disconnect_matched ((toplevel->priv->
gtk_settings), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (panel_toplevel_drag_threshold_changed
))), (toplevel))
3084 toplevel)g_signal_handlers_disconnect_matched ((toplevel->priv->
gtk_settings), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (panel_toplevel_drag_threshold_changed
))), (toplevel))
;
3085 toplevel->priv->gtk_settings = NULL((void*)0);
3086
3087 panel_background_free (&toplevel->background);
3088 }
3089
3090 if (toplevel->priv->attached) {
3091 panel_toplevel_disconnect_attached (toplevel);
3092 toplevel->priv->attached = FALSE(0);
3093
3094 toplevel->priv->attach_toplevel = NULL((void*)0);
3095 toplevel->priv->attach_widget = NULL((void*)0);
3096 }
3097
3098 g_clear_pointer (&toplevel->priv->description, g_free)do { _Static_assert (sizeof *(&toplevel->priv->description
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
((&toplevel->priv->description)) _pp = (&toplevel
->priv->description); __typeof__ (*(&toplevel->priv
->description)) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (
g_free) (_ptr); } while (0)
;
3099 g_clear_pointer (&toplevel->priv->name, g_free)do { _Static_assert (sizeof *(&toplevel->priv->name
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
((&toplevel->priv->name)) _pp = (&toplevel->
priv->name); __typeof__ (*(&toplevel->priv->name
)) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (g_free) (_ptr);
} while (0)
;
3100
3101 panel_toplevel_disconnect_timeouts (toplevel);
3102
3103 G_OBJECT_CLASS (panel_toplevel_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), (((GType) ((20) << (
2))))))))
->dispose (widget);
3104}
3105
3106static void
3107panel_toplevel_check_resize (GtkContainer *container)
3108{
3109 GtkAllocation allocation;
3110 GtkRequisition requisition;
3111 GtkWidget *widget;
3112
3113 widget = GTK_WIDGET (container)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((container)), ((gtk_widget_get_type ()))))))
;
3114
3115 if (!gtk_widget_get_visible (widget))
3116 return;
3117
3118 requisition.width = -1;
3119 requisition.height = -1;
3120
3121 gtk_widget_get_preferred_size (widget, &requisition, NULL((void*)0));
3122 gtk_widget_get_allocation (widget, &allocation);
3123
3124 allocation.width = requisition.width;
3125 allocation.height = requisition.height;
3126
3127 gtk_widget_size_allocate (widget, &allocation);
3128}
3129
3130static void
3131panel_toplevel_size_request (GtkWidget *widget,
3132 GtkRequisition *requisition)
3133{
3134 PanelToplevel *toplevel;
3135 GtkBin *bin;
3136 GtkWidget *child;
3137 GdkRectangle old_geometry;
3138 int position_changed = FALSE(0);
3139 int size_changed = FALSE(0);
3140
3141 toplevel = PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
;
3142 bin = GTK_BIN (widget)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_bin_get_type ()))))))
;
3143
3144 /* we get a size request when there are new monitors, so first try to
3145 * see if we need to move to a new monitor */
3146 panel_toplevel_update_monitor (toplevel);
3147
3148 child = gtk_bin_get_child (bin);
3149 if (child && gtk_widget_get_visible (child))
3150 gtk_widget_get_preferred_size (child, requisition, NULL((void*)0));
3151
3152 old_geometry = toplevel->priv->geometry;
3153
3154 panel_toplevel_update_geometry (toplevel, requisition);
3155
3156 requisition->width = toplevel->priv->geometry.width;
3157 requisition->height = toplevel->priv->geometry.height;
3158
3159 if (!gtk_widget_get_realized (widget))
3160 return;
3161
3162 if (old_geometry.width != toplevel->priv->geometry.width ||
3163 old_geometry.height != toplevel->priv->geometry.height)
3164 size_changed = TRUE(!(0));
3165
3166 if (old_geometry.x != toplevel->priv->geometry.x ||
3167 old_geometry.y != toplevel->priv->geometry.y)
3168 position_changed = TRUE(!(0));
3169
3170 panel_toplevel_move_resize_window (toplevel, position_changed, size_changed);
3171}
3172
3173static void
3174panel_toplevel_get_preferred_width (GtkWidget *widget,
3175 gint *minimum_width,
3176 gint *natural_width)
3177{
3178 GtkRequisition req;
3179 panel_toplevel_size_request (widget, &req);
3180 *minimum_width = *natural_width = req.width;
3181}
3182
3183static void
3184panel_toplevel_get_preferred_height (GtkWidget *widget,
3185 gint *minimum_height,
3186 gint *natural_height)
3187{
3188 GtkRequisition req;
3189 panel_toplevel_size_request (widget, &req);
3190 *minimum_height = *natural_height = req.height;
3191}
3192
3193static void
3194set_background_region (PanelToplevel *toplevel)
3195{
3196 GtkWidget *widget;
3197 GdkWindow *window;
3198 gint origin_x;
3199 gint origin_y;
3200 GtkAllocation allocation;
3201 GtkOrientation orientation;
3202
3203 widget = GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
;
3204
3205 if (!gtk_widget_get_realized (widget))
3206 return;
3207
3208 window = gtk_widget_get_window (widget);
3209 origin_x = -1;
3210 origin_y = -1;
3211
3212 gdk_window_get_origin (window, &origin_x, &origin_y);
3213 gtk_widget_get_allocation (widget, &allocation);
3214
3215 orientation = GTK_ORIENTATION_HORIZONTAL;
3216 if (toplevel->priv->orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT))
3217 orientation = GTK_ORIENTATION_VERTICAL;
3218
3219 panel_background_change_region (&toplevel->background, orientation,
3220 origin_x, origin_y,
3221 allocation.width, allocation.height);
3222}
3223
3224static void
3225panel_toplevel_size_allocate (GtkWidget *widget,
3226 GtkAllocation *allocation)
3227{
3228 PanelToplevel *toplevel = (PanelToplevel *) widget;
3229 GtkBin *bin = (GtkBin *) widget;
3230 GtkStyleContext *context;
3231 GtkStateFlags state;
3232 GtkBorder padding;
3233 GtkWidget *child;
3234 GtkAllocation challoc;
3235 GtkAllocation child_allocation;
3236
3237 gtk_widget_set_allocation (widget, allocation);
3238
3239 if (toplevel->priv->expand ||
3240 toplevel->priv->buttons_enabled ||
3241 toplevel->priv->attached)
3242 challoc = *allocation;
3243 else {
3244 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)) {
3245 challoc.x = HANDLE_SIZE10;
3246 challoc.y = 0;
3247 challoc.width = allocation->width - 2 * HANDLE_SIZE10;
3248 challoc.height = allocation->height;
3249 } else {
3250 challoc.x = 0;
3251 challoc.y = HANDLE_SIZE10;
3252 challoc.width = allocation->width;
3253 challoc.height = allocation->height - 2 * HANDLE_SIZE10;
3254 }
3255 }
3256
3257 state = gtk_widget_get_state_flags (widget);
3258 context = gtk_widget_get_style_context (widget);
3259 gtk_style_context_get_padding (context, state, &padding);
3260
3261 if (toplevel->priv->edges & PANEL_EDGE_TOP) {
3262 challoc.y += padding.top;
3263 challoc.height -= padding.top;
3264 }
3265
3266 if (toplevel->priv->edges & PANEL_EDGE_LEFT) {
3267 challoc.x += padding.left;
3268 challoc.width -= padding.left;
3269 }
3270
3271 if (toplevel->priv->edges & PANEL_EDGE_BOTTOM)
3272 challoc.height -= padding.bottom;
3273
3274 if (toplevel->priv->edges & PANEL_EDGE_RIGHT)
3275 challoc.width -= padding.right;
3276
3277 challoc.width = MAX (1, challoc.width)(((1) > (challoc.width)) ? (1) : (challoc.width));
3278 challoc.height = MAX (1, challoc.height)(((1) > (challoc.height)) ? (1) : (challoc.height));
3279
3280 child = gtk_bin_get_child (bin);
3281 gtk_widget_get_allocation (child, &child_allocation);
3282
3283 if (gtk_widget_get_mapped (widget) &&
3284 (challoc.x != child_allocation.x ||
3285 challoc.y != child_allocation.y ||
3286 challoc.width != child_allocation.width ||
3287 challoc.height != child_allocation.height)) {
3288 GtkAllocation allocation_to_invalidate;
3289
3290 gtk_widget_get_allocation (widget, &allocation_to_invalidate);
3291 gdk_window_invalidate_rect (gtk_widget_get_window (widget),
3292 &allocation_to_invalidate, FALSE(0));
3293 }
3294
3295 if (child && gtk_widget_get_visible (child))
3296 gtk_widget_size_allocate (child, &challoc);
3297
3298 set_background_region (toplevel);
3299}
3300
3301static gboolean panel_toplevel_draw(GtkWidget* widget, cairo_t* cr)
3302{
3303 PanelToplevel* toplevel = (PanelToplevel*) widget;
3304 PanelFrameEdge edges;
3305 gboolean retval = FALSE(0);
3306 int awidth;
3307 int aheight;
3308 GtkStyleContext *context;
3309 GtkStateFlags state;
3310 GtkBorder padding;
3311
3312 if (!gtk_widget_is_drawable (widget))
3313 return retval;
3314
3315 if (GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->draw)
3316 retval = GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->draw (widget, cr);
3317
3318 edges = toplevel->priv->edges;
3319 panel_frame_draw (widget, cr, edges);
3320
3321 if (toplevel->priv->expand ||
3322 toplevel->priv->buttons_enabled ||
3323 toplevel->priv->attached)
3324 return retval;
3325
3326 state = gtk_widget_get_state_flags (widget);
3327 awidth = gtk_widget_get_allocated_width (widget);
3328 aheight = gtk_widget_get_allocated_height (widget);
3329
3330 context = gtk_widget_get_style_context (widget);
3331 gtk_style_context_get_padding (context, state, &padding);
3332
3333 gtk_style_context_save (context);
3334 gtk_style_context_set_state (context, state);
3335
3336 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)) {
3337 int x, y, width, height;
3338
3339 x = 0;
3340 y = 0;
3341 height = aheight;
3342 width = HANDLE_SIZE10;
3343
3344 if (edges & PANEL_EDGE_TOP) {
3345 y += padding.top;
3346 height -= padding.top;
3347 }
3348 if (edges & PANEL_EDGE_BOTTOM)
3349 height -= padding.bottom;
3350 if (edges & PANEL_EDGE_LEFT)
3351 x += padding.left;
3352
3353 cairo_save (cr);
3354 gtk_render_handle (context, cr, x, y, width, height);
3355 cairo_restore (cr);
3356
3357 x = awidth - HANDLE_SIZE10;
3358 if (edges & PANEL_EDGE_RIGHT)
3359 x -= padding.right;
3360
3361 cairo_save (cr);
3362 gtk_render_handle (context, cr, x, y, width, height);
3363 cairo_restore (cr);
3364 } else {
3365 int x, y, width, height;
3366
3367 x = 0;
3368 y = 0;
3369 width = awidth;
3370 height = HANDLE_SIZE10;
3371
3372 if (edges & PANEL_EDGE_LEFT) {
3373 x += padding.left;
3374 width -= padding.left;
3375 }
3376 if (edges & PANEL_EDGE_RIGHT)
3377 width -= padding.right;
3378 if (edges & PANEL_EDGE_TOP)
3379 y += padding.top;
3380
3381 cairo_save (cr);
3382 gtk_render_handle (context, cr, x, y, width, height);
3383 cairo_restore (cr);
3384
3385 y = aheight - HANDLE_SIZE10;
3386 if (edges & PANEL_EDGE_BOTTOM)
3387 y -= padding.bottom;
3388
3389 cairo_save (cr);
3390 gtk_render_handle (context, cr, x, y, width, height);
3391 cairo_restore (cr);
3392 }
3393
3394 gtk_style_context_restore (context);
3395
3396 return retval;
3397}
3398
3399static gboolean
3400panel_toplevel_button_press_event (GtkWidget *widget,
3401 GdkEventButton *event)
3402{
3403 PanelToplevel *toplevel;
3404 GtkWidget *event_widget;
3405
3406 g_return_val_if_fail (PANEL_IS_TOPLEVEL (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (widget)"); return ((0)); }
} while (0)
;
3407
3408 toplevel = PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
;
3409
3410 if (event->button != 1 && event->button != 2)
3411 return FALSE(0);
3412
3413 if (toplevel->priv->animating)
3414 return FALSE(0);
3415
3416 /* Get the mouse-button modifier from marco so that only intentional
3417 * moves are considered. We don't this for non-expanded panels since we
3418 * only have the handles that the user can grab. */
3419 if ((toplevel->priv->expand || toplevel->priv->attached) &&
3420 (event->state & GDK_MODIFIER_MASK) != panel_bindings_get_mouse_button_modifier_keymask ())
3421 return FALSE(0);
3422
3423 gdk_window_get_user_data (event->window, (gpointer)&event_widget);
3424 g_assert (GTK_IS_WIDGET (event_widget))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((event_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_assertion_message_expr (((gchar*) 0), "panel-toplevel.c", 3424
, ((const char*) (__func__)), "GTK_IS_WIDGET (event_widget)")
; } while (0)
;
3425 gtk_widget_translate_coordinates (event_widget,
3426 widget,
3427 event->x,
3428 event->y,
3429 &toplevel->priv->drag_offset_x,
3430 &toplevel->priv->drag_offset_y);
3431
3432 panel_toplevel_begin_grab_op (toplevel, PANEL_GRAB_OP_MOVE, FALSE(0), event->time);
3433
3434 return TRUE(!(0));
3435}
3436
3437static gboolean
3438panel_toplevel_button_release_event (GtkWidget *widget,
3439 GdkEventButton *event)
3440{
3441 PanelToplevel *toplevel;
3442
3443 if (event->button != 1 && event->button != 2)
3444 return FALSE(0);
3445
3446 toplevel = PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
;
3447
3448 if (toplevel->priv->grab_op == PANEL_GRAB_OP_NONE)
3449 return FALSE(0);
3450
3451 if (toplevel->priv->grab_is_keyboard)
3452 return FALSE(0);
3453
3454 panel_toplevel_end_grab_op (toplevel, event->time);
3455
3456 return TRUE(!(0));
3457}
3458
3459static gboolean
3460panel_toplevel_configure_event (GtkWidget *widget,
3461 GdkEventConfigure *event)
3462{
3463 PanelToplevel *toplevel;
3464
3465 toplevel = PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
;
3466
3467 set_background_region (toplevel);
3468
3469 return TRUE(!(0));
3470}
3471
3472static gboolean
3473panel_toplevel_key_press_event (GtkWidget *widget,
3474 GdkEventKey *event)
3475{
3476 PanelToplevel *toplevel = (PanelToplevel *) widget;
3477
3478 if (toplevel->priv->grab_op != PANEL_GRAB_OP_NONE &&
3479 panel_toplevel_handle_grab_op_key_event (toplevel, event))
3480 return TRUE(!(0));
3481
3482 if (GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->key_press_event)
3483 return GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->key_press_event (widget, event);
3484
3485 return FALSE(0);
3486}
3487
3488static void
3489panel_toplevel_state_flags_changed (GtkWidget *widget,
3490 GtkStateFlags previous_state)
3491{
3492 GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->state_flags_changed (widget,
3493 previous_state);
3494
3495 set_background_default_style (widget);
3496}
3497
3498static gboolean
3499panel_toplevel_motion_notify_event (GtkWidget *widget,
3500 GdkEventMotion *event)
3501{
3502 if (gdk_event_get_screen ((GdkEvent *)event) ==
3503 gtk_window_get_screen (GTK_WINDOW (widget)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_window_get_type ()))))))
))
3504 return panel_toplevel_handle_grab_op_motion_event (
3505 PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
, event);
3506 else
3507 return FALSE(0);
3508}
3509
3510static gboolean
3511panel_toplevel_animation_timeout (PanelToplevel *toplevel)
3512{
3513 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
3514
3515 if (!toplevel->priv->animating) {
3516 toplevel->priv->animation_end_x = 0xdead;
3517 toplevel->priv->animation_end_y = 0xdead;
3518 toplevel->priv->animation_end_width = 0xdead;
3519 toplevel->priv->animation_end_height = 0xdead;
3520 toplevel->priv->animation_start_time = 0xdead;
3521 toplevel->priv->animation_duration_time = 0xdead;
3522 toplevel->priv->animation_timeout = 0;
3523 toplevel->priv->initial_animation_done = TRUE(!(0));
3524 }
3525
3526 return toplevel->priv->animating;
3527}
3528
3529static GTimeSpan
3530panel_toplevel_get_animation_time (PanelToplevel *toplevel)
3531{
3532 /* The number of seconds to complete the animation.
3533 */
3534#define ANIMATION_TIME_FAST 400
3535#define ANIMATION_TIME_MEDIUM 1200
3536#define ANIMATION_TIME_SLOW 2000
3537
3538 GTimeSpan t;
3539
3540 switch (toplevel->priv->animation_speed) {
3541 case PANEL_ANIMATION_SLOW:
3542 t = ANIMATION_TIME_SLOW * G_TIME_SPAN_MILLISECOND((1000L));
3543 break;
3544 case PANEL_ANIMATION_MEDIUM:
3545 t = ANIMATION_TIME_MEDIUM * G_TIME_SPAN_MILLISECOND((1000L));
3546 break;
3547 case PANEL_ANIMATION_FAST:
3548 t = ANIMATION_TIME_FAST * G_TIME_SPAN_MILLISECOND((1000L));
3549 break;
3550 default:
3551 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 3551, ((const char*) (__func__)), ((void*)0)); } while (0)
;
3552 break;
3553 }
3554
3555 return t;
3556
3557#undef ANIMATION_TIME_FAST
3558#undef ANIMATION_TIME_MEDIUM
3559#undef ANIMATION_TIME_SLOW
3560}
3561
3562static void
3563panel_toplevel_calculate_animation_end_geometry (PanelToplevel *toplevel)
3564{
3565 GdkRectangle monitor_geom;
3566
3567 toplevel->priv->animation_end_x = toplevel->priv->x;
3568 toplevel->priv->animation_end_y = toplevel->priv->y;
3569 toplevel->priv->animation_end_width = -1;
3570 toplevel->priv->animation_end_height = -1;
3571
3572 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
3573
3574 if (!toplevel->priv->expand) {
3575
3576 if (toplevel->priv->x_centered)
3577 toplevel->priv->animation_end_x =
3578 (monitor_geom.width - toplevel->priv->geometry.width) / 2;
3579 if (toplevel->priv->y_centered)
3580 toplevel->priv->animation_end_y =
3581 (monitor_geom.height - toplevel->priv->geometry.height) / 2;
3582 }
3583
3584 /* we consider the toplevels which are in the initial animation stage
3585 * as in a normal state */
3586 if (toplevel->priv->state == PANEL_STATE_NORMAL ||
3587 (!toplevel->priv->initial_animation_done &&
3588 !toplevel->priv->auto_hide))
3589 panel_toplevel_update_normal_position (toplevel,
3590 &toplevel->priv->animation_end_x,
3591 &toplevel->priv->animation_end_y,
3592 &toplevel->priv->animation_end_width,
3593 &toplevel->priv->animation_end_height);
3594
3595 else if (toplevel->priv->state == PANEL_STATE_AUTO_HIDDEN)
3596 panel_toplevel_update_auto_hide_position (toplevel,
3597 &toplevel->priv->animation_end_x,
3598 &toplevel->priv->animation_end_y,
3599 &toplevel->priv->animation_end_width,
3600 &toplevel->priv->animation_end_height,
3601 TRUE(!(0)));
3602 else
3603 panel_toplevel_update_hidden_position (toplevel,
3604 &toplevel->priv->animation_end_x,
3605 &toplevel->priv->animation_end_y,
3606 &toplevel->priv->animation_end_width,
3607 &toplevel->priv->animation_end_height);
3608}
3609
3610static void
3611panel_toplevel_start_animation (PanelToplevel *toplevel)
3612{
3613 GtkRequisition requisition;
3614 int deltax, deltay, deltaw = 0, deltah = 0;
3615 int cur_x = -1, cur_y = -1;
3616
3617 panel_toplevel_calculate_animation_end_geometry (toplevel);
3618
3619 toplevel->priv->animating = TRUE(!(0));
3620
3621 panel_toplevel_update_struts (toplevel, TRUE(!(0)));
3622#ifdef HAVE_X111
3623 if (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel)))(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gtk_widget_get_display (((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((toplevel)), ((gtk_widget_get_type ()))))
))))); GType __t = ((gdk_x11_display_get_type())); gboolean __r
; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
) {
3624 panel_struts_update_toplevel_geometry (toplevel,
3625 &toplevel->priv->animation_end_x,
3626 &toplevel->priv->animation_end_y,
3627 &toplevel->priv->animation_end_width,
3628 &toplevel->priv->animation_end_height);
3629 }
3630#endif /* HAVE_X11 */
3631 panel_toplevel_update_struts (toplevel, FALSE(0));
3632
3633 gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
), &cur_x, &cur_y);
3634
3635 cur_x -= panel_multimonitor_x (toplevel->priv->monitor);
3636 cur_y -= panel_multimonitor_y (toplevel->priv->monitor);
3637
3638 deltax = toplevel->priv->animation_end_x - cur_x;
3639 deltay = toplevel->priv->animation_end_y - cur_y;
3640
3641 gtk_widget_get_preferred_size (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
, &requisition, NULL((void*)0));
3642
3643 if (toplevel->priv->animation_end_width != -1)
3644 deltaw = toplevel->priv->animation_end_width - requisition.width;
3645
3646 if (toplevel->priv->animation_end_height != -1)
3647 deltah = toplevel->priv->animation_end_height - requisition.height;
3648
3649 if (deltax == 0 && deltay == 0 && deltaw == 0 && deltah == 0) {
3650 toplevel->priv->animation_end_x = -1;
3651 toplevel->priv->animation_end_y = -1;
3652 toplevel->priv->animation_end_width = -1;
3653 toplevel->priv->animation_end_height = -1;
3654 toplevel->priv->animating = FALSE(0);
3655 return;
3656 }
3657
3658 if (toplevel->priv->attached) {
3659 /* Re-map unmapped attached toplevels */
3660 if (!gtk_widget_get_visible (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
))
3661 gtk_widget_set_visible (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
, TRUE(!(0)));
3662
3663 if (!gtk_widget_get_mapped (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
))
3664 gtk_widget_map (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
3665
3666 gtk_window_present (GTK_WINDOW (toplevel->priv->attach_toplevel)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->attach_toplevel)), ((gtk_window_get_type
()))))))
);
3667 }
3668
3669 toplevel->priv->animation_start_time = g_get_monotonic_time ();
3670 toplevel->priv->animation_duration_time = panel_toplevel_get_animation_time (toplevel);
3671
3672 if (!toplevel->priv->animation_timeout)
3673 toplevel->priv->animation_timeout =
3674 g_timeout_add (20, (GSourceFunc) panel_toplevel_animation_timeout, toplevel);
3675}
3676
3677void
3678panel_toplevel_hide (PanelToplevel *toplevel,
3679 gboolean auto_hide,
3680 gint direction)
3681{
3682 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
3683
3684 if (toplevel->priv->state != PANEL_STATE_NORMAL)
3685 return;
3686
3687 g_signal_emit (toplevel, toplevel_signals [HIDE_SIGNAL], 0);
3688
3689 if (toplevel->priv->attach_toplevel)
3690 panel_toplevel_pop_autohide_disabler (toplevel->priv->attach_toplevel);
3691
3692 if (auto_hide)
3693 toplevel->priv->state = PANEL_STATE_AUTO_HIDDEN;
3694 else {
3695 GtkDirectionType hide_direction;
3696
3697 if (direction == -1) {
3698 if (toplevel->priv->orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT))
3699 hide_direction = GTK_DIR_UP;
3700 else
3701 hide_direction = GTK_DIR_LEFT;
3702 } else {
3703 hide_direction = (GtkDirectionType) direction;
3704 }
3705
3706 switch (hide_direction) {
3707 case GTK_DIR_UP:
3708 g_return_if_fail (toplevel->priv->orientation & PANEL_VERTICAL_MASK)do { if ((toplevel->priv->orientation & (PANEL_ORIENTATION_LEFT
| PANEL_ORIENTATION_RIGHT))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "toplevel->priv->orientation & PANEL_VERTICAL_MASK"
); return; } } while (0)
;
3709 toplevel->priv->state = PANEL_STATE_HIDDEN_UP;
3710 break;
3711 case GTK_DIR_DOWN:
3712 g_return_if_fail (toplevel->priv->orientation & PANEL_VERTICAL_MASK)do { if ((toplevel->priv->orientation & (PANEL_ORIENTATION_LEFT
| PANEL_ORIENTATION_RIGHT))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "toplevel->priv->orientation & PANEL_VERTICAL_MASK"
); return; } } while (0)
;
3713 toplevel->priv->state = PANEL_STATE_HIDDEN_DOWN;
3714 break;
3715 case GTK_DIR_LEFT:
3716 g_return_if_fail (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK)do { if ((toplevel->priv->orientation & (PANEL_ORIENTATION_TOP
| PANEL_ORIENTATION_BOTTOM))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "toplevel->priv->orientation & PANEL_HORIZONTAL_MASK"
); return; } } while (0)
;
3717 toplevel->priv->state = PANEL_STATE_HIDDEN_LEFT;
3718 break;
3719 case GTK_DIR_RIGHT:
3720 g_return_if_fail (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK)do { if ((toplevel->priv->orientation & (PANEL_ORIENTATION_TOP
| PANEL_ORIENTATION_BOTTOM))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "toplevel->priv->orientation & PANEL_HORIZONTAL_MASK"
); return; } } while (0)
;
3721 toplevel->priv->state = PANEL_STATE_HIDDEN_RIGHT;
3722 break;
3723 default:
3724 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 3724, ((const char*) (__func__)), ((void*)0)); } while (0)
;
3725 break;
3726 }
3727
3728 panel_toplevel_update_hide_buttons (toplevel);
3729 }
3730
3731 if (toplevel->priv->animate && gtk_widget_get_realized (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
)) {
3732 panel_toplevel_start_animation (toplevel);
3733 }
3734
3735 /* if the toplevel is attached (-> drawer), hide it after the animation
3736 * this hides the hide button properly as well */
3737 if (toplevel->priv->attached) {
3738 gtk_widget_hide (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
3739 }
3740
3741 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
3742}
3743
3744static gboolean
3745panel_toplevel_auto_hide_timeout_handler (PanelToplevel *toplevel)
3746{
3747 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return ((0));
} } while (0)
;
3748
3749 if (panel_toplevel_get_autohide_disabled (toplevel)) {
3750 toplevel->priv->hide_timeout = 0;
3751 return FALSE(0);
3752 }
3753
3754 /* keep coming back until the animation has finished.
3755 * FIXME: we should really remove the timeout/idle
3756 * completely and re-instate it when the
3757 * animation has finished.
3758 */
3759 if (toplevel->priv->animating)
3760 return TRUE(!(0));
3761
3762 panel_toplevel_hide (toplevel, TRUE(!(0)), -1);
3763
3764 toplevel->priv->hide_timeout = 0;
3765
3766 return FALSE(0);
3767}
3768
3769void
3770panel_toplevel_unhide (PanelToplevel *toplevel)
3771{
3772 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
3773
3774 if (toplevel->priv->state == PANEL_STATE_NORMAL)
3775 return;
3776
3777 toplevel->priv->state = PANEL_STATE_NORMAL;
3778
3779 panel_toplevel_update_hide_buttons (toplevel);
3780
3781 if (toplevel->priv->attach_toplevel)
3782 panel_toplevel_push_autohide_disabler (toplevel->priv->attach_toplevel);
3783
3784 if (toplevel->priv->animate && gtk_widget_get_realized (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
)) {
3785 panel_toplevel_start_animation (toplevel);
3786 }
3787
3788 /* if the toplevel is attached (-> drawer), unhide it after the animation
3789 * (same as for hide) */
3790 if (toplevel->priv->attached) {
3791 gtk_widget_show (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
3792 }
3793
3794 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
3795
3796 if (!toplevel->priv->animate)
3797 g_signal_emit (toplevel, toplevel_signals [UNHIDE_SIGNAL], 0);
3798}
3799
3800static gboolean
3801panel_toplevel_auto_unhide_timeout_handler (PanelToplevel *toplevel)
3802{
3803 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return ((0));
} } while (0)
;
3804
3805 /* keep coming back until the animation has finished.
3806 * FIXME: we should really remove the timeout/idle
3807 * completely and re-instate it when the
3808 * animation has finished.
3809 */
3810 if (toplevel->priv->animating)
3811 return TRUE(!(0));
3812
3813 if (!toplevel->priv->animate)
3814 toplevel->priv->initial_animation_done = TRUE(!(0));
3815
3816 /* initial animation for auto-hidden panels: we need to unhide and hide
3817 * again to get at the right size */
3818 if (!toplevel->priv->initial_animation_done &&
3819 toplevel->priv->auto_hide) {
3820 toplevel->priv->unhide_timeout = 0;
3821 panel_toplevel_unhide (toplevel);
3822 panel_toplevel_hide (toplevel, TRUE(!(0)), -1);
3823 return FALSE(0);
3824 }
3825
3826 if (!panel_toplevel_contains_pointer (toplevel) &&
3827 toplevel->priv->auto_hide) {
3828 toplevel->priv->unhide_timeout = 0;
3829 return FALSE(0);
3830 }
3831
3832 panel_toplevel_unhide (toplevel);
3833
3834 toplevel->priv->unhide_timeout = 0;
3835
3836 return FALSE(0);
3837}
3838
3839void
3840panel_toplevel_queue_auto_hide (PanelToplevel *toplevel)
3841{
3842 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
3843
3844 if (!toplevel->priv->auto_hide ||
3845 panel_toplevel_contains_pointer (toplevel) ||
3846 panel_toplevel_get_autohide_disabled (toplevel))
3847 return;
3848
3849 if (toplevel->priv->unhide_timeout)
3850 g_source_remove (toplevel->priv->unhide_timeout);
3851 toplevel->priv->unhide_timeout = 0;
3852
3853 if (toplevel->priv->hide_timeout ||
3854 toplevel->priv->state != PANEL_STATE_NORMAL)
3855 return;
3856
3857 if (toplevel->priv->hide_delay > 0)
3858 toplevel->priv->hide_timeout =
3859 g_timeout_add (toplevel->priv->hide_delay,
3860 (GSourceFunc) panel_toplevel_auto_hide_timeout_handler,
3861 toplevel);
3862 else
3863 toplevel->priv->hide_timeout =
3864 g_idle_add ((GSourceFunc) panel_toplevel_auto_hide_timeout_handler,
3865 toplevel);
3866}
3867
3868void
3869panel_toplevel_queue_auto_unhide (PanelToplevel *toplevel)
3870{
3871 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
3872
3873 if (toplevel->priv->unhide_timeout)
3874 return;
3875
3876 if (toplevel->priv->hide_timeout)
3877 g_source_remove (toplevel->priv->hide_timeout);
3878 toplevel->priv->hide_timeout = 0;
3879
3880 if (toplevel->priv->state != PANEL_STATE_AUTO_HIDDEN)
3881 return;
3882
3883 if (toplevel->priv->unhide_delay > 0)
3884 toplevel->priv->unhide_timeout =
3885 g_timeout_add (toplevel->priv->unhide_delay,
3886 (GSourceFunc) panel_toplevel_auto_unhide_timeout_handler,
3887 toplevel);
3888 else
3889 toplevel->priv->unhide_timeout =
3890 g_idle_add ((GSourceFunc) panel_toplevel_auto_unhide_timeout_handler,
3891 toplevel);
3892}
3893
3894void
3895panel_toplevel_queue_initial_unhide (PanelToplevel *toplevel)
3896{
3897 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
3898
3899 if (toplevel->priv->initial_animation_done)
3900 return;
3901
3902 if (toplevel->priv->unhide_timeout)
3903 return;
3904
3905 toplevel->priv->unhide_timeout =
3906 g_idle_add ((GSourceFunc) panel_toplevel_auto_unhide_timeout_handler,
3907 toplevel);
3908}
3909
3910static gboolean
3911panel_toplevel_enter_notify_event (GtkWidget *widget,
3912 GdkEventCrossing *event)
3913{
3914 PanelToplevel *toplevel;
3915
3916 g_return_val_if_fail (PANEL_IS_TOPLEVEL (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (widget)"); return ((0)); }
} while (0)
;
3917
3918 toplevel = PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
;
3919
3920 if (toplevel->priv->auto_hide && event->detail != GDK_NOTIFY_INFERIOR)
3921 panel_toplevel_queue_auto_unhide (toplevel);
3922
3923 if (GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->enter_notify_event)
3924 return GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->enter_notify_event (widget, event);
3925
3926 return FALSE(0);
3927}
3928
3929static gboolean
3930panel_toplevel_leave_notify_event (GtkWidget *widget,
3931 GdkEventCrossing *event)
3932{
3933 PanelToplevel *toplevel;
3934
3935 g_return_val_if_fail (PANEL_IS_TOPLEVEL (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (widget)"); return ((0)); }
} while (0)
;
3936
3937 toplevel = PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
;
3938
3939 if (toplevel->priv->auto_hide && event->detail != GDK_NOTIFY_INFERIOR)
3940 panel_toplevel_queue_auto_hide (toplevel);
3941
3942 if (GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->leave_notify_event)
3943 return GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->leave_notify_event (widget, event);
3944
3945 return FALSE(0);
3946}
3947
3948static gboolean
3949panel_toplevel_focus_in_event (GtkWidget *widget,
3950 GdkEventFocus *event)
3951{
3952 PanelToplevel *toplevel = PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
;
3953
3954 if (toplevel->priv->state == PANEL_STATE_AUTO_HIDDEN)
3955 panel_toplevel_unhide (toplevel);
3956
3957 if (GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->focus_in_event)
3958 return GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->focus_in_event (widget, event);
3959
3960 return FALSE(0);
3961}
3962
3963static gboolean
3964panel_toplevel_focus_out_event (GtkWidget *widget,
3965 GdkEventFocus *event)
3966{
3967 PanelToplevel *toplevel = PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
;
3968
3969 /* It appears that sometimes we don't get a leave notify event,
3970 but just a focus in/out, so queue the autohide in that case.
3971 If the pointer is inside the panel then obviously we won't hide */
3972 if (toplevel->priv->auto_hide)
3973 panel_toplevel_queue_auto_hide (toplevel);
3974
3975 if (GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->focus_out_event)
3976 return GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->focus_out_event (widget, event);
3977
3978 return FALSE(0);
3979}
3980
3981static void
3982panel_toplevel_style_updated (GtkWidget *widget)
3983{
3984 panel_toplevel_update_hide_buttons (PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
);
3985
3986 if (GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->style_updated)
3987 GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->style_updated (widget);
3988
3989 set_background_default_style (widget);
3990}
3991
3992static void
3993panel_toplevel_drag_threshold_changed (PanelToplevel *toplevel)
3994{
3995 int threshold;
3996
3997 threshold = 0;
3998 g_object_get (G_OBJECT (toplevel->priv->gtk_settings)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->gtk_settings)), (((GType) ((20) <<
(2))))))))
,
3999 "gtk-dnd-drag-threshold", &threshold,
4000 NULL((void*)0));
4001
4002 if (threshold)
4003 toplevel->priv->snap_tolerance = threshold * SNAP_TOLERANCE_FACTOR6;
4004}
4005
4006static void
4007panel_toplevel_update_gtk_settings (PanelToplevel *toplevel)
4008{
4009 if (toplevel->priv->gtk_settings)
4010 g_signal_handlers_disconnect_by_func (toplevel->priv->gtk_settings,g_signal_handlers_disconnect_matched ((toplevel->priv->
gtk_settings), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (panel_toplevel_drag_threshold_changed
))), (toplevel))
4011 G_CALLBACK (panel_toplevel_drag_threshold_changed),g_signal_handlers_disconnect_matched ((toplevel->priv->
gtk_settings), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (panel_toplevel_drag_threshold_changed
))), (toplevel))
4012 toplevel)g_signal_handlers_disconnect_matched ((toplevel->priv->
gtk_settings), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (panel_toplevel_drag_threshold_changed
))), (toplevel))
;
4013
4014 toplevel->priv->gtk_settings = gtk_widget_get_settings (GTK_WIDGET (toplevel->priv->panel_widget)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->panel_widget)), ((gtk_widget_get_type
()))))))
);
4015
4016 g_signal_connect_swapped (toplevel->priv->gtk_settings, "notify::gtk-dnd-drag-threshold",g_signal_connect_data ((toplevel->priv->gtk_settings), (
"notify::gtk-dnd-drag-threshold"), (((GCallback) (panel_toplevel_drag_threshold_changed
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
4017 G_CALLBACK (panel_toplevel_drag_threshold_changed),g_signal_connect_data ((toplevel->priv->gtk_settings), (
"notify::gtk-dnd-drag-threshold"), (((GCallback) (panel_toplevel_drag_threshold_changed
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
4018 toplevel)g_signal_connect_data ((toplevel->priv->gtk_settings), (
"notify::gtk-dnd-drag-threshold"), (((GCallback) (panel_toplevel_drag_threshold_changed
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
;
4019
4020 panel_toplevel_drag_threshold_changed (toplevel);
4021}
4022
4023static void
4024panel_toplevel_screen_changed (GtkWidget *widget,
4025 GdkScreen *previous_screen)
4026{
4027 panel_toplevel_update_gtk_settings (PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
);
4028
4029 if (GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->screen_changed)
4030 GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->screen_changed (widget, previous_screen);
4031
4032 gtk_widget_queue_resize (widget);
4033}
4034
4035static void
4036panel_toplevel_set_property (GObject *object,
4037 guint prop_id,
4038 const GValue *value,
4039 GParamSpec *pspec)
4040{
4041 PanelToplevel *toplevel;
4042
4043 g_return_if_fail (PANEL_IS_TOPLEVEL (object))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((object)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (object)"); return; } } while
(0)
;
4044
4045 toplevel = PANEL_TOPLEVEL (object)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((panel_toplevel_get_type ()))))))
;
4046
4047 switch (prop_id) {
4048 case PROP_NAME:
4049 panel_toplevel_set_name (toplevel, g_value_get_string (value));
4050 break;
4051 case PROP_SETTINGS_PATH:
4052 panel_toplevel_set_settings_path (toplevel, g_value_get_string (value));
4053 break;
4054 case PROP_EXPAND:
4055 panel_toplevel_set_expand (toplevel, g_value_get_boolean (value));
4056 break;
4057 case PROP_ORIENTATION:
4058 panel_toplevel_set_orientation (toplevel, g_value_get_enum (value));
4059 break;
4060 case PROP_SIZE:
4061 panel_toplevel_set_size (toplevel, g_value_get_int (value));
4062 break;
4063 case PROP_X:
4064 panel_toplevel_set_x (toplevel,
4065 g_value_get_int (value),
4066 toplevel->priv->x_right,
4067 toplevel->priv->x_centered);
4068 break;
4069 case PROP_X_RIGHT:
4070 panel_toplevel_set_x (toplevel,
4071 toplevel->priv->x,
4072 g_value_get_int (value),
4073 toplevel->priv->x_centered);
4074 break;
4075 case PROP_X_CENTERED:
4076 panel_toplevel_set_x (toplevel,
4077 toplevel->priv->x,
4078 toplevel->priv->x_right,
4079 g_value_get_boolean (value));
4080 break;
4081 case PROP_Y:
4082 panel_toplevel_set_y (toplevel,
4083 g_value_get_int (value),
4084 toplevel->priv->y_bottom,
4085 toplevel->priv->y_centered);
4086 break;
4087 case PROP_Y_BOTTOM:
4088 panel_toplevel_set_y (toplevel,
4089 toplevel->priv->y,
4090 g_value_get_int (value),
4091 toplevel->priv->y_centered);
4092 break;
4093 case PROP_Y_CENTERED:
4094 panel_toplevel_set_y (toplevel,
4095 toplevel->priv->y,
4096 toplevel->priv->y_bottom,
4097 g_value_get_boolean (value));
4098 break;
4099 case PROP_MONITOR:
4100 panel_toplevel_set_monitor (toplevel, g_value_get_int (value));
4101 break;
4102 case PROP_AUTOHIDE:
4103 panel_toplevel_set_auto_hide (toplevel, g_value_get_boolean (value));
4104 break;
4105 case PROP_HIDE_DELAY:
4106 panel_toplevel_set_hide_delay (toplevel, g_value_get_int (value));
4107 break;
4108 case PROP_UNHIDE_DELAY:
4109 panel_toplevel_set_unhide_delay (toplevel, g_value_get_int (value));
4110 break;
4111 case PROP_AUTOHIDE_SIZE:
4112 panel_toplevel_set_auto_hide_size (toplevel, g_value_get_int (value));
4113 break;
4114 case PROP_ANIMATE:
4115 panel_toplevel_set_animate (toplevel, g_value_get_boolean (value));
4116 break;
4117 case PROP_ANIMATION_SPEED:
4118 panel_toplevel_set_animation_speed (toplevel, g_value_get_enum (value));
4119 break;
4120 case PROP_BUTTONS_ENABLED:
4121 panel_toplevel_set_enable_buttons (toplevel, g_value_get_boolean (value));
4122 break;
4123 case PROP_ARROWS_ENABLED:
4124 panel_toplevel_set_enable_arrows (toplevel, g_value_get_boolean (value));
4125 break;
4126 default:
4127 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "panel-toplevel.c", 4127, ("property"), _glib__property_id,
_glib__pspec->name, g_type_name ((((((GTypeClass*) (((GTypeInstance
*) (_glib__pspec))->g_class))->g_type)))), (g_type_name
((((((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
4128 break;
4129 }
4130}
4131
4132static void
4133panel_toplevel_get_property (GObject *object,
4134 guint prop_id,
4135 GValue *value,
4136 GParamSpec *pspec)
4137{
4138 PanelToplevel *toplevel;
4139
4140 g_return_if_fail (PANEL_IS_TOPLEVEL (object))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((object)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (object)"); return; } } while
(0)
;
4141
4142 toplevel = PANEL_TOPLEVEL (object)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((panel_toplevel_get_type ()))))))
;
4143
4144 switch (prop_id) {
4145 case PROP_NAME:
4146 g_value_set_string (value, panel_toplevel_get_name (toplevel));
4147 break;
4148 case PROP_SETTINGS_PATH:
4149 g_value_set_string (value, toplevel->priv->settings_path);
4150 break;
4151 case PROP_EXPAND:
4152 g_value_set_boolean (value, toplevel->priv->expand);
4153 break;
4154 case PROP_ORIENTATION:
4155 g_value_set_enum (value, toplevel->priv->orientation);
4156 break;
4157 case PROP_SIZE:
4158 g_value_set_int (value, toplevel->priv->size);
4159 break;
4160 case PROP_X:
4161 g_value_set_int (value, toplevel->priv->x);
4162 break;
4163 case PROP_X_RIGHT:
4164 g_value_set_int (value, toplevel->priv->x_right);
4165 break;
4166 case PROP_X_CENTERED:
4167 g_value_set_boolean (value, toplevel->priv->x_centered);
4168 break;
4169 case PROP_Y:
4170 g_value_set_int (value, toplevel->priv->y);
4171 break;
4172 case PROP_Y_BOTTOM:
4173 g_value_set_int (value, toplevel->priv->y_bottom);
4174 break;
4175 case PROP_Y_CENTERED:
4176 g_value_set_boolean (value, toplevel->priv->y_centered);
4177 break;
4178 case PROP_MONITOR:
4179 g_value_set_int (value, toplevel->priv->monitor);
4180 break;
4181 case PROP_AUTOHIDE:
4182 g_value_set_boolean (value, toplevel->priv->auto_hide);
4183 break;
4184 case PROP_HIDE_DELAY:
4185 g_value_set_int (value, toplevel->priv->hide_delay);
4186 break;
4187 case PROP_UNHIDE_DELAY:
4188 g_value_set_int (value, toplevel->priv->unhide_delay);
4189 break;
4190 case PROP_AUTOHIDE_SIZE:
4191 g_value_set_int (value, toplevel->priv->auto_hide_size);
4192 break;
4193 case PROP_ANIMATE:
4194 g_value_set_boolean (value, toplevel->priv->animate);
4195 break;
4196 case PROP_ANIMATION_SPEED:
4197 g_value_set_enum (value, toplevel->priv->animation_speed);
4198 break;
4199 case PROP_BUTTONS_ENABLED:
4200 g_value_set_boolean (value, toplevel->priv->buttons_enabled);
4201 break;
4202 case PROP_ARROWS_ENABLED:
4203 g_value_set_boolean (value, toplevel->priv->arrows_enabled);
4204 break;
4205 default:
4206 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "panel-toplevel.c", 4206, ("property"), _glib__property_id,
_glib__pspec->name, g_type_name ((((((GTypeClass*) (((GTypeInstance
*) (_glib__pspec))->g_class))->g_type)))), (g_type_name
((((((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
4207 break;
4208 }
4209}
4210
4211static GObject*
4212panel_toplevel_constructor (GType type,
4213 guint n_construct_properties,
4214 GObjectConstructParam *construct_properties)
4215{
4216 GObject *object;
4217
4218 object = G_OBJECT_CLASS (panel_toplevel_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), (((GType) ((20) << (
2))))))))
->constructor (type,
4219 n_construct_properties,
4220 construct_properties);
4221 PanelToplevel *toplevel = PANEL_TOPLEVEL(object)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((panel_toplevel_get_type ()))))))
;
4222 GdkScreen *screen = gtk_widget_get_screen(GTK_WIDGET(toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
4223 GdkVisual *visual = gdk_screen_get_rgba_visual(screen);
4224 gtk_widget_set_visual(GTK_WIDGET(toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
, visual);
4225
4226 return object;
4227}
4228
4229static void
4230panel_toplevel_finalize (GObject *object)
4231{
4232 PanelToplevel *toplevel = (PanelToplevel *) object;
4233
4234#ifdef HAVE_X111
4235 if (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel)))(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gtk_widget_get_display (((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((toplevel)), ((gtk_widget_get_type ()))))
))))); GType __t = ((gdk_x11_display_get_type())); gboolean __r
; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
)
4236 panel_struts_unregister_strut (toplevel);
4237#endif /* HAVE_X11 */
4238
4239 toplevel_list = g_slist_remove (toplevel_list, toplevel);
4240
4241 G_OBJECT_CLASS (panel_toplevel_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), (((GType) ((20) << (
2))))))))
->finalize (object);
4242}
4243
4244static void
4245panel_toplevel_class_init (PanelToplevelClass *klass)
4246{
4247 GObjectClass *gobject_class = (GObjectClass *) klass;
4248 GtkWidgetClass *widget_class = (GtkWidgetClass *) klass;
4249 GtkContainerClass *container_class = (GtkContainerClass *) klass;
4250 GtkBindingSet *binding_set;
4251
4252 binding_set = gtk_binding_set_by_class (klass);
4253
4254 gobject_class->constructor = panel_toplevel_constructor;
4255 gobject_class->set_property = panel_toplevel_set_property;
4256 gobject_class->get_property = panel_toplevel_get_property;
4257 gobject_class->finalize = panel_toplevel_finalize;
4258
4259 gobject_class->dispose = panel_toplevel_dispose;
4260
4261 widget_class->realize = panel_toplevel_realize;
4262 widget_class->unrealize = panel_toplevel_unrealize;
4263 widget_class->state_flags_changed = panel_toplevel_state_flags_changed;
4264 widget_class->draw = panel_toplevel_draw;
4265 widget_class->get_preferred_width = panel_toplevel_get_preferred_width;
4266 widget_class->get_preferred_height = panel_toplevel_get_preferred_height;
4267 widget_class->style_updated = panel_toplevel_style_updated;
4268 widget_class->size_allocate = panel_toplevel_size_allocate;
4269 widget_class->button_press_event = panel_toplevel_button_press_event;
4270 widget_class->button_release_event = panel_toplevel_button_release_event;
4271 widget_class->configure_event = panel_toplevel_configure_event;
4272 widget_class->key_press_event = panel_toplevel_key_press_event;
4273 widget_class->motion_notify_event = panel_toplevel_motion_notify_event;
4274 widget_class->enter_notify_event = panel_toplevel_enter_notify_event;
4275 widget_class->leave_notify_event = panel_toplevel_leave_notify_event;
4276 widget_class->screen_changed = panel_toplevel_screen_changed;
4277 widget_class->focus_in_event = panel_toplevel_focus_in_event;
4278 widget_class->focus_out_event = panel_toplevel_focus_out_event;
4279
4280 gtk_widget_class_set_css_name (widget_class, "PanelToplevel");
4281
4282 container_class->check_resize = panel_toplevel_check_resize;
4283
4284 klass->hiding = NULL((void*)0);
4285 klass->unhiding = NULL((void*)0);
4286 klass->popup_panel_menu = panel_toplevel_popup_panel_menu;
4287 klass->toggle_expand = panel_toplevel_toggle_expand;
4288 klass->expand = panel_toplevel_expand;
4289 klass->unexpand = panel_toplevel_unexpand;
4290 klass->toggle_hidden = panel_toplevel_toggle_hidden;
4291 klass->begin_move = panel_toplevel_begin_move;
4292 klass->begin_resize = panel_toplevel_begin_resize;
4293
4294 g_object_class_install_property (
4295 gobject_class,
4296 PROP_NAME,
4297 g_param_spec_string (
4298 "name",
4299 "Name",
4300 "The name of this panel",
4301 NULL((void*)0),
4302 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4303
4304 g_object_class_install_property (
4305 gobject_class,
4306 PROP_SETTINGS_PATH,
4307 g_param_spec_string (
4308 "settings-path",
4309 "GSettings path",
4310 "The GSettings path used for this panel",
4311 NULL((void*)0),
4312 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4313
4314 g_object_class_install_property (
4315 gobject_class,
4316 PROP_EXPAND,
4317 g_param_spec_boolean (
4318 "expand",
4319 "Expand",
4320 "Expand to take up the full monitor width/height",
4321 TRUE(!(0)),
4322 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4323
4324 g_object_class_install_property (
4325 gobject_class,
4326 PROP_ORIENTATION,
4327 g_param_spec_enum (
4328 "orientation",
4329 "Orientation",
4330 "The orientation of the panel",
4331 PANEL_TYPE_ORIENTATIONpanel_orientation_get_type(),
4332 PANEL_ORIENTATION_TOP,
4333 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4334
4335 g_object_class_install_property (
4336 gobject_class,
4337 PROP_SIZE,
4338 g_param_spec_int (
4339 "size",
4340 "Size",
4341 "The height (or width when vertical) of the panel",
4342 0,
4343 G_MAXINT2147483647,
4344 DEFAULT_SIZE48,
4345 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4346
4347 g_object_class_install_property (
4348 gobject_class,
4349 PROP_X,
4350 g_param_spec_int (
4351 "x",
4352 "X position",
4353 "The X position of the panel",
4354 0,
4355 G_MAXINT2147483647,
4356 0,
4357 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4358
4359 g_object_class_install_property (
4360 gobject_class,
4361 PROP_X_RIGHT,
4362 g_param_spec_int (
4363 "x-right",
4364 "X position, from the right",
4365 "The X position of the panel, starting from the right of the screen",
4366 -1,
4367 G_MAXINT2147483647,
4368 -1,
4369 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4370
4371 g_object_class_install_property (
4372 gobject_class,
4373 PROP_X_CENTERED,
4374 g_param_spec_boolean (
4375 "x-centered",
4376 "X centered",
4377 "The x co-ordinate is relative to center screen",
4378 FALSE(0),
4379 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4380
4381 g_object_class_install_property (
4382 gobject_class,
4383 PROP_Y,
4384 g_param_spec_int (
4385 "y",
4386 "Y position",
4387 "The Y position of the panel",
4388 0,
4389 G_MAXINT2147483647,
4390 0,
4391 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4392
4393 g_object_class_install_property (
4394 gobject_class,
4395 PROP_Y_BOTTOM,
4396 g_param_spec_int (
4397 "y_bottom",
4398 "Y position, from the bottom",
4399 "The Y position of the panel, starting from the bottom of the screen",
4400 -1,
4401 G_MAXINT2147483647,
4402 -1,
4403 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4404
4405 g_object_class_install_property (
4406 gobject_class,
4407 PROP_Y_CENTERED,
4408 g_param_spec_boolean (
4409 "y-centered",
4410 "Y centered",
4411 "The y co-ordinate is relative to center screen",
4412 FALSE(0),
4413 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4414
4415 g_object_class_install_property (
4416 gobject_class,
4417 PROP_MONITOR,
4418 g_param_spec_int (
4419 "monitor",
4420 "Xinerama monitor",
4421 "The monitor (in terms of Xinerama) which the panel is on",
4422 0,
4423 G_MAXINT2147483647,
4424 0,
4425 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4426
4427 g_object_class_install_property (
4428 gobject_class,
4429 PROP_AUTOHIDE,
4430 g_param_spec_boolean (
4431 "auto-hide",
4432 "Auto hide",
4433 "Automatically hide the panel when the mouse leaves the panel",
4434 FALSE(0),
4435 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4436
4437 g_object_class_install_property (
4438 gobject_class,
4439 PROP_HIDE_DELAY,
4440 g_param_spec_int (
4441 "hide-delay",
4442 "Hide delay",
4443 "The number of milliseconds to delay before automatically hiding",
4444 0,
4445 G_MAXINT2147483647,
4446 DEFAULT_HIDE_DELAY300,
4447 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4448
4449 g_object_class_install_property (
4450 gobject_class,
4451 PROP_UNHIDE_DELAY,
4452 g_param_spec_int (
4453 "unhide-delay",
4454 "Un-hide delay",
4455 "The number of milliseconds to delay before automatically un-hiding",
4456 0,
4457 G_MAXINT2147483647,
4458 DEFAULT_UNHIDE_DELAY100,
4459 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4460
4461 g_object_class_install_property (
4462 gobject_class,
4463 PROP_AUTOHIDE_SIZE,
4464 g_param_spec_int (
4465 "auto-hide-size",
4466 "Auto-hide size",
4467 "The number of pixels visible when the panel has been automatically hidden",
4468 1,
4469 G_MAXINT2147483647,
4470 DEFAULT_AUTO_HIDE_SIZE1,
4471 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4472
4473 g_object_class_install_property (
4474 gobject_class,
4475 PROP_ANIMATE,
4476 g_param_spec_boolean (
4477 "animate",
4478 "Animate",
4479 "Enable hiding/showing animations",
4480 TRUE(!(0)),
4481 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4482
4483 g_object_class_install_property (
4484 gobject_class,
4485 PROP_ANIMATION_SPEED,
4486 g_param_spec_enum (
4487 "animation-speed",
4488 "Animation Speed",
4489 "The speed at which to animate panel hiding/showing",
4490 PANEL_TYPE_ANIMATION_SPEEDpanel_animation_speed_get_type(),
4491 PANEL_ANIMATION_MEDIUM,
4492 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4493
4494 g_object_class_install_property (
4495 gobject_class,
4496 PROP_BUTTONS_ENABLED,
4497 g_param_spec_boolean (
4498 "buttons-enabled",
4499 "Buttons Enabled",
4500 "Enable hide/show buttons",
4501 TRUE(!(0)),
4502 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4503
4504 g_object_class_install_property (
4505 gobject_class,
4506 PROP_ARROWS_ENABLED,
4507 g_param_spec_boolean (
4508 "arrows-enabled",
4509 "Arrows Enabled",
4510 "Enable arrows on hide/show buttons",
4511 TRUE(!(0)),
4512 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4513
4514 gtk_widget_class_install_style_property (
4515 widget_class,
4516 g_param_spec_int (
4517 "arrow-size",
4518 "Arrow Size",
4519 "The size of the arrows on the hide/show buttons",
4520 0,
4521 G_MAXINT2147483647,
4522 DEFAULT_ARROW_SIZE20,
4523 G_PARAM_READABLE));
4524
4525 toplevel_signals [HIDE_SIGNAL] =
4526 g_signal_new ("hiding",
4527 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
4528 G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
4529 G_STRUCT_OFFSET (PanelToplevelClass, hiding)((glong) __builtin_offsetof(PanelToplevelClass, hiding)),
4530 NULL((void*)0),
4531 NULL((void*)0),
4532 g_cclosure_marshal_VOID__VOID,
4533 G_TYPE_NONE((GType) ((1) << (2))),
4534 0);
4535
4536 toplevel_signals [UNHIDE_SIGNAL] =
4537 g_signal_new ("unhiding",
4538 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
4539 G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
4540 G_STRUCT_OFFSET (PanelToplevelClass, unhiding)((glong) __builtin_offsetof(PanelToplevelClass, unhiding)),
4541 NULL((void*)0),
4542 NULL((void*)0),
4543 g_cclosure_marshal_VOID__VOID,
4544 G_TYPE_NONE((GType) ((1) << (2))),
4545 0);
4546
4547 toplevel_signals [POPUP_PANEL_MENU_SIGNAL] =
4548 g_signal_new ("popup-panel-menu",
4549 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
4550 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
4551 G_STRUCT_OFFSET (PanelToplevelClass, popup_panel_menu)((glong) __builtin_offsetof(PanelToplevelClass, popup_panel_menu
))
,
4552 NULL((void*)0),
4553 NULL((void*)0),
4554 panel_marshal_BOOLEAN__VOID,
4555 G_TYPE_BOOLEAN((GType) ((5) << (2))),
4556 0);
4557
4558 toplevel_signals [TOGGLE_EXPAND_SIGNAL] =
4559 g_signal_new ("toggle-expand",
4560 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
4561 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
4562 G_STRUCT_OFFSET (PanelToplevelClass, toggle_expand)((glong) __builtin_offsetof(PanelToplevelClass, toggle_expand
))
,
4563 NULL((void*)0),
4564 NULL((void*)0),
4565 panel_marshal_BOOLEAN__VOID,
4566 G_TYPE_BOOLEAN((GType) ((5) << (2))),
4567 0);
4568
4569 toplevel_signals [EXPAND_SIGNAL] =
4570 g_signal_new ("expand",
4571 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
4572 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
4573 G_STRUCT_OFFSET (PanelToplevelClass, expand)((glong) __builtin_offsetof(PanelToplevelClass, expand)),
4574 NULL((void*)0),
4575 NULL((void*)0),
4576 panel_marshal_BOOLEAN__VOID,
4577 G_TYPE_BOOLEAN((GType) ((5) << (2))),
4578 0);
4579
4580 toplevel_signals [UNEXPAND_SIGNAL] =
4581 g_signal_new ("unexpand",
4582 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
4583 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
4584 G_STRUCT_OFFSET (PanelToplevelClass, unexpand)((glong) __builtin_offsetof(PanelToplevelClass, unexpand)),
4585 NULL((void*)0),
4586 NULL((void*)0),
4587 panel_marshal_BOOLEAN__VOID,
4588 G_TYPE_BOOLEAN((GType) ((5) << (2))),
4589 0);
4590
4591 toplevel_signals [TOGGLE_HIDDEN_SIGNAL] =
4592 g_signal_new ("toggle-hidden",
4593 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
4594 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
4595 G_STRUCT_OFFSET (PanelToplevelClass, toggle_hidden)((glong) __builtin_offsetof(PanelToplevelClass, toggle_hidden
))
,
4596 NULL((void*)0),
4597 NULL((void*)0),
4598 panel_marshal_BOOLEAN__VOID,
4599 G_TYPE_BOOLEAN((GType) ((5) << (2))),
4600 0);
4601
4602 toplevel_signals [BEGIN_MOVE_SIGNAL] =
4603 g_signal_new ("begin-move",
4604 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
4605 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
4606 G_STRUCT_OFFSET (PanelToplevelClass, begin_move)((glong) __builtin_offsetof(PanelToplevelClass, begin_move)),
4607 NULL((void*)0),
4608 NULL((void*)0),
4609 panel_marshal_BOOLEAN__VOID,
4610 G_TYPE_BOOLEAN((GType) ((5) << (2))),
4611 0);
4612
4613 toplevel_signals [BEGIN_RESIZE_SIGNAL] =
4614 g_signal_new ("begin-resize",
4615 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
4616 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
4617 G_STRUCT_OFFSET (PanelToplevelClass, begin_resize)((glong) __builtin_offsetof(PanelToplevelClass, begin_resize)
)
,
4618 NULL((void*)0),
4619 NULL((void*)0),
4620 panel_marshal_BOOLEAN__VOID,
4621 G_TYPE_BOOLEAN((GType) ((5) << (2))),
4622 0);
4623
4624 gtk_binding_entry_add_signal (binding_set, GDK_KEY_F100xffc7, GDK_CONTROL_MASK,
4625 "popup_panel_menu", 0);
4626
4627 panel_bindings_set_entries (binding_set);
4628}
4629
4630static void
4631panel_toplevel_setup_widgets (PanelToplevel *toplevel)
4632{
4633 GtkWidget* container;
4634
4635 toplevel->priv->grid = gtk_grid_new ();
4636
4637 toplevel->priv->hide_button_top = panel_toplevel_add_hide_button (toplevel, GTK_ARROW_UP, 1, 0);
4638 toplevel->priv->hide_button_bottom = panel_toplevel_add_hide_button (toplevel, GTK_ARROW_DOWN, 1, 2);
4639 toplevel->priv->hide_button_left = panel_toplevel_add_hide_button (toplevel, GTK_ARROW_LEFT, 0, 1);
4640 toplevel->priv->hide_button_right = panel_toplevel_add_hide_button (toplevel, GTK_ARROW_RIGHT, 2, 1);
4641
4642 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM))
4643 {
4644 gtk_widget_show(toplevel->priv->hide_button_left);
4645 gtk_widget_show(toplevel->priv->hide_button_right);
4646 }
4647 else
4648 {
4649 gtk_widget_show(toplevel->priv->hide_button_top);
4650 gtk_widget_show(toplevel->priv->hide_button_bottom);
4651 }
4652
4653 toplevel->priv->inner_frame = g_object_new(PANEL_TYPE_FRAME(panel_frame_get_type ()), NULL((void*)0));
4654
4655 gtk_widget_set_hexpand (GTK_WIDGET (toplevel->priv->inner_frame)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->inner_frame)), ((gtk_widget_get_type
()))))))
, TRUE(!(0)));
4656 gtk_widget_set_vexpand (GTK_WIDGET (toplevel->priv->inner_frame)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->inner_frame)), ((gtk_widget_get_type
()))))))
, TRUE(!(0)));
4657
4658 gtk_grid_attach (GTK_GRID (toplevel->priv->grid)((((GtkGrid*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->grid)), ((gtk_grid_get_type ()))))
))
, GTK_WIDGET (toplevel->priv->inner_frame)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->inner_frame)), ((gtk_widget_get_type
()))))))
, 1, 1, 1, 1);
4659 gtk_widget_show (GTK_WIDGET (toplevel->priv->inner_frame)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->inner_frame)), ((gtk_widget_get_type
()))))))
);
4660
4661 container = panel_widget_new (toplevel,
4662 !toplevel->priv->expand,
4663 (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)) ?
4664 GTK_ORIENTATION_HORIZONTAL :
4665 GTK_ORIENTATION_VERTICAL,
4666 toplevel->priv->size);
4667
4668 toplevel->priv->panel_widget = PANEL_WIDGET(container)((((PanelWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((container)), ((panel_widget_get_type()))))))
;
4669
4670 gtk_container_add(GTK_CONTAINER(toplevel->priv->inner_frame)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->inner_frame)), ((gtk_container_get_type
()))))))
, container);
4671 gtk_widget_show(container);
4672
4673 gtk_container_add (GTK_CONTAINER (toplevel)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_container_get_type ()))))))
, toplevel->priv->grid);
4674 gtk_widget_show (toplevel->priv->grid);
4675}
4676
4677static void
4678background_changed (PanelBackground *background,
4679 PanelToplevel *toplevel)
4680{
4681 panel_toplevel_update_edges (toplevel);
4682 panel_widget_emit_background_changed (toplevel->priv->panel_widget);
4683}
4684
4685static void
4686panel_toplevel_init (PanelToplevel *toplevel)
4687{
4688 GtkWidget *widget;
4689 int i;
4690
4691 toplevel->priv = panel_toplevel_get_instance_private (toplevel);
4692
4693 toplevel->priv->expand = TRUE(!(0));
4694 toplevel->priv->orientation = PANEL_ORIENTATION_BOTTOM;
4695 toplevel->priv->size = DEFAULT_SIZE48;
4696 toplevel->priv->scale = gtk_widget_get_scale_factor (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
4697 toplevel->priv->x = 0;
4698 toplevel->priv->y = 0;
4699 toplevel->priv->x_right = -1;
4700 toplevel->priv->y_bottom = -1;
4701 toplevel->priv->monitor = 0;
4702 toplevel->priv->configured_monitor = -1;
4703 toplevel->priv->hide_delay = DEFAULT_HIDE_DELAY300;
4704 toplevel->priv->unhide_delay = DEFAULT_UNHIDE_DELAY100;
4705 toplevel->priv->auto_hide_size = DEFAULT_AUTO_HIDE_SIZE1;
4706 toplevel->priv->animation_speed = PANEL_ANIMATION_FAST;
4707
4708 toplevel->priv->snap_tolerance = DEFAULT_DND_THRESHOLD8 * SNAP_TOLERANCE_FACTOR6;
4709 toplevel->priv->gtk_settings = NULL((void*)0);
4710
4711 toplevel->priv->state = PANEL_STATE_NORMAL;
4712
4713 toplevel->priv->name = NULL((void*)0);
4714 toplevel->priv->description = NULL((void*)0);
4715
4716 toplevel->priv->hide_timeout = 0;
4717 toplevel->priv->unhide_timeout = 0;
4718
4719 toplevel->priv->geometry.x = -1;
4720 toplevel->priv->geometry.y = -1;
4721 toplevel->priv->geometry.width = -1;
4722 toplevel->priv->geometry.height = -1;
4723
4724 toplevel->priv->original_width = -1;
4725 toplevel->priv->original_height = -1;
4726
4727 toplevel->priv->grab_op = PANEL_GRAB_OP_NONE;
4728
4729 toplevel->priv->drag_offset_x = 0;
4730 toplevel->priv->drag_offset_y = 0;
4731
4732 toplevel->priv->animation_end_x = 0;
4733 toplevel->priv->animation_end_y = 0;
4734 toplevel->priv->animation_end_width = 0;
4735 toplevel->priv->animation_end_height = 0;
4736 toplevel->priv->animation_start_time = 0;
4737 toplevel->priv->animation_duration_time = 0;
4738 toplevel->priv->animation_timeout = 0;
4739
4740 toplevel->priv->panel_widget = NULL((void*)0);
4741 toplevel->priv->inner_frame = NULL((void*)0);
4742 toplevel->priv->grid = NULL((void*)0);
4743 toplevel->priv->hide_button_top = NULL((void*)0);
4744 toplevel->priv->hide_button_bottom = NULL((void*)0);
4745 toplevel->priv->hide_button_left = NULL((void*)0);
4746 toplevel->priv->hide_button_right = NULL((void*)0);
4747
4748 toplevel->priv->attach_toplevel = NULL((void*)0);
4749 toplevel->priv->attach_widget = NULL((void*)0);
4750 toplevel->priv->n_autohide_disablers = 0;
4751
4752 for (i = 0; i < N_ATTACH_TOPLEVEL_SIGNALS5; i++)
4753 toplevel->priv->attach_toplevel_signals [i] = 0;
4754 for (i = 0; i < N_ATTACH_WIDGET_SIGNALS5; i++)
4755 toplevel->priv->attach_widget_signals [i] = 0;
4756
4757 toplevel->priv->auto_hide = FALSE(0);
4758 toplevel->priv->buttons_enabled = TRUE(!(0));
4759 toplevel->priv->arrows_enabled = TRUE(!(0));
4760 toplevel->priv->x_centered = FALSE(0);
4761 toplevel->priv->y_centered = FALSE(0);
4762 toplevel->priv->animating = FALSE(0);
4763 toplevel->priv->grab_is_keyboard = FALSE(0);
4764 toplevel->priv->position_centered = FALSE(0);
4765 toplevel->priv->attached = FALSE(0);
4766 toplevel->priv->attach_hidden = FALSE(0);
4767 toplevel->priv->updated_geometry_initial = FALSE(0);
4768 toplevel->priv->initial_animation_done = FALSE(0);
4769
4770 widget = GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
;
4771 gtk_widget_add_events (widget,
4772 GDK_BUTTON_PRESS_MASK |
4773 GDK_BUTTON_RELEASE_MASK |
4774 GDK_POINTER_MOTION_MASK |
4775 GDK_ENTER_NOTIFY_MASK |
4776 GDK_LEAVE_NOTIFY_MASK);
4777
4778 gtk_widget_set_app_paintable (widget, TRUE(!(0)));
4779
4780 panel_toplevel_setup_widgets (toplevel);
4781 panel_toplevel_update_description (toplevel);
4782 panel_toplevel_update_gtk_settings (toplevel);
4783
4784 toplevel_list = g_slist_prepend (toplevel_list, toplevel);
4785
4786 /* Prevent the window from being deleted via Alt+F4 by accident. This
4787 * happens with "alternative" window managers such as Sawfish or XFWM4.
4788 */
4789 g_signal_connect (toplevel, "delete-event", G_CALLBACK(gtk_true), NULL)g_signal_connect_data ((toplevel), ("delete-event"), (((GCallback
) (gtk_true))), (((void*)0)), ((void*)0), (GConnectFlags) 0)
;
4790
4791 panel_background_init (&toplevel->background,
4792 (PanelBackgroundChangedNotify) background_changed,
4793 toplevel);
4794
4795 update_style_classes (toplevel);
4796
4797#ifdef HAVE_WAYLAND1
4798 if (GDK_IS_WAYLAND_DISPLAY (gdk_display_get_default ())(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gdk_display_get_default ())); GType __t = ((gdk_wayland_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
) {
4799 wayland_panel_toplevel_init (toplevel);
4800 }
4801#endif /* HAVE_WAYLAND */
4802}
4803
4804PanelWidget *
4805panel_toplevel_get_panel_widget (PanelToplevel *toplevel)
4806{
4807
4808 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return (((void
*)0)); } } while (0)
;
4809
4810 return toplevel->priv->panel_widget;
4811}
4812
4813static void
4814panel_toplevel_update_name (PanelToplevel *toplevel)
4815{
4816 char *title;
4817
4818 g_assert (toplevel->priv->description != NULL)do { if (toplevel->priv->description != ((void*)0)) ; else
g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c", 4818
, ((const char*) (__func__)), "toplevel->priv->description != NULL"
); } while (0)
;
4819
4820 title = toplevel->priv->name ? toplevel->priv->name : toplevel->priv->description;
4821
4822 gtk_window_set_title (GTK_WINDOW (toplevel)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_window_get_type ()))))))
, title);
4823
4824 panel_a11y_set_atk_name_desc (
4825 GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
,
4826 title, toplevel->priv->description);
4827}
4828
4829void
4830panel_toplevel_set_name (PanelToplevel *toplevel,
4831 const char *name)
4832{
4833 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
4834
4835 if (!toplevel->priv->name && (!name || !name [0]))
4836 return;
4837
4838 if (toplevel->priv->name && name && name [0] &&
4839 !strcmp (toplevel->priv->name, name))
4840 return;
4841
4842 g_free (toplevel->priv->name);
4843 if (name && name [0])
4844 toplevel->priv->name = g_strdup (name)g_strdup_inline (name);
4845 else
4846 toplevel->priv->name = NULL((void*)0);
4847
4848 panel_toplevel_update_name (toplevel);
4849
4850 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "name");
4851}
4852
4853void
4854panel_toplevel_set_settings_path (PanelToplevel *toplevel,
4855 const char *settings_path)
4856{
4857 toplevel->priv->settings_path = g_strdup (settings_path)g_strdup_inline (settings_path);
4858}
4859
4860const char* panel_toplevel_get_name(PanelToplevel* toplevel)
4861{
4862 g_return_val_if_fail(PANEL_IS_TOPLEVEL(toplevel), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL(toplevel)"); return (((void
*)0)); } } while (0)
;
4863
4864 return toplevel->priv->name;
4865}
4866
4867const char* panel_toplevel_get_description(PanelToplevel* toplevel)
4868{
4869 g_return_val_if_fail(PANEL_IS_TOPLEVEL(toplevel), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL(toplevel)"); return (((void
*)0)); } } while (0)
;
4870
4871 return toplevel->priv->description;
4872}
4873
4874void
4875panel_toplevel_set_expand (PanelToplevel *toplevel,
4876 gboolean expand)
4877{
4878 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
4879
4880 if (toplevel->priv->attached && expand) {
4881 g_warning ("attempt to expand attached toplevel; ignoring");
4882 return;
4883 }
4884
4885 expand = expand != FALSE(0);
4886
4887 if (toplevel->priv->expand == expand)
4888 return;
4889
4890 toplevel->priv->expand = expand;
4891
4892 if (!toplevel->priv->expand && toplevel->priv->updated_geometry_initial) {
4893 switch (toplevel->priv->orientation) {
4894 case PANEL_ORIENTATION_TOP:
4895 panel_toplevel_set_x (toplevel, 0, -1, TRUE(!(0)));
4896 break;
4897 case PANEL_ORIENTATION_BOTTOM:
4898 panel_toplevel_set_x (toplevel, 0, 0, TRUE(!(0)));
4899 break;
4900 case PANEL_ORIENTATION_LEFT:
4901 panel_toplevel_set_y (toplevel, 0, -1, TRUE(!(0)));
4902 break;
4903 case PANEL_ORIENTATION_RIGHT:
4904 panel_toplevel_set_y (toplevel, 0, 0, TRUE(!(0)));
4905 break;
4906 default:
4907 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 4907, ((const char*) (__func__)), ((void*)0)); } while (0)
;
4908 break;
4909 }
4910 }
4911
4912 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
4913
4914 panel_widget_set_packed (toplevel->priv->panel_widget, !toplevel->priv->expand);
4915
4916 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "expand");
4917}
4918
4919gboolean
4920panel_toplevel_get_expand (PanelToplevel *toplevel)
4921{
4922 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), TRUE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return ((!(0)
)); } } while (0)
;
4923
4924 return toplevel->priv->expand;
4925}
4926
4927gboolean
4928panel_toplevel_get_is_floating (PanelToplevel *toplevel)
4929{
4930 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), TRUE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return ((!(0)
)); } } while (0)
;
4931
4932 return toplevel->priv->floating;
4933}
4934
4935void
4936panel_toplevel_set_orientation (PanelToplevel *toplevel,
4937 PanelOrientation orientation)
4938{
4939 gboolean rotate;
4940 GdkRectangle monitor_geom;
4941
4942 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
4943
4944 if (toplevel->priv->orientation == orientation)
4945 return;
4946
4947 g_object_freeze_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
);
4948
4949 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
4950
4951 /* Un-snap from center if no longer along screen edge */
4952 if (toplevel->priv->x_centered &&
4953 (orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT))) {
4954 toplevel->priv->x_centered = FALSE(0);
4955 toplevel->priv->x = (monitor_geom.width - toplevel->priv->geometry.width) / 2;
4956 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "x");
4957 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "x-centered");
4958
4959 if (toplevel->priv->x_right != -1) {
4960 toplevel->priv->x_right = -1;
4961 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "x-right");
4962 }
4963 }
4964
4965 if (toplevel->priv->y_centered &&
4966 (orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM))) {
4967 toplevel->priv->y_centered = FALSE(0);
4968 toplevel->priv->y = (monitor_geom.height - toplevel->priv->geometry.height) / 2;
4969 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "y");
4970 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "y-centered");
4971
4972 if (toplevel->priv->y_bottom != -1) {
4973 toplevel->priv->y_bottom = -1;
4974 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "y-bottom");
4975 }
4976 }
4977
4978 rotate = FALSE(0);
4979 if ((orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)) &&
4980 (toplevel->priv->orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT)))
4981 rotate = TRUE(!(0));
4982 else if ((orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT)) &&
4983 (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)))
4984 rotate = TRUE(!(0));
4985
4986 /* rotate around the center */
4987 if (rotate && !toplevel->priv->position_centered && !toplevel->priv->expand &&
4988 toplevel->priv->updated_geometry_initial) {
4989 toplevel->priv->position_centered = TRUE(!(0));
4990
4991 /* x, y temporary refer to the panel center, so we don't care
4992 * about x_right, y_bottom. Those will get updated in
4993 * panel_toplevel_update_position() accordingly. */
4994 if (!toplevel->priv->x_centered) {
4995 toplevel->priv->x += toplevel->priv->geometry.width / 2;
4996 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "x");
4997 }
4998
4999 if (!toplevel->priv->y_centered) {
5000 toplevel->priv->y += toplevel->priv->geometry.height / 2;
5001 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "y");
5002 }
5003
5004 }
5005
5006 toplevel->priv->orientation = orientation;
5007 update_style_classes (toplevel);
5008
5009 gtk_widget_reset_style (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
5010
5011 panel_toplevel_update_hide_buttons (toplevel);
5012
5013 panel_widget_set_orientation (
5014 toplevel->priv->panel_widget,
5015 (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)) ?
5016 GTK_ORIENTATION_HORIZONTAL :
5017 GTK_ORIENTATION_VERTICAL);
5018
5019 switch (toplevel->priv->state) {
5020 case PANEL_STATE_HIDDEN_UP:
5021 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM))
5022 toplevel->priv->state = PANEL_STATE_HIDDEN_LEFT;
5023 break;
5024 case PANEL_STATE_HIDDEN_DOWN:
5025 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM))
5026 toplevel->priv->state = PANEL_STATE_HIDDEN_RIGHT;
5027 break;
5028 case PANEL_STATE_HIDDEN_LEFT:
5029 if (toplevel->priv->orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT))
5030 toplevel->priv->state = PANEL_STATE_HIDDEN_UP;
5031 break;
5032 case PANEL_STATE_HIDDEN_RIGHT:
5033 if (toplevel->priv->orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT))
5034 toplevel->priv->state = PANEL_STATE_HIDDEN_DOWN;
5035 break;
5036 default:
5037 break;
5038 }
5039
5040 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
5041
5042 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "orientation");
5043
5044 g_object_thaw_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
);
5045
5046#ifdef HAVE_WAYLAND1
5047 if (GDK_IS_WAYLAND_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel)))(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gtk_widget_get_display (((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((toplevel)), ((gtk_widget_get_type ()))))
))))); GType __t = ((gdk_wayland_display_get_type())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
) {
5048 wayland_panel_toplevel_update_placement (toplevel);
5049 }
5050#endif /* HAVE_WAYLAND */
5051}
5052
5053PanelOrientation
5054panel_toplevel_get_orientation (PanelToplevel *toplevel)
5055{
5056 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), PANEL_ORIENTATION_TOP)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return (PANEL_ORIENTATION_TOP
); } } while (0)
;
5057
5058 return toplevel->priv->orientation;
5059}
5060
5061void
5062panel_toplevel_set_size (PanelToplevel *toplevel,
5063 int size)
5064{
5065 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
5066 g_return_if_fail (size >= 0)do { if ((size >= 0)) { } else { g_return_if_fail_warning (
((gchar*) 0), ((const char*) (__func__)), "size >= 0"); return
; } } while (0)
;
5067
5068 if (toplevel->priv->size == size)
5069 return;
5070
5071 toplevel->priv->size = size;
5072
5073 panel_widget_set_size (toplevel->priv->panel_widget, toplevel->priv->size);
5074
5075 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
5076
5077 panel_toplevel_update_hide_buttons (toplevel);
5078
5079 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "size");
5080}
5081
5082int
5083panel_toplevel_get_size (PanelToplevel *toplevel)
5084{
5085 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), DEFAULT_SIZE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return (48); }
} while (0)
;
5086
5087 return toplevel->priv->size;
5088}
5089
5090void
5091panel_toplevel_set_auto_hide_size (PanelToplevel *toplevel,
5092 int auto_hide_size)
5093{
5094 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
5095
5096 if (toplevel->priv->auto_hide_size == auto_hide_size)
5097 return;
5098
5099 toplevel->priv->auto_hide_size = auto_hide_size;
5100
5101 if (toplevel->priv->state == PANEL_STATE_AUTO_HIDDEN) {
5102 if (panel_toplevel_update_struts (toplevel, FALSE(0))) {
5103 if (toplevel->priv->animate) {
5104 panel_toplevel_unhide (toplevel);
5105 panel_toplevel_hide (toplevel, TRUE(!(0)), -1);
5106 } else
5107 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
5108 }
5109 }
5110
5111 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "auto-hide-size");
5112}
5113
5114int
5115panel_toplevel_get_auto_hide_size (PanelToplevel *toplevel)
5116{
5117 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), DEFAULT_AUTO_HIDE_SIZE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return (1); }
} while (0)
;
5118
5119 return toplevel->priv->auto_hide_size;
5120}
5121
5122void
5123panel_toplevel_set_x (PanelToplevel *toplevel,
5124 int x,
5125 int x_right,
5126 gboolean x_centered)
5127{
5128 gboolean changed = FALSE(0);
5129
5130 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
5131
5132 x_centered = x_centered != FALSE(0);
5133
5134 g_object_freeze_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
);
5135
5136 if (toplevel->priv->x != x) {
5137 toplevel->priv->x = x;
5138 changed = TRUE(!(0));
5139 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "x");
5140 }
5141
5142 if (toplevel->priv->x_right != x_right) {
5143 toplevel->priv->x_right = x_right;
5144 changed = TRUE(!(0));
5145 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "x-right");
5146 }
5147
5148 if (toplevel->priv->x_centered != x_centered) {
5149 toplevel->priv->x_centered = (x_centered != FALSE(0));
5150 changed = TRUE(!(0));
5151 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "x-centered");
5152 }
5153
5154 if (changed)
5155 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
5156
5157 g_object_thaw_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
);
5158}
5159
5160void
5161panel_toplevel_set_y (PanelToplevel *toplevel,
5162 int y,
5163 int y_bottom,
5164 gboolean y_centered)
5165{
5166 gboolean changed = FALSE(0);
5167
5168 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
5169
5170 y_centered = y_centered != FALSE(0);
5171
5172 g_object_freeze_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
);
5173
5174 if (toplevel->priv->y != y) {
5175 toplevel->priv->y = y;
5176 changed = TRUE(!(0));
5177 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "y");
5178 }
5179
5180 if (toplevel->priv->y_bottom != y_bottom) {
5181 toplevel->priv->y_bottom = y_bottom;
5182 changed = TRUE(!(0));
5183 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "y-bottom");
5184 }
5185
5186 if (toplevel->priv->y_centered != y_centered) {
5187 toplevel->priv->y_centered = (y_centered != FALSE(0));
5188 changed = TRUE(!(0));
5189 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "y-centered");
5190 }
5191
5192 if (changed)
5193 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
5194
5195 g_object_thaw_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
);
5196}
5197
5198void
5199panel_toplevel_get_position (PanelToplevel *toplevel,
5200 int *x,
5201 int *x_right,
5202 int *y,
5203 int *y_bottom)
5204{
5205 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
5206
5207 if (x)
5208 *x = toplevel->priv->x;
5209
5210 if (y)
5211 *y = toplevel->priv->y;
5212
5213 if (x_right)
5214 *x_right = toplevel->priv->x_right;
5215
5216 if (y_bottom)
5217 *y_bottom = toplevel->priv->y_bottom;
5218}
5219
5220gboolean
5221panel_toplevel_get_x_centered (PanelToplevel *toplevel)
5222{
5223 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return ((0));
} } while (0)
;
5224
5225 return toplevel->priv->x_centered;
5226}
5227
5228gboolean
5229panel_toplevel_get_y_centered (PanelToplevel *toplevel)
5230{
5231 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return ((0));
} } while (0)
;
5232
5233 return toplevel->priv->y_centered;
5234}
5235
5236/**
5237 * panel_toplevel_set_monitor_internal:
5238 *
5239 * Sets the monitor of the toplevel, but only the internal state. We need to
5240 * make the difference between the internal state and the configuration of the
5241 * user because internal constraints might affect the monitor of the toplevel.
5242 *
5243 * panel_toplevel_set_monitor_internal() won't update the configuration of the
5244 * user.
5245 **/
5246static void
5247panel_toplevel_set_monitor_internal (PanelToplevel *toplevel,
5248 int monitor,
5249 gboolean force_resize)
5250{
5251 if (toplevel->priv->monitor == monitor)
5252 return;
5253
5254 toplevel->priv->monitor = monitor;
5255
5256 if (force_resize)
5257 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
5258}
5259
5260/**
5261 * panel_toplevel_update_monitor:
5262 *
5263 * Moves the toplevel to its configured monitor or the first one, if needed.
5264 * This generally happens when the configured monitor was non-existing before,
5265 * and it appeared at runtime, or if it was existing and disappeared.
5266 *
5267 * This must only be called at the beginning of the size request of the
5268 * toplevel because it doesn't queue a size request.
5269 **/
5270static void
5271panel_toplevel_update_monitor (PanelToplevel *toplevel)
5272{
5273 /* If we were not using the configured monitor, can we use it now? */
5274 if ((toplevel->priv->configured_monitor != -1) &&
5275 (toplevel->priv->configured_monitor != toplevel->priv->monitor) &&
5276 toplevel->priv->configured_monitor < panel_multimonitor_monitors ()) {
5277 panel_toplevel_set_monitor_internal (toplevel,
5278 toplevel->priv->configured_monitor,
5279 FALSE(0));
5280
5281 /* else, can we still use the monitor we were using? */
5282 } else if (toplevel->priv->monitor >= panel_multimonitor_monitors ()) {
5283 panel_toplevel_set_monitor_internal (toplevel,
5284 0,
5285 FALSE(0));
5286 }
5287}
5288
5289void
5290panel_toplevel_set_monitor (PanelToplevel *toplevel,
5291 int monitor)
5292{
5293 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
5294
5295 if (toplevel->priv->configured_monitor == monitor)
5296 return;
5297
5298 toplevel->priv->configured_monitor = monitor;
5299
5300 /* Only use the configured monitor if it's existing. Else, we ignore
5301 * the non-existing monitor, and keep the old one. The main use case is
5302 * when logging in after having used a multimonitor environment.
5303 * We will put the panel on the monitor 0 for this session, and it will
5304 * move back to the right monitor next time. */
5305 if (monitor < panel_multimonitor_monitors ())
5306 panel_toplevel_set_monitor_internal (toplevel, monitor, TRUE(!(0)));
5307
5308 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "monitor");
5309}
5310
5311int
5312panel_toplevel_get_monitor (PanelToplevel *toplevel)
5313{
5314 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), -1)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return (-1); }
} while (0)
;
5315
5316 return toplevel->priv->monitor;
5317}
5318
5319void
5320panel_toplevel_set_auto_hide (PanelToplevel *toplevel,
5321 gboolean auto_hide)
5322{
5323 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
5324
5325 auto_hide = auto_hide != FALSE(0);
5326
5327 if (toplevel->priv->auto_hide == auto_hide)
5328 return;
5329
5330 toplevel->priv->auto_hide = (auto_hide != FALSE(0));
5331
5332 if (toplevel->priv->auto_hide)
5333 panel_toplevel_queue_auto_hide (toplevel);
5334 else
5335 panel_toplevel_queue_auto_unhide (toplevel);
5336
5337 if (panel_toplevel_update_struts (toplevel, FALSE(0)))
5338 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
5339
5340 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "auto-hide");
5341}
5342
5343gboolean
5344panel_toplevel_get_auto_hide (PanelToplevel *toplevel)
5345{
5346 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return ((0));
} } while (0)
;
5347
5348 return toplevel->priv->auto_hide;
5349}
5350
5351void
5352panel_toplevel_set_hide_delay (PanelToplevel *toplevel,
5353 int hide_delay)
5354{
5355 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
5356
5357 if (toplevel->priv->hide_delay == hide_delay)
5358 return;
5359
5360 toplevel->priv->hide_delay = hide_delay;
5361
5362 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "hide-delay");
5363}
5364
5365int
5366panel_toplevel_get_hide_delay (PanelToplevel *toplevel)
5367{
5368 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), -1)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return (-1); }
} while (0)
;
5369
5370 return toplevel->priv->hide_delay;
5371}
5372
5373void
5374panel_toplevel_set_unhide_delay (PanelToplevel *toplevel,
5375 int unhide_delay)
5376{
5377 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
5378
5379 if (toplevel->priv->unhide_delay == unhide_delay)
5380 return;
5381
5382 toplevel->priv->unhide_delay = unhide_delay;
5383
5384 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "unhide-delay");
5385}
5386
5387int
5388panel_toplevel_get_unhide_delay (PanelToplevel *toplevel)
5389{
5390 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), -1)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return (-1); }
} while (0)
;
5391
5392 return toplevel->priv->unhide_delay;
5393}
5394
5395void
5396panel_toplevel_set_animate (PanelToplevel *toplevel,
5397 gboolean animate)
5398{
5399 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
5400
5401 animate = animate != FALSE(0);
5402
5403 if (toplevel->priv->animate == animate)
5404 return;
5405
5406 toplevel->priv->animate = (animate != FALSE(0));
5407
5408 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "animate");
5409}
5410
5411gboolean
5412panel_toplevel_get_animate (PanelToplevel *toplevel)
5413{
5414 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return ((0));
} } while (0)
;
5415
5416 return toplevel->priv->animate;
5417}
5418
5419void
5420panel_toplevel_set_animation_speed (PanelToplevel *toplevel,
5421 PanelAnimationSpeed animation_speed)
5422{
5423 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
5424
5425 if (toplevel->priv->animation_speed == animation_speed)
5426 return;
5427
5428 toplevel->priv->animation_speed = animation_speed;
5429
5430 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "animation-speed");
5431}
5432
5433PanelAnimationSpeed
5434panel_toplevel_get_animation_speed (PanelToplevel *toplevel)
5435{
5436 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), 0)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return (0); }
} while (0)
;
5437
5438 return toplevel->priv->animation_speed;
5439}
5440
5441void
5442panel_toplevel_set_enable_buttons (PanelToplevel *toplevel,
5443 gboolean enable_buttons)
5444{
5445 enable_buttons = enable_buttons != FALSE(0);
5446
5447 if (toplevel->priv->buttons_enabled == enable_buttons)
5448 return;
5449
5450 toplevel->priv->buttons_enabled = enable_buttons;
5451
5452 panel_toplevel_update_hide_buttons (toplevel);
5453
5454 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "buttons-enabled");
5455}
5456
5457gboolean
5458panel_toplevel_get_enable_buttons (PanelToplevel *toplevel)
5459{
5460 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return ((0));
} } while (0)
;
5461
5462 return toplevel->priv->buttons_enabled;
5463}
5464
5465void
5466panel_toplevel_set_enable_arrows (PanelToplevel *toplevel,
5467 gboolean enable_arrows)
5468{
5469 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
5470
5471 enable_arrows = enable_arrows != FALSE(0);
5472
5473 if (toplevel->priv->arrows_enabled == enable_arrows)
5474 return;
5475
5476 toplevel->priv->arrows_enabled = (enable_arrows != FALSE(0));
5477
5478 panel_toplevel_update_hide_buttons (toplevel);
5479
5480 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "arrows-enabled");
5481}
5482
5483gboolean
5484panel_toplevel_get_enable_arrows (PanelToplevel *toplevel)
5485{
5486 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return ((0));
} } while (0)
;
5487
5488 return toplevel->priv->arrows_enabled;
5489}
5490
5491void
5492panel_toplevel_rotate (PanelToplevel *toplevel,
5493 gboolean clockwise)
5494{
5495 PanelOrientation orientation;
5496
5497 /* Relies on PanelOrientation definition:
5498 *
5499 * typedef enum {
5500 * PANEL_ORIENTATION_TOP = 1 << 0,
5501 * PANEL_ORIENTATION_RIGHT = 1 << 1,
5502 * PANEL_ORIENTATION_BOTTOM = 1 << 2,
5503 * PANEL_ORIENTATION_LEFT = 1 << 3
5504 * } PanelOrientation;
5505 */
5506
5507 orientation = toplevel->priv->orientation;
5508
5509 if (clockwise)
5510 orientation <<= 1;
5511 else
5512 orientation >>= 1;
5513
5514 if (orientation == 0)
5515 orientation = PANEL_ORIENTATION_LEFT;
5516
5517 else if (orientation > PANEL_ORIENTATION_LEFT)
5518 orientation = PANEL_ORIENTATION_TOP;
5519
5520 panel_toplevel_set_orientation (toplevel, orientation);
5521}
5522
5523PanelState
5524panel_toplevel_get_state (PanelToplevel *toplevel)
5525{
5526 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), 0)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return (0); }
} while (0)
;
5527
5528 return toplevel->priv->state;
5529}
5530
5531gboolean
5532panel_toplevel_get_is_hidden (PanelToplevel *toplevel)
5533{
5534 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return ((0));
} } while (0)
;
5535
5536 if (toplevel->priv->state == PANEL_STATE_HIDDEN_UP ||
5537 toplevel->priv->state == PANEL_STATE_HIDDEN_DOWN ||
5538 toplevel->priv->state == PANEL_STATE_HIDDEN_LEFT ||
5539 toplevel->priv->state == PANEL_STATE_HIDDEN_RIGHT)
5540 return TRUE(!(0));
5541
5542 return FALSE(0);
5543}
5544
5545int
5546panel_toplevel_get_minimum_size (PanelToplevel *toplevel)
5547{
5548 return calculate_minimum_height (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
,
5549 toplevel->priv->orientation);
5550}
5551
5552int
5553panel_toplevel_get_maximum_size (PanelToplevel *toplevel)
5554{
5555 GdkRectangle monitor_geom;
5556
5557 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
5558
5559 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM))
5560 return monitor_geom.height / MAXIMUM_SIZE_SCREEN_RATIO5;
5561 else
5562 return monitor_geom.width / MAXIMUM_SIZE_SCREEN_RATIO5;
5563}
diff --git a/2024-06-18-172109-13286-1@e182420b844f_master/report-891289.html b/2024-06-18-172109-13286-1@e182420b844f_master/report-891289.html new file mode 100644 index 00000000..3554d649 --- /dev/null +++ b/2024-06-18-172109-13286-1@e182420b844f_master/report-891289.html @@ -0,0 +1,1524 @@ + + + +/rootdir/libmate-panel-applet/tmp-introspectems2xjmx/MatePanelApplet-4.0.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:libmate-panel-applet/tmp-introspectems2xjmx/MatePanelApplet-4.0.c
Warning:line 799, column 27
Access to field 'message' results in a dereference of a null pointer (loaded from variable 'error')
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name MatePanelApplet-4.0.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/libmate-panel-applet -fcoverage-compilation-dir=/rootdir/libmate-panel-applet -resource-dir /usr/bin/../lib/clang/18 -D WITH_GZFILEOP -D WITH_GZFILEOP -D MATELOCALEDIR="/usr/local/share/locale" -I /usr/include/gtk-3.0 -I /usr/include/atk-1.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/cairo -I /usr/include/gio-unix-2.0 -I /usr/include/freetype2 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/webp -I /usr/include/cloudproviders -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/libpng16 -I /usr/include/pixman-1 -I /usr/include/sysprof-6 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/gio-unix-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /rootdir/libmate-panel-applet -I /rootdir/libmate-panel-applet -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-deprecated-declarations -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-18-172109-13286-1 -x c /rootdir/libmate-panel-applet/tmp-introspectems2xjmx/MatePanelApplet-4.0.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* This file is generated, do not edit */
2
3#undef GLIB_VERSION_MIN_REQUIRED((((2) << 16 | (80) << 8)))
4#undef GLIB_VERSION_MAX_ALLOWED((((2) << 16 | (80) << 8)))
5
6#include <glib.h>
7#include <string.h>
8#include <stdlib.h>
9
10/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
11 * GObject introspection: Dump introspection data
12 *
13 * Copyright (C) 2008 Colin Walters <walters@verbum.org>
14 *
15 * SPDX-License-Identifier: LGPL-2.1-or-later
16 *
17 * This library is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU Lesser General Public
19 * License as published by the Free Software Foundation; either
20 * version 2 of the License, or (at your option) any later version.
21 *
22 * This library is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25 * Lesser General Public License for more details.
26 *
27 * You should have received a copy of the GNU Lesser General Public
28 * License along with this library; if not, write to the
29 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
30 * Boston, MA 02111-1307, USA.
31 */
32
33/* This file is both compiled into libgirepository.so, and installed
34 * on the filesystem. But for the dumper, we want to avoid linking
35 * to libgirepository; see
36 * https://bugzilla.gnome.org/show_bug.cgi?id=630342
37 */
38#ifdef G_IREPOSITORY_COMPILATION
39#include "config.h"
40#include "girepository.h"
41#endif
42
43#include <glib.h>
44#include <glib-object.h>
45#include <gmodule.h>
46
47#include <stdlib.h>
48#include <stdio.h>
49#include <string.h>
50
51/* Analogue of g_output_stream_write_all(). */
52static gboolean
53write_all (FILE *out,
54 const void *buffer,
55 gsize count,
56 gsize *bytes_written,
57 GError **error)
58{
59 size_t ret;
60
61 ret = fwrite (buffer, 1, count, out);
62
63 if (bytes_written != NULL((void*)0))
64 *bytes_written = ret;
65
66 if (ret < count)
67 {
68 g_set_error (error, G_FILE_ERRORg_file_error_quark (), G_FILE_ERROR_FAILED,
69 "Failed to write to file");
70 return FALSE(0);
71 }
72
73 return TRUE(!(0));
74}
75
76/* Analogue of g_data_input_stream_read_line(). */
77static char *
78read_line (FILE *input,
79 size_t *len_out)
80{
81 GByteArray *buffer = g_byte_array_new ();
82 const guint8 nul = '\0';
83
84 while (TRUE(!(0)))
85 {
86 size_t ret;
87 guint8 byte;
88
89 ret = fread (&byte, 1, 1, input);
90 if (ret == 0)
91 break;
92
93 if (byte == '\n')
94 break;
95
96 g_byte_array_append (buffer, &byte, 1);
97 }
98
99 g_byte_array_append (buffer, &nul, 1);
100
101 if (len_out != NULL((void*)0))
102 *len_out = buffer->len - 1; /* don’t include terminating nul */
103
104 return (char *) g_byte_array_free (buffer, FALSE(0));
105}
106
107static void
108escaped_printf (FILE *out, const char *fmt, ...) G_GNUC_PRINTF (2, 3)__attribute__((__format__ (__printf__, 2, 3)));
109
110static void
111escaped_printf (FILE *out, const char *fmt, ...)
112{
113 char *str;
114 va_list args;
115 gsize written;
116 GError *error = NULL((void*)0);
117
118 va_start (args, fmt)__builtin_va_start(args, fmt);
119
120 str = g_markup_vprintf_escaped (fmt, args);
121 if (!write_all (out, str, strlen (str), &written, &error))
122 {
123 g_critical ("failed to write to iochannel: %s", error->message);
124 g_clear_error (&error);
125 }
126 g_free (str);
127
128 va_end (args)__builtin_va_end(args);
129}
130
131static void
132goutput_write (FILE *out, const char *str)
133{
134 gsize written;
135 GError *error = NULL((void*)0);
136 if (!write_all (out, str, strlen (str), &written, &error))
137 {
138 g_critical ("failed to write to iochannel: %s", error->message);
139 g_clear_error (&error);
140 }
141}
142
143typedef GType (*GetTypeFunc)(void);
144typedef GQuark (*ErrorQuarkFunc)(void);
145
146static GType
147invoke_get_type (GModule *self, const char *symbol, GError **error)
148{
149 GetTypeFunc sym;
150 GType ret;
151
152 if (!g_module_symbol (self, symbol, (void**)&sym))
153 {
154 g_set_error (error,
155 G_FILE_ERRORg_file_error_quark (),
156 G_FILE_ERROR_FAILED,
157 "Failed to find symbol '%s'", symbol);
158 return G_TYPE_INVALID((GType) ((0) << (2)));
159 }
160
161 ret = sym ();
162 if (ret == G_TYPE_INVALID((GType) ((0) << (2))))
163 {
164 g_set_error (error,
165 G_FILE_ERRORg_file_error_quark (),
166 G_FILE_ERROR_FAILED,
167 "Function '%s' returned G_TYPE_INVALID", symbol);
168 }
169 return ret;
170}
171
172static GQuark
173invoke_error_quark (GModule *self, const char *symbol, GError **error)
174{
175 ErrorQuarkFunc sym;
176
177 if (!g_module_symbol (self, symbol, (void**)&sym))
178 {
179 g_set_error (error,
180 G_FILE_ERRORg_file_error_quark (),
181 G_FILE_ERROR_FAILED,
182 "Failed to find symbol '%s'", symbol);
183 return G_TYPE_INVALID((GType) ((0) << (2)));
184 }
185
186 return sym ();
187}
188
189static char *
190value_transform_to_string (const GValue *value)
191{
192 GValue tmp = G_VALUE_INIT{ 0, { { 0 } } };
193 char *s = NULL((void*)0);
194
195 g_value_init (&tmp, G_TYPE_STRING((GType) ((16) << (2))));
196
197 if (g_value_transform (value, &tmp))
198 {
199 const char *str = g_value_get_string (&tmp);
200
201 if (str != NULL((void*)0))
202 s = g_strescape (str, NULL((void*)0));
203 }
204
205 g_value_unset (&tmp);
206
207 return s;
208}
209
210/* A simpler version of g_strdup_value_contents(), but with stable
211 * output and less complex semantics
212 */
213static char *
214value_to_string (const GValue *value)
215{
216 if (value == NULL((void*)0))
217 return NULL((void*)0);
218
219 if (G_VALUE_HOLDS_STRING (value)(((__extension__ ({ const GValue *__val = (const GValue*) ((value
)); GType __t = (((GType) ((16) << (2)))); gboolean __r
; if (!__val) __r = (0); else if (__val->g_type == __t) __r
= (!(0)); else __r = g_type_check_value_holds (__val, __t); __r
; }))))
)
220 {
221 const char *s = g_value_get_string (value);
222
223 if (s == NULL((void*)0))
224 return g_strdup ("NULL")g_strdup_inline ("NULL");
225
226 return g_strescape (s, NULL((void*)0));
227 }
228 else
229 {
230 GType value_type = G_VALUE_TYPE (value)(((GValue*) (value))->g_type);
231
232 switch (G_TYPE_FUNDAMENTAL (value_type)(g_type_fundamental (value_type)))
233 {
234 case G_TYPE_BOXED((GType) ((18) << (2))):
235 if (g_value_get_boxed (value) == NULL((void*)0))
236 return NULL((void*)0);
237 else
238 return value_transform_to_string (value);
239 break;
240
241 case G_TYPE_OBJECT((GType) ((20) << (2))):
242 if (g_value_get_object (value) == NULL((void*)0))
243 return NULL((void*)0);
244 else
245 return value_transform_to_string (value);
246 break;
247
248 case G_TYPE_POINTER((GType) ((17) << (2))):
249 return NULL((void*)0);
250
251 default:
252 return value_transform_to_string (value);
253 }
254 }
255
256 return NULL((void*)0);
257}
258
259static void
260dump_properties (GType type, FILE *out)
261{
262 guint i;
263 guint n_properties = 0;
264 GParamSpec **props;
265
266 if (G_TYPE_FUNDAMENTAL (type)(g_type_fundamental (type)) == G_TYPE_OBJECT((GType) ((20) << (2))))
267 {
268 GObjectClass *klass;
269 klass = g_type_class_ref (type);
270 props = g_object_class_list_properties (klass, &n_properties);
271 }
272 else
273 {
274 void *klass;
275 klass = g_type_default_interface_ref (type);
276 props = g_object_interface_list_properties (klass, &n_properties);
277 }
278
279 for (i = 0; i < n_properties; i++)
280 {
281 GParamSpec *prop;
282
283 prop = props[i];
284 if (prop->owner_type != type)
285 continue;
286
287 const GValue *v = g_param_spec_get_default_value (prop);
288 char *default_value = value_to_string (v);
289
290 if (v != NULL((void*)0) && default_value != NULL((void*)0))
291 {
292 escaped_printf (out, " <property name=\"%s\" type=\"%s\" flags=\"%d\" default-value=\"%s\"/>\n",
293 prop->name,
294 g_type_name (prop->value_type),
295 prop->flags,
296 default_value);
297 }
298 else
299 {
300 escaped_printf (out, " <property name=\"%s\" type=\"%s\" flags=\"%d\"/>\n",
301 prop->name,
302 g_type_name (prop->value_type),
303 prop->flags);
304 }
305
306 g_free (default_value);
307 }
308
309 g_free (props);
310}
311
312static void
313dump_signals (GType type, FILE *out)
314{
315 guint i;
316 guint n_sigs;
317 guint *sig_ids;
318
319 sig_ids = g_signal_list_ids (type, &n_sigs);
320 for (i = 0; i < n_sigs; i++)
321 {
322 guint sigid;
323 GSignalQuery query;
324 guint j;
325
326 sigid = sig_ids[i];
327 g_signal_query (sigid, &query);
328
329 escaped_printf (out, " <signal name=\"%s\" return=\"%s\"",
330 query.signal_name, g_type_name (query.return_type));
331
332 if (query.signal_flags & G_SIGNAL_RUN_FIRST)
333 escaped_printf (out, " when=\"first\"");
334 else if (query.signal_flags & G_SIGNAL_RUN_LAST)
335 escaped_printf (out, " when=\"last\"");
336 else if (query.signal_flags & G_SIGNAL_RUN_CLEANUP)
337 escaped_printf (out, " when=\"cleanup\"");
338 else if (query.signal_flags & G_SIGNAL_MUST_COLLECT)
339 escaped_printf (out, " when=\"must-collect\"");
340 if (query.signal_flags & G_SIGNAL_NO_RECURSE)
341 escaped_printf (out, " no-recurse=\"1\"");
342
343 if (query.signal_flags & G_SIGNAL_DETAILED)
344 escaped_printf (out, " detailed=\"1\"");
345
346 if (query.signal_flags & G_SIGNAL_ACTION)
347 escaped_printf (out, " action=\"1\"");
348
349 if (query.signal_flags & G_SIGNAL_NO_HOOKS)
350 escaped_printf (out, " no-hooks=\"1\"");
351
352 goutput_write (out, ">\n");
353
354 for (j = 0; j < query.n_params; j++)
355 {
356 escaped_printf (out, " <param type=\"%s\"/>\n",
357 g_type_name (query.param_types[j]));
358 }
359 goutput_write (out, " </signal>\n");
360 }
361 g_free (sig_ids);
362}
363
364static void
365dump_object_type (GType type, const char *symbol, FILE *out)
366{
367 guint n_interfaces;
368 guint i;
369 GType *interfaces;
370
371 escaped_printf (out, " <class name=\"%s\" get-type=\"%s\"",
372 g_type_name (type), symbol);
373 if (type != G_TYPE_OBJECT((GType) ((20) << (2))))
374 {
375 GString *parent_str;
376 GType parent;
377 gboolean first = TRUE(!(0));
378
379 parent = g_type_parent (type);
380 parent_str = g_string_new ("");
381 while (parent != G_TYPE_INVALID((GType) ((0) << (2))))
382 {
383 if (first)
384 first = FALSE(0);
385 else
386 g_string_append_c (parent_str, ',')g_string_append_c_inline (parent_str, ',');
387 g_string_append (parent_str, g_type_name (parent))(__builtin_constant_p (g_type_name (parent)) ? __extension__ (
{ const char * const __val = (g_type_name (parent)); g_string_append_len_inline
(parent_str, __val, (__val != ((void*)0)) ? (gssize) strlen (
((__val) + !(__val))) : (gssize) -1); }) : g_string_append_len_inline
(parent_str, g_type_name (parent), (gssize) -1))
;
388 parent = g_type_parent (parent);
389 }
390
391 escaped_printf (out, " parents=\"%s\"", parent_str->str);
392
393 g_string_free (parent_str, TRUE)(__builtin_constant_p ((!(0))) ? (((!(0))) ? (g_string_free) (
(parent_str), ((!(0)))) : g_string_free_and_steal (parent_str
)) : (g_string_free) ((parent_str), ((!(0)))))
;
394 }
395
396 if (G_TYPE_IS_ABSTRACT (type)(g_type_test_flags ((type), G_TYPE_FLAG_ABSTRACT)))
397 escaped_printf (out, " abstract=\"1\"");
398
399 if (G_TYPE_IS_FINAL (type)(g_type_test_flags ((type), G_TYPE_FLAG_FINAL)))
400 escaped_printf (out, " final=\"1\"");
401
402 goutput_write (out, ">\n");
403
404 interfaces = g_type_interfaces (type, &n_interfaces);
405 for (i = 0; i < n_interfaces; i++)
406 {
407 GType itype = interfaces[i];
408 escaped_printf (out, " <implements name=\"%s\"/>\n",
409 g_type_name (itype));
410 }
411 g_free (interfaces);
412
413 dump_properties (type, out);
414 dump_signals (type, out);
415 goutput_write (out, " </class>\n");
416}
417
418static void
419dump_interface_type (GType type, const char *symbol, FILE *out)
420{
421 guint n_interfaces;
422 guint i;
423 GType *interfaces;
424
425 escaped_printf (out, " <interface name=\"%s\" get-type=\"%s\">\n",
426 g_type_name (type), symbol);
427
428 interfaces = g_type_interface_prerequisites (type, &n_interfaces);
429 for (i = 0; i < n_interfaces; i++)
430 {
431 GType itype = interfaces[i];
432 if (itype == G_TYPE_OBJECT((GType) ((20) << (2))))
433 {
434 /* Treat this as implicit for now; in theory GInterfaces are
435 * supported on things like GstMiniObject, but right now
436 * the introspection system only supports GObject.
437 * http://bugzilla.gnome.org/show_bug.cgi?id=559706
438 */
439 continue;
440 }
441 escaped_printf (out, " <prerequisite name=\"%s\"/>\n",
442 g_type_name (itype));
443 }
444 g_free (interfaces);
445
446 dump_properties (type, out);
447 dump_signals (type, out);
448 goutput_write (out, " </interface>\n");
449}
450
451static void
452dump_boxed_type (GType type, const char *symbol, FILE *out)
453{
454 escaped_printf (out, " <boxed name=\"%s\" get-type=\"%s\"/>\n",
455 g_type_name (type), symbol);
456}
457
458static void
459dump_flags_type (GType type, const char *symbol, FILE *out)
460{
461 guint i;
462 GFlagsClass *klass;
463
464 klass = g_type_class_ref (type);
465 escaped_printf (out, " <flags name=\"%s\" get-type=\"%s\">\n",
466 g_type_name (type), symbol);
467
468 for (i = 0; i < klass->n_values; i++)
469 {
470 GFlagsValue *value = &(klass->values[i]);
471
472 escaped_printf (out, " <member name=\"%s\" nick=\"%s\" value=\"%u\"/>\n",
473 value->value_name, value->value_nick, value->value);
474 }
475 goutput_write (out, " </flags>\n");
476}
477
478static void
479dump_enum_type (GType type, const char *symbol, FILE *out)
480{
481 guint i;
482 GEnumClass *klass;
483
484 klass = g_type_class_ref (type);
485 escaped_printf (out, " <enum name=\"%s\" get-type=\"%s\">\n",
486 g_type_name (type), symbol);
487
488 for (i = 0; i < klass->n_values; i++)
489 {
490 GEnumValue *value = &(klass->values[i]);
491
492 escaped_printf (out, " <member name=\"%s\" nick=\"%s\" value=\"%d\"/>\n",
493 value->value_name, value->value_nick, value->value);
494 }
495 goutput_write (out, " </enum>");
496}
497
498static void
499dump_fundamental_type (GType type, const char *symbol, FILE *out)
500{
501 guint n_interfaces;
502 guint i;
503 GType *interfaces;
504 GString *parent_str;
505 GType parent;
506 gboolean first = TRUE(!(0));
507
508
509 escaped_printf (out, " <fundamental name=\"%s\" get-type=\"%s\"",
510 g_type_name (type), symbol);
511
512 if (G_TYPE_IS_ABSTRACT (type)(g_type_test_flags ((type), G_TYPE_FLAG_ABSTRACT)))
513 escaped_printf (out, " abstract=\"1\"");
514
515 if (G_TYPE_IS_FINAL (type)(g_type_test_flags ((type), G_TYPE_FLAG_FINAL)))
516 escaped_printf (out, " final=\"1\"");
517
518 if (G_TYPE_IS_INSTANTIATABLE (type)(g_type_test_flags ((type), G_TYPE_FLAG_INSTANTIATABLE)))
519 escaped_printf (out, " instantiatable=\"1\"");
520
521 parent = g_type_parent (type);
522 parent_str = g_string_new ("");
523 while (parent != G_TYPE_INVALID((GType) ((0) << (2))))
524 {
525 if (first)
526 first = FALSE(0);
527 else
528 g_string_append_c (parent_str, ',')g_string_append_c_inline (parent_str, ',');
529 if (!g_type_name (parent))
530 break;
531 g_string_append (parent_str, g_type_name (parent))(__builtin_constant_p (g_type_name (parent)) ? __extension__ (
{ const char * const __val = (g_type_name (parent)); g_string_append_len_inline
(parent_str, __val, (__val != ((void*)0)) ? (gssize) strlen (
((__val) + !(__val))) : (gssize) -1); }) : g_string_append_len_inline
(parent_str, g_type_name (parent), (gssize) -1))
;
532 parent = g_type_parent (parent);
533 }
534
535 if (parent_str->len > 0)
536 escaped_printf (out, " parents=\"%s\"", parent_str->str);
537 g_string_free (parent_str, TRUE)(__builtin_constant_p ((!(0))) ? (((!(0))) ? (g_string_free) (
(parent_str), ((!(0)))) : g_string_free_and_steal (parent_str
)) : (g_string_free) ((parent_str), ((!(0)))))
;
538
539 goutput_write (out, ">\n");
540
541 interfaces = g_type_interfaces (type, &n_interfaces);
542 for (i = 0; i < n_interfaces; i++)
543 {
544 GType itype = interfaces[i];
545 escaped_printf (out, " <implements name=\"%s\"/>\n",
546 g_type_name (itype));
547 }
548 g_free (interfaces);
549 goutput_write (out, " </fundamental>\n");
550}
551
552static void
553dump_type (GType type, const char *symbol, FILE *out)
554{
555 /* XXX: We need to ensure that global ancillary structures like
556 * GParamSpecPool are initialized before we use the GType and
557 * GObject reflection API to poke at things like properties and
558 * signals; we cannot rely on GObject being instantiated at this
559 * point.
560 */
561 GObjectClass *gobject_class = g_type_class_ref (G_TYPE_OBJECT((GType) ((20) << (2))));
562
563 switch (g_type_fundamental (type))
564 {
565 case G_TYPE_OBJECT((GType) ((20) << (2))):
566 dump_object_type (type, symbol, out);
567 break;
568 case G_TYPE_INTERFACE((GType) ((2) << (2))):
569 dump_interface_type (type, symbol, out);
570 break;
571 case G_TYPE_BOXED((GType) ((18) << (2))):
572 dump_boxed_type (type, symbol, out);
573 break;
574 case G_TYPE_FLAGS((GType) ((13) << (2))):
575 dump_flags_type (type, symbol, out);
576 break;
577 case G_TYPE_ENUM((GType) ((12) << (2))):
578 dump_enum_type (type, symbol, out);
579 break;
580 case G_TYPE_POINTER((GType) ((17) << (2))):
581 /* GValue, etc. Just skip them. */
582 break;
583 default:
584 dump_fundamental_type (type, symbol, out);
585 break;
586 }
587
588 g_type_class_unref ((GTypeClass *) gobject_class);
589}
590
591static void
592dump_error_quark (GQuark quark, const char *symbol, FILE *out)
593{
594 escaped_printf (out, " <error-quark function=\"%s\" domain=\"%s\"/>\n",
595 symbol, g_quark_to_string (quark));
596}
597
598/**
599 * g_irepository_dump:
600 * @input_filename: (type filename): Input filename (for example `input.txt`)
601 * @output_filename: (type filename): Output filename (for example `output.xml`)
602 * @error: a %GError
603 *
604 * Dump the introspection data from the types specified in @input_filename to
605 * @output_filename.
606 *
607 * The input file should be a
608 * UTF-8 Unix-line-ending text file, with each line containing either
609 * `get-type:` followed by the name of a [type@GObject.Type] `_get_type`
610 * function, or `error-quark:` followed by the name of an error quark function.
611 * No extra whitespace is allowed.
612 *
613 * This function will overwrite the contents of the output file.
614 *
615 * Returns: true on success, false on error
616 * Since: 2.80
617 */
618#ifndef G_IREPOSITORY_COMPILATION
619static gboolean
620dump_irepository (const char *arg,
621 GError **error) G_GNUC_UNUSED__attribute__ ((__unused__));
622static gboolean
623dump_irepository (const char *arg,
624 GError **error)
625#else
626gboolean
627g_irepository_dump (const char *arg,
628 GError **error)
629#endif
630{
631 GHashTable *output_types;
632 FILE *input;
633 FILE *output;
634 GModule *self;
635 gboolean caught_error = FALSE(0);
636
637 char **args = g_strsplit (arg, ",", 2);
638 if (args == NULL((void*)0))
7
Assuming 'args' is equal to NULL
8
Taking true branch
639 return FALSE(0);
9
Returning without writing to '*error'
640
641 const char *input_filename = args[0];
642 const char *output_filename = args[1];
643
644 self = g_module_open (NULL((void*)0), 0);
645 if (!self)
646 {
647 g_set_error (error,
648 G_FILE_ERRORg_file_error_quark (),
649 G_FILE_ERROR_FAILED,
650 "failed to open self: %s",
651 g_module_error ());
652 g_strfreev (args);
653 return FALSE(0);
654 }
655
656 input = fopen (input_filename, "rb");
657 if (input == NULL((void*)0))
658 {
659 int saved_errno = errno(*__errno_location ());
660 g_set_error (error, G_FILE_ERRORg_file_error_quark (), g_file_error_from_errno (saved_errno),
661 "Failed to open ‘%s’: %s", input_filename, g_strerror (saved_errno));
662
663 g_module_close (self);
664 g_strfreev (args);
665
666 return FALSE(0);
667 }
668
669 output = fopen (output_filename, "wb");
670 if (output == NULL((void*)0))
671 {
672 int saved_errno = errno(*__errno_location ());
673 g_set_error (error, G_FILE_ERRORg_file_error_quark (), g_file_error_from_errno (saved_errno),
674 "Failed to open ‘%s’: %s", output_filename, g_strerror (saved_errno));
675
676 fclose (input);
677 g_module_close (self);
678 g_strfreev (args);
679
680 return FALSE(0);
681 }
682
683 goutput_write (output, "<?xml version=\"1.0\"?>\n");
684 goutput_write (output, "<dump>\n");
685
686 output_types = g_hash_table_new (NULL((void*)0), NULL((void*)0));
687
688 while (TRUE(!(0)))
689 {
690 gsize len;
691 char *line = read_line (input, &len);
692 const char *function;
693
694 if (line == NULL((void*)0) || *line == '\0')
695 {
696 g_free (line);
697 break;
698 }
699
700 g_strchomp (line);
701
702 if (strncmp (line, "get-type:", strlen ("get-type:")) == 0)
703 {
704 GType type;
705
706 function = line + strlen ("get-type:");
707
708 type = invoke_get_type (self, function, error);
709
710 if (type == G_TYPE_INVALID((GType) ((0) << (2))))
711 {
712 g_printerr ("Invalid GType function: '%s'\n", function);
713 caught_error = TRUE(!(0));
714 g_free (line);
715 break;
716 }
717
718 if (g_hash_table_lookup (output_types, (gpointer) type))
719 goto next;
720 g_hash_table_insert (output_types, (gpointer) type, (gpointer) type);
721
722 dump_type (type, function, output);
723 }
724 else if (strncmp (line, "error-quark:", strlen ("error-quark:")) == 0)
725 {
726 GQuark quark;
727 function = line + strlen ("error-quark:");
728 quark = invoke_error_quark (self, function, error);
729
730 if (quark == 0)
731 {
732 g_printerr ("Invalid error quark function: '%s'\n", function);
733 caught_error = TRUE(!(0));
734 g_free (line);
735 break;
736 }
737
738 dump_error_quark (quark, function, output);
739 }
740
741
742 next:
743 g_free (line);
744 }
745
746 g_hash_table_destroy (output_types);
747
748 goutput_write (output, "</dump>\n");
749
750 {
751 /* Avoid overwriting an earlier set error */
752 if (fclose (input) != 0 && !caught_error)
753 {
754 int saved_errno = errno(*__errno_location ());
755
756 g_set_error (error, G_FILE_ERRORg_file_error_quark (), g_file_error_from_errno (saved_errno),
757 "Error closing input file ‘%s’: %s", input_filename,
758 g_strerror (saved_errno));
759 caught_error = TRUE(!(0));
760 }
761
762 if (fclose (output) != 0 && !caught_error)
763 {
764 int saved_errno = errno(*__errno_location ());
765
766 g_set_error (error, G_FILE_ERRORg_file_error_quark (), g_file_error_from_errno (saved_errno),
767 "Error closing output file ‘%s’: %s", output_filename,
768 g_strerror (saved_errno));
769 caught_error = TRUE(!(0));
770 }
771 }
772
773 g_strfreev (args);
774
775 return !caught_error;
776}
777
778
779int
780main(int argc, char **argv)
781{
782 GError *error = NULL((void*)0);
1
'error' initialized to a null pointer value
783 const char *introspect_dump_prefix = "--introspect-dump=";
784
785#if !GLIB_CHECK_VERSION(2,35,0)(2 > (2) || (2 == (2) && 80 > (35)) || (2 == (2
) && 80 == (35) && 2 >= (0)))
786 g_type_init ();
787#endif
788
789
790
791 if (argc != 2 || !g_str_has_prefix (argv[1], introspect_dump_prefix)(__builtin_constant_p (introspect_dump_prefix)? __extension__
({ const char * const __str = (argv[1]); const char * const __prefix
= (introspect_dump_prefix); gboolean __result = (0); if (__str
== ((void*)0) || __prefix == ((void*)0)) __result = (g_str_has_prefix
) (__str, __prefix); else { const size_t __str_len = strlen (
((__str) + !(__str))); const size_t __prefix_len = strlen (((
__prefix) + !(__prefix))); if (__str_len >= __prefix_len) __result
= memcmp (((__str) + !(__str)), ((__prefix) + !(__prefix)), __prefix_len
) == 0; } __result; }) : (g_str_has_prefix) (argv[1], introspect_dump_prefix
) )
)
2
Assuming 'argc' is equal to 2
3
'?' condition is false
4
Assuming the condition is false
5
Taking false branch
792 {
793 g_printerr ("Usage: %s --introspect-dump=input,output", argv[0]);
794 exit (1);
795 }
796
797 if (!dump_irepository (argv[1] + strlen(introspect_dump_prefix), &error))
6
Calling 'dump_irepository'
10
Returning from 'dump_irepository'
11
Taking true branch
798 {
799 g_printerr ("%s\n", error->message);
12
Access to field 'message' results in a dereference of a null pointer (loaded from variable 'error')
800 exit (1);
801 }
802 exit (0);
803}
804extern GType mate_panel_applet_get_type(void);
805extern GType mate_panel_applet_orient_get_type(void);
806extern GType mate_panel_applet_background_type_get_type(void);
807extern GType mate_panel_applet_flags_get_type(void);
808G_MODULE_EXPORT__attribute__((visibility("default"))) GType (*GI_GET_TYPE_FUNCS_[])(void) = {
809 mate_panel_applet_get_type,
810 mate_panel_applet_orient_get_type,
811 mate_panel_applet_background_type_get_type,
812 mate_panel_applet_flags_get_type
813};
diff --git a/2024-06-18-172109-13286-1@e182420b844f_master/report-92ce7b.html b/2024-06-18-172109-13286-1@e182420b844f_master/report-92ce7b.html new file mode 100644 index 00000000..785c2035 --- /dev/null +++ b/2024-06-18-172109-13286-1@e182420b844f_master/report-92ce7b.html @@ -0,0 +1,3246 @@ + + + +mate-panel-applet.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:libmate-panel-applet/mate-panel-applet.c
Warning:line 1704, column 35
Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name mate-panel-applet.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/libmate-panel-applet -fcoverage-compilation-dir=/rootdir/libmate-panel-applet -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I .. -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/gio-unix-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I ../libmate-panel-applet -D MATELOCALEDIR="/usr/local/share/locale" -D PIC -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-18-172109-13286-1 -x c mate-panel-applet.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * mate-panel-applet.c: panel applet writing library.
3 *
4 * Copyright (c) 2010 Carlos Garcia Campos <carlosgc@gnome.org>
5 * Copyright (C) 2001 Sun Microsystems, Inc.
6 * Copyright (C) 2012-2021 MATE Developers
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
17 *
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the
20 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22 *
23 * Authors:
24 * Mark McLoughlin <mark@skynet.ie>
25 */
26
27#ifdef HAVE_CONFIG_H1
28#include <config.h>
29#endif
30
31#include <unistd.h>
32#include <stdlib.h>
33#include <string.h>
34
35#include <glib/gi18n-lib.h>
36#include <cairo.h>
37#include <gdk/gdk.h>
38#include <gdk/gdkkeysyms.h>
39#include <gtk/gtk.h>
40
41#ifdef HAVE_X111
42#include <cairo-xlib.h>
43#include <gdk/gdkx.h>
44#include <gtk/gtkx.h>
45#include <X11/Xatom.h>
46#include "panel-plug-private.h"
47#endif
48
49#include "mate-panel-applet.h"
50#include "panel-applet-private.h"
51#include "mate-panel-applet-factory.h"
52#include "mate-panel-applet-marshal.h"
53#include "mate-panel-applet-enums.h"
54
55typedef struct {
56 GtkWidget *plug;
57 GDBusConnection *connection;
58
59 gboolean out_of_process;
60
61 char *id;
62 GClosure *closure;
63 char *object_path;
64 guint object_id;
65 char *prefs_path;
66
67 GtkUIManager *ui_manager;
68 GtkActionGroup *applet_action_group;
69 GtkActionGroup *panel_action_group;
70
71 MatePanelAppletFlags flags;
72 MatePanelAppletOrient orient;
73 guint size;
74 char *background;
75
76 int previous_width;
77 int previous_height;
78
79 int *size_hints;
80 int size_hints_len;
81
82 gboolean moving_focus_out;
83
84 gboolean locked;
85 gboolean locked_down;
86} MatePanelAppletPrivate;
87
88enum {
89 CHANGE_ORIENT,
90 CHANGE_SIZE,
91 CHANGE_BACKGROUND,
92 MOVE_FOCUS_OUT_OF_APPLET,
93 LAST_SIGNAL
94};
95
96static guint mate_panel_applet_signals[LAST_SIGNAL] = { 0 };
97
98enum {
99 PROP_0,
100 PROP_OUT_OF_PROCESS,
101 PROP_ID,
102 PROP_CLOSURE,
103 PROP_CONNECTION,
104 PROP_PREFS_PATH,
105 PROP_ORIENT,
106 PROP_SIZE,
107 PROP_BACKGROUND,
108 PROP_FLAGS,
109 PROP_SIZE_HINTS,
110 PROP_LOCKED,
111 PROP_LOCKED_DOWN
112};
113
114static void mate_panel_applet_handle_background (MatePanelApplet *applet);
115static GtkAction *mate_panel_applet_menu_get_action (MatePanelApplet *applet,
116 const gchar *action);
117static void mate_panel_applet_menu_update_actions (MatePanelApplet *applet);
118static void mate_panel_applet_menu_cmd_remove (GtkAction *action,
119 MatePanelApplet *applet);
120static void mate_panel_applet_menu_cmd_move (GtkAction *action,
121 MatePanelApplet *applet);
122static void mate_panel_applet_menu_cmd_lock (GtkAction *action,
123 MatePanelApplet *applet);
124static void mate_panel_applet_register_object (MatePanelApplet *applet);
125void _mate_panel_applet_apply_css (GtkWidget* widget, MatePanelAppletBackgroundType type);
126
127static const gchar panel_menu_ui[] =
128 "<ui>\n"
129 " <popup name=\"MatePanelAppletPopup\" action=\"PopupAction\">\n"
130 " <placeholder name=\"AppletItems\"/>\n"
131 " <separator/>\n"
132 " <menuitem name=\"RemoveItem\" action=\"Remove\"/>\n"
133 " <menuitem name=\"MoveItem\" action=\"Move\"/>\n"
134 " <separator/>\n"
135 " <menuitem name=\"LockItem\" action=\"Lock\"/>\n"
136 " </popup>\n"
137 "</ui>\n";
138
139static const GtkActionEntry menu_entries[] = {
140 { "Remove", "list-remove", N_("_Remove From Panel")("_Remove From Panel"),
141 NULL((void*)0), NULL((void*)0),
142 G_CALLBACK (mate_panel_applet_menu_cmd_remove)((GCallback) (mate_panel_applet_menu_cmd_remove)) },
143 { "Move", NULL((void*)0), N_("_Move")("_Move"),
144 NULL((void*)0), NULL((void*)0),
145 G_CALLBACK (mate_panel_applet_menu_cmd_move)((GCallback) (mate_panel_applet_menu_cmd_move)) }
146};
147
148static const GtkToggleActionEntry menu_toggle_entries[] = {
149 { "Lock", NULL((void*)0), N_("Loc_k To Panel")("Loc_k To Panel"),
150 NULL((void*)0), NULL((void*)0),
151 G_CALLBACK (mate_panel_applet_menu_cmd_lock)((GCallback) (mate_panel_applet_menu_cmd_lock)),
152 FALSE(0) }
153};
154
155G_DEFINE_TYPE_WITH_PRIVATE (MatePanelApplet, mate_panel_applet, GTK_TYPE_EVENT_BOX)static void mate_panel_applet_init (MatePanelApplet *self); static
void mate_panel_applet_class_init (MatePanelAppletClass *klass
); static GType mate_panel_applet_get_type_once (void); static
gpointer mate_panel_applet_parent_class = ((void*)0); static
gint MatePanelApplet_private_offset; static void mate_panel_applet_class_intern_init
(gpointer klass) { mate_panel_applet_parent_class = g_type_class_peek_parent
(klass); if (MatePanelApplet_private_offset != 0) g_type_class_adjust_private_offset
(klass, &MatePanelApplet_private_offset); mate_panel_applet_class_init
((MatePanelAppletClass*) klass); } __attribute__ ((__unused__
)) static inline gpointer mate_panel_applet_get_instance_private
(MatePanelApplet *self) { return (((gpointer) ((guint8*) (self
) + (glong) (MatePanelApplet_private_offset)))); } GType mate_panel_applet_get_type
(void) { static GType static_g_define_type_id = 0; if ((__extension__
({ _Static_assert (sizeof *(&static_g_define_type_id) ==
sizeof (gpointer), "Expression evaluates to false"); (void) (
0 ? (gpointer) * (&static_g_define_type_id) : ((void*)0))
; (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter_pointer (
&static_g_define_type_id)); })) ) { GType g_define_type_id
= mate_panel_applet_get_type_once (); (__extension__ ({ _Static_assert
(sizeof *(&static_g_define_type_id) == sizeof (gpointer)
, "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id
) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer
((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id
)); })) ; } return static_g_define_type_id; } __attribute__ (
(__noinline__)) static GType mate_panel_applet_get_type_once (
void) { GType g_define_type_id = g_type_register_static_simple
((gtk_event_box_get_type ()), g_intern_static_string ("MatePanelApplet"
), sizeof (MatePanelAppletClass), (GClassInitFunc)(void (*)(void
)) mate_panel_applet_class_intern_init, sizeof (MatePanelApplet
), (GInstanceInitFunc)(void (*)(void)) mate_panel_applet_init
, (GTypeFlags) 0); { {{ MatePanelApplet_private_offset = g_type_add_instance_private
(g_define_type_id, sizeof (MatePanelAppletPrivate)); };} } return
g_define_type_id; }
156
157#define MATE_PANEL_APPLET_INTERFACE"org.mate.panel.applet.Applet" "org.mate.panel.applet.Applet"
158#define MATE_PANEL_APPLET_OBJECT_PATH"/org/mate/panel/applet/%s/%d" "/org/mate/panel/applet/%s/%d"
159
160char *
161mate_panel_applet_get_preferences_path (MatePanelApplet *applet)
162{
163 MatePanelAppletPrivate *priv;
164
165 g_return_val_if_fail (MATE_PANEL_IS_APPLET (applet), NULL)do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return (((void*)0)); } } while (0)
;
166
167 priv = mate_panel_applet_get_instance_private (applet);
168 if (!priv->prefs_path)
169 return NULL((void*)0);
170
171 return g_strdup (priv->prefs_path)g_strdup_inline (priv->prefs_path);
172}
173
174static void
175mate_panel_applet_set_preferences_path (MatePanelApplet *applet,
176 const char *prefs_path)
177{
178 MatePanelAppletPrivate *priv;
179
180 priv = mate_panel_applet_get_instance_private (applet);
181
182 if (priv->prefs_path == prefs_path)
183 return;
184
185 if (g_strcmp0 (priv->prefs_path, prefs_path) == 0)
186 return;
187
188 if (prefs_path)
189 priv->prefs_path = g_strdup (prefs_path)g_strdup_inline (prefs_path);
190
191 g_object_notify (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
, "prefs-path");
192}
193
194MatePanelAppletFlags
195mate_panel_applet_get_flags (MatePanelApplet *applet)
196{
197 MatePanelAppletPrivate *priv;
198
199 g_return_val_if_fail (MATE_PANEL_IS_APPLET (applet), MATE_PANEL_APPLET_FLAGS_NONE)do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return (MATE_PANEL_APPLET_FLAGS_NONE); } } while (0)
;
200
201 priv = mate_panel_applet_get_instance_private (applet);
202
203 return priv->flags;
204}
205
206void
207mate_panel_applet_set_flags (MatePanelApplet *applet,
208 MatePanelAppletFlags flags)
209{
210 MatePanelAppletPrivate *priv;
211
212 g_return_if_fail (MATE_PANEL_IS_APPLET (applet))do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return; } } while (0)
;
213
214 priv = mate_panel_applet_get_instance_private (applet);
215
216 if (priv->flags == flags)
217 return;
218
219 priv->flags = flags;
220
221 g_object_notify (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
, "flags");
222
223 if (priv->connection) {
224 GVariantBuilder builder;
225 GVariantBuilder invalidated_builder;
226 GError *error = NULL((void*)0);
227
228 g_variant_builder_init (&builder, G_VARIANT_TYPE_ARRAY((const GVariantType *) "a*"));
229 g_variant_builder_init (&invalidated_builder, G_VARIANT_TYPE ("as")(g_variant_type_checked_ (("as"))));
230
231 g_variant_builder_add (&builder, "{sv}", "Flags",
232 g_variant_new_uint32 (priv->flags));
233
234 g_dbus_connection_emit_signal (priv->connection,
235 NULL((void*)0),
236 priv->object_path,
237 "org.freedesktop.DBus.Properties",
238 "PropertiesChanged",
239 g_variant_new ("(sa{sv}as)",
240 MATE_PANEL_APPLET_INTERFACE"org.mate.panel.applet.Applet",
241 &builder,
242 &invalidated_builder),
243 &error);
244 if (error) {
245 g_printerr ("Failed to send signal PropertiesChanged::Flags: %s\n",
246 error->message);
247 g_error_free (error);
248 }
249 g_variant_builder_clear (&builder);
250 g_variant_builder_clear (&invalidated_builder);
251 }
252}
253
254static void
255mate_panel_applet_size_hints_ensure (MatePanelApplet *applet,
256 int new_size)
257{
258 MatePanelAppletPrivate *priv;
259
260 priv = mate_panel_applet_get_instance_private (applet);
261 if (priv->size_hints && priv->size_hints_len < new_size) {
262 g_free (priv->size_hints);
263 priv->size_hints = g_new (gint, new_size)((gint *) g_malloc_n ((new_size), sizeof (gint)));
264 } else if (!priv->size_hints) {
265 priv->size_hints = g_new (gint, new_size)((gint *) g_malloc_n ((new_size), sizeof (gint)));
266 }
267 priv->size_hints_len = new_size;
268}
269
270static gboolean
271mate_panel_applet_size_hints_changed (MatePanelApplet *applet,
272 const int *size_hints,
273 int n_elements,
274 int base_size)
275{
276 MatePanelAppletPrivate *priv;
277 gint i;
278
279 priv = mate_panel_applet_get_instance_private (applet);
280
281 if (!priv->size_hints)
282 return TRUE(!(0));
283
284 if (priv->size_hints_len != n_elements)
285 return TRUE(!(0));
286
287 for (i = 0; i < n_elements; i++) {
288 if (size_hints[i] + base_size != priv->size_hints[i])
289 return TRUE(!(0));
290 }
291
292 return FALSE(0);
293}
294
295/**
296 * mate_panel_applet_set_size_hints:
297 * @applet: applet
298 * @size_hints: (array length=n_elements): List of integers
299 * @n_elements: Length of @size_hints
300 * @base_size: base_size
301 */
302void
303mate_panel_applet_set_size_hints (MatePanelApplet *applet,
304 const int *size_hints,
305 int n_elements,
306 int base_size)
307{
308 MatePanelAppletPrivate *priv;
309 gint i;
310
311 /* Make sure property has really changed to avoid bus traffic */
312 if (!mate_panel_applet_size_hints_changed (applet, size_hints, n_elements, base_size))
313 return;
314
315 priv = mate_panel_applet_get_instance_private (applet);
316
317 mate_panel_applet_size_hints_ensure (applet, n_elements);
318 for (i = 0; i < n_elements; i++)
319 priv->size_hints[i] = size_hints[i] + base_size;
320
321 g_object_notify (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
, "size-hints");
322
323 if (priv->connection) {
324 GVariantBuilder builder;
325 GVariantBuilder invalidated_builder;
326 GVariant **children;
327 GError *error = NULL((void*)0);
328
329 g_variant_builder_init (&builder, G_VARIANT_TYPE_ARRAY((const GVariantType *) "a*"));
330 g_variant_builder_init (&invalidated_builder, G_VARIANT_TYPE ("as")(g_variant_type_checked_ (("as"))));
331
332 children = g_new (GVariant *, priv->size_hints_len)((GVariant * *) g_malloc_n ((priv->size_hints_len), sizeof
(GVariant *)))
;
333 for (i = 0; i < n_elements; i++)
334 children[i] = g_variant_new_int32 (priv->size_hints[i]);
335 g_variant_builder_add (&builder, "{sv}", "SizeHints",
336 g_variant_new_array (G_VARIANT_TYPE_INT32((const GVariantType *) "i"),
337 children, priv->size_hints_len));
338 g_free (children);
339
340 g_dbus_connection_emit_signal (priv->connection,
341 NULL((void*)0),
342 priv->object_path,
343 "org.freedesktop.DBus.Properties",
344 "PropertiesChanged",
345 g_variant_new ("(sa{sv}as)",
346 MATE_PANEL_APPLET_INTERFACE"org.mate.panel.applet.Applet",
347 &builder,
348 &invalidated_builder),
349 &error);
350 if (error) {
351 g_printerr ("Failed to send signal PropertiesChanged::SizeHints: %s\n",
352 error->message);
353 g_error_free (error);
354 }
355 g_variant_builder_clear (&builder);
356 g_variant_builder_clear (&invalidated_builder);
357 }
358}
359
360guint
361mate_panel_applet_get_size (MatePanelApplet *applet)
362{
363 MatePanelAppletPrivate *priv;
364
365 g_return_val_if_fail (MATE_PANEL_IS_APPLET (applet), 0)do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return (0); } } while (0)
;
366
367 priv = mate_panel_applet_get_instance_private (applet);
368
369 return priv->size;
370}
371
372/* Applets cannot set their size, so API is not public. */
373static void
374mate_panel_applet_set_size (MatePanelApplet *applet,
375 guint size)
376{
377 MatePanelAppletPrivate *priv;
378
379 g_return_if_fail (MATE_PANEL_IS_APPLET (applet))do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return; } } while (0)
;
380
381 priv = mate_panel_applet_get_instance_private (applet);
382
383 if (priv->size == size)
384 return;
385
386 priv->size = size;
387 g_signal_emit (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
,
388 mate_panel_applet_signals [CHANGE_SIZE],
389 0, size);
390
391 g_object_notify (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
, "size");
392}
393
394MatePanelAppletOrient
395mate_panel_applet_get_orient (MatePanelApplet *applet)
396{
397 MatePanelAppletPrivate *priv;
398
399 g_return_val_if_fail (MATE_PANEL_IS_APPLET (applet), 0)do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return (0); } } while (0)
;
400
401 priv = mate_panel_applet_get_instance_private (applet);
402
403 return priv->orient;
404}
405
406/* Applets cannot set their orientation, so API is not public. */
407static void
408mate_panel_applet_set_orient (MatePanelApplet *applet,
409 MatePanelAppletOrient orient)
410{
411 MatePanelAppletPrivate *priv;
412
413 g_return_if_fail (MATE_PANEL_IS_APPLET (applet))do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return; } } while (0)
;
414
415 priv = mate_panel_applet_get_instance_private (applet);
416
417 if (priv->orient == orient)
418 return;
419
420 priv->orient = orient;
421 g_signal_emit (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
,
422 mate_panel_applet_signals [CHANGE_ORIENT],
423 0, orient);
424
425 g_object_notify (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
, "orient");
426}
427
428static void
429mate_panel_applet_set_locked (MatePanelApplet *applet,
430 gboolean locked)
431{
432 MatePanelAppletPrivate *priv;
433 GtkAction *action;
434
435 g_return_if_fail (MATE_PANEL_IS_APPLET (applet))do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return; } } while (0)
;
436
437 priv = mate_panel_applet_get_instance_private (applet);
438
439 if (priv->locked == locked)
440 return;
441
442 priv->locked = locked;
443
444 action = mate_panel_applet_menu_get_action (applet, "Lock");
445 g_signal_handlers_block_by_func (action,g_signal_handlers_block_matched ((action), (GSignalMatchType)
(G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0
), (mate_panel_applet_menu_cmd_lock), (applet))
446 mate_panel_applet_menu_cmd_lock,g_signal_handlers_block_matched ((action), (GSignalMatchType)
(G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0
), (mate_panel_applet_menu_cmd_lock), (applet))
447 applet)g_signal_handlers_block_matched ((action), (GSignalMatchType)
(G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0
), (mate_panel_applet_menu_cmd_lock), (applet))
;
448 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action)((((GtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((gtk_toggle_action_get_type ()))))))
, locked);
449 g_signal_handlers_unblock_by_func (action,g_signal_handlers_unblock_matched ((action), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (mate_panel_applet_menu_cmd_lock), (applet))
450 mate_panel_applet_menu_cmd_lock,g_signal_handlers_unblock_matched ((action), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (mate_panel_applet_menu_cmd_lock), (applet))
451 applet)g_signal_handlers_unblock_matched ((action), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (mate_panel_applet_menu_cmd_lock), (applet))
;
452
453 mate_panel_applet_menu_update_actions (applet);
454
455 g_object_notify (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
, "locked");
456
457 if (priv->connection) {
458 GError *error = NULL((void*)0);
459
460 g_dbus_connection_emit_signal (priv->connection,
461 NULL((void*)0),
462 priv->object_path,
463 MATE_PANEL_APPLET_INTERFACE"org.mate.panel.applet.Applet",
464 locked ? "Lock" : "Unlock",
465 NULL((void*)0), &error);
466 if (error) {
467 g_printerr ("Failed to send signal %s: %s\n",
468 locked ? "Lock" : "Unlock",
469 error->message);
470 g_error_free (error);
471 }
472 }
473}
474
475gboolean
476mate_panel_applet_get_locked_down (MatePanelApplet *applet)
477{
478 MatePanelAppletPrivate *priv;
479
480 g_return_val_if_fail (MATE_PANEL_IS_APPLET (applet), FALSE)do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return ((0)); } } while (0)
;
481
482 priv = mate_panel_applet_get_instance_private (applet);
483
484 return priv->locked_down;
485}
486
487/* Applets cannot set the lockdown state, so API is not public. */
488static void
489mate_panel_applet_set_locked_down (MatePanelApplet *applet,
490 gboolean locked_down)
491{
492 MatePanelAppletPrivate *priv;
493
494 g_return_if_fail (MATE_PANEL_IS_APPLET (applet))do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return; } } while (0)
;
495
496 priv = mate_panel_applet_get_instance_private (applet);
497
498 if (priv->locked_down == locked_down)
499 return;
500
501 priv->locked_down = locked_down;
502 mate_panel_applet_menu_update_actions (applet);
503
504 g_object_notify (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
, "locked-down");
505}
506
507#ifdef HAVE_X111
508
509static Atom _net_wm_window_type = None0L;
510static Atom _net_wm_window_type_dock = None0L;
511static Atom _net_active_window = None0L;
512
513static void
514mate_panel_applet_init_atoms (Display *xdisplay)
515{
516 if (_net_wm_window_type == None0L)
517 _net_wm_window_type = XInternAtom (xdisplay,
518 "_NET_WM_WINDOW_TYPE",
519 False0);
520
521 if (_net_wm_window_type_dock == None0L)
522 _net_wm_window_type_dock = XInternAtom (xdisplay,
523 "_NET_WM_WINDOW_TYPE_DOCK",
524 False0);
525
526 if (_net_active_window == None0L)
527 _net_active_window = XInternAtom (xdisplay,
528 "_NET_ACTIVE_WINDOW",
529 False0);
530}
531
532static Window
533mate_panel_applet_find_toplevel_dock_window (MatePanelApplet *applet,
534 Display *xdisplay)
535{
536 GtkWidget *toplevel;
537 Window xwin;
538 Window root, parent, *child;
539 int num_children;
540
541 toplevel = gtk_widget_get_toplevel (GTK_WIDGET (applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
);
542 if (!gtk_widget_get_realized (toplevel))
543 return None0L;
544
545 xwin = GDK_WINDOW_XID (gtk_widget_get_window (toplevel))(gdk_x11_window_get_xid (gtk_widget_get_window (toplevel)));
546
547 child = NULL((void*)0);
548 parent = root = None0L;
549 do {
550 Atom type_return;
551 Atom window_type;
552 int format_return;
553 gulong number_return, bytes_after_return;
554 guchar *data_return;
555
556 XGetWindowProperty (xdisplay,
557 xwin,
558 _net_wm_window_type,
559 0, 1, False0,
560 XA_ATOM((Atom) 4),
561 &type_return, &format_return,
562 &number_return,
563 &bytes_after_return,
564 &data_return);
565
566 if (type_return == XA_ATOM((Atom) 4)) {
567 window_type = *(Atom *) data_return;
568
569 XFree (data_return);
570 data_return = NULL((void*)0);
571
572 if (window_type == _net_wm_window_type_dock)
573 return xwin;
574 }
575
576 if (!XQueryTree (xdisplay,
577 xwin,
578 &root, &parent, &child,
579 (guint *) &num_children)) {
580 return None0L;
581 }
582
583 if (child && num_children > 0)
584 XFree (child);
585
586 xwin = parent;
587
588 } while (xwin != None0L && xwin != root);
589
590 return None0L;
591}
592
593#endif /* HAVE_X11 */
594
595/* This function
596 * 1) Gets the window id of the panel that contains the applet
597 * using XQueryTree and XGetWindowProperty to find an ancestor
598 * window with the _NET_WM_WINDOW_TYPE_DOCK window type.
599 * 2) Sends a _NET_ACTIVE_WINDOW message to get that panel focused
600 */
601void
602mate_panel_applet_request_focus (MatePanelApplet *applet,
603 guint32 timestamp)
604{
605#ifdef HAVE_X111
606 GdkScreen *screen;
607 GdkWindow *root;
608 GdkDisplay *display;
609 Display *xdisplay;
610 Window dock_xwindow;
611 Window xroot;
612 XEvent xev;
613
614 if (!GDK_IS_X11_DISPLAY (gdk_display_get_default ())(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gdk_display_get_default ())); GType __t = ((gdk_x11_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
)
615 return;
616
617 g_return_if_fail (MATE_PANEL_IS_APPLET (applet))do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return; } } while (0)
;
618
619 screen = gdk_screen_get_default(); /*There is only one screen since GTK 3.22*/
620 root = gdk_screen_get_root_window (screen);
621 display = gdk_screen_get_display (screen);
622
623 xdisplay = GDK_DISPLAY_XDISPLAY (display)(gdk_x11_display_get_xdisplay (display));
624 xroot = GDK_WINDOW_XID (root)(gdk_x11_window_get_xid (root));
625
626 mate_panel_applet_init_atoms (xdisplay);
627
628 dock_xwindow = mate_panel_applet_find_toplevel_dock_window (applet, xdisplay);
629 if (dock_xwindow == None0L)
630 return;
631
632 xev.xclient.type = ClientMessage33;
633 xev.xclient.serial = 0;
634 xev.xclient.send_event = True1;
635 xev.xclient.window = dock_xwindow;
636 xev.xclient.message_type = _net_active_window;
637 xev.xclient.format = 32;
638 xev.xclient.data.l[0] = 1; /* requestor type; we're an app, I guess */
639 xev.xclient.data.l[1] = timestamp;
640 xev.xclient.data.l[2] = None0L; /* "currently active window", supposedly */
641 xev.xclient.data.l[3] = 0;
642 xev.xclient.data.l[4] = 0;
643
644 XSendEvent (xdisplay,
645 xroot, False0,
646 SubstructureRedirectMask(1L<<20) | SubstructureNotifyMask(1L<<19),
647 &xev);
648#endif
649}
650
651static GtkAction *
652mate_panel_applet_menu_get_action (MatePanelApplet *applet,
653 const gchar *action)
654{
655 MatePanelAppletPrivate *priv;
656
657 priv = mate_panel_applet_get_instance_private (applet);
658
659 return gtk_action_group_get_action (priv->panel_action_group, action);
660}
661
662static void
663mate_panel_applet_menu_update_actions (MatePanelApplet *applet)
664{
665 MatePanelAppletPrivate *priv;
666
667 priv = mate_panel_applet_get_instance_private (applet);
668 g_object_set (mate_panel_applet_menu_get_action (applet, "Lock"),
669 "visible", !priv->locked_down,
670 NULL((void*)0));
671 g_object_set (mate_panel_applet_menu_get_action (applet, "Move"),
672 "sensitive", !priv->locked,
673 "visible", !priv->locked_down,
674 NULL((void*)0));
675 g_object_set (mate_panel_applet_menu_get_action (applet, "Remove"),
676 "sensitive", !priv->locked,
677 "visible", !priv->locked_down,
678 NULL((void*)0));
679}
680
681static void
682mate_panel_applet_menu_cmd_remove (GtkAction *action,
683 MatePanelApplet *applet)
684{
685 MatePanelAppletPrivate *priv;
686 GError *error = NULL((void*)0);
687
688 priv = mate_panel_applet_get_instance_private (applet);
689
690 if (!priv->connection)
691 return;
692
693 g_dbus_connection_emit_signal (priv->connection,
694 NULL((void*)0),
695 priv->object_path,
696 MATE_PANEL_APPLET_INTERFACE"org.mate.panel.applet.Applet",
697 "RemoveFromPanel",
698 NULL((void*)0), &error);
699 if (error) {
700 g_printerr ("Failed to send signal RemoveFromPanel: %s\n",
701 error->message);
702 g_error_free (error);
703 }
704}
705
706static void
707mate_panel_applet_menu_cmd_move (GtkAction *action,
708 MatePanelApplet *applet)
709{
710 MatePanelAppletPrivate *priv;
711 GError *error = NULL((void*)0);
712
713 priv = mate_panel_applet_get_instance_private (applet);
714
715 if (!priv->connection)
716 return;
717
718 g_dbus_connection_emit_signal (priv->connection,
719 NULL((void*)0),
720 priv->object_path,
721 MATE_PANEL_APPLET_INTERFACE"org.mate.panel.applet.Applet",
722 "Move",
723 NULL((void*)0), &error);
724 if (error) {
725 g_printerr ("Failed to send signal RemoveFromPanel: %s\n",
726 error->message);
727 g_error_free (error);
728 }
729}
730
731static void
732mate_panel_applet_menu_cmd_lock (GtkAction *action,
733 MatePanelApplet *applet)
734{
735 gboolean locked;
736
737 locked = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)((((GtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((gtk_toggle_action_get_type ()))))))
);
738 mate_panel_applet_set_locked (applet, locked);
739}
740
741void
742mate_panel_applet_setup_menu (MatePanelApplet *applet,
743 const gchar *xml,
744 GtkActionGroup *applet_action_group)
745{
746 MatePanelAppletPrivate *priv;
747 gchar *new_xml;
748 GError *error = NULL((void*)0);
749
750 g_return_if_fail (MATE_PANEL_IS_APPLET (applet))do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return; } } while (0)
;
751 g_return_if_fail (xml != NULL)do { if ((xml != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "xml != NULL"); return
; } } while (0)
;
752
753 priv = mate_panel_applet_get_instance_private (applet);
754
755 if (priv->applet_action_group)
756 return;
757
758 priv->applet_action_group = g_object_ref (applet_action_group)((__typeof__ (applet_action_group)) (g_object_ref) (applet_action_group
))
;
759 gtk_ui_manager_insert_action_group (priv->ui_manager,
760 applet_action_group, 0);
761
762 new_xml = g_strdup_printf ("<ui><popup name=\"MatePanelAppletPopup\" action=\"AppletItems\">"
763 "<placeholder name=\"AppletItems\">%s\n</placeholder>\n"
764 "</popup></ui>\n", xml);
765 gtk_ui_manager_add_ui_from_string (priv->ui_manager, new_xml, -1, &error);
766 g_free (new_xml);
767 gtk_ui_manager_ensure_update (priv->ui_manager);
768 if (error) {
769 g_warning ("Error merging menus: %s\n", error->message);
770 g_error_free (error);
771 }
772}
773
774void
775mate_panel_applet_setup_menu_from_file (MatePanelApplet *applet,
776 const gchar *filename,
777 GtkActionGroup *applet_action_group)
778{
779 gchar *xml = NULL((void*)0);
780 GError *error = NULL((void*)0);
781
782 if (g_file_get_contents (filename, &xml, NULL((void*)0), &error)) {
783 mate_panel_applet_setup_menu (applet, xml, applet_action_group);
784 } else {
785 g_warning ("%s", error->message);
786 g_error_free (error);
787 }
788
789 g_free (xml);
790}
791
792/**
793 * mate_panel_applet_setup_menu_from_resource:
794 * @applet: a #MatePanelApplet.
795 * @resource_path: a resource path
796 * @action_group: a #GtkActionGroup.
797 *
798 * Sets up the context menu of @applet. @filename is a resource path to a menu
799 * XML file, containing a #GtkUIManager UI definition that describes how to
800 * display the menu items. @action_group contains the various #GtkAction that
801 * are referenced in @xml.
802 *
803 * See also the <link linkend="getting-started.context-menu">Context
804 * Menu</link> section.
805 *
806 * Since: 1.20.1
807 **/
808void
809mate_panel_applet_setup_menu_from_resource (MatePanelApplet *applet,
810 const gchar *resource_path,
811 GtkActionGroup *action_group)
812{
813 GBytes *bytes;
814 GError *error = NULL((void*)0);
815
816 bytes = g_resources_lookup_data (resource_path,
817 G_RESOURCE_LOOKUP_FLAGS_NONE,
818 &error);
819
820 if (bytes) {
821 mate_panel_applet_setup_menu (applet,
822 g_bytes_get_data (bytes, NULL((void*)0)),
823 action_group);
824 } else {
825 g_warning ("%s", error->message);
826 g_error_free (error);
827 }
828
829 g_bytes_unref (bytes);
830}
831
832static void
833mate_panel_applet_finalize (GObject *object)
834{
835 MatePanelApplet *applet;
836 MatePanelAppletPrivate *priv;
837
838 applet = MATE_PANEL_APPLET (object);
839 priv = mate_panel_applet_get_instance_private (applet);
840
841 if (priv->connection) {
842 if (priv->object_id)
843 g_dbus_connection_unregister_object (priv->connection,
844 priv->object_id);
845 priv->object_id = 0;
846 g_clear_object (&priv->connection)do { _Static_assert (sizeof *((&priv->connection)) == sizeof
(gpointer), "Expression evaluates to false"); __typeof__ (((
&priv->connection))) _pp = ((&priv->connection)
); __typeof__ (*((&priv->connection))) _ptr = *_pp; *_pp
= ((void*)0); if (_ptr) (g_object_unref) (_ptr); } while (0)
;
847 }
848
849 g_clear_pointer (&priv->object_path, g_free)do { _Static_assert (sizeof *(&priv->object_path) == sizeof
(gpointer), "Expression evaluates to false"); __typeof__ ((&
priv->object_path)) _pp = (&priv->object_path); __typeof__
(*(&priv->object_path)) _ptr = *_pp; *_pp = ((void*)0
); if (_ptr) (g_free) (_ptr); } while (0)
;
850
851 mate_panel_applet_set_preferences_path (applet, NULL((void*)0));
852
853 g_clear_object (&priv->applet_action_group)do { _Static_assert (sizeof *((&priv->applet_action_group
)) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(((&priv->applet_action_group))) _pp = ((&priv->
applet_action_group)); __typeof__ (*((&priv->applet_action_group
))) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (g_object_unref
) (_ptr); } while (0)
;
854 g_clear_object (&priv->panel_action_group)do { _Static_assert (sizeof *((&priv->panel_action_group
)) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(((&priv->panel_action_group))) _pp = ((&priv->
panel_action_group)); __typeof__ (*((&priv->panel_action_group
))) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (g_object_unref
) (_ptr); } while (0)
;
855 g_clear_object (&priv->ui_manager)do { _Static_assert (sizeof *((&priv->ui_manager)) == sizeof
(gpointer), "Expression evaluates to false"); __typeof__ (((
&priv->ui_manager))) _pp = ((&priv->ui_manager)
); __typeof__ (*((&priv->ui_manager))) _ptr = *_pp; *_pp
= ((void*)0); if (_ptr) (g_object_unref) (_ptr); } while (0)
;
856
857 g_clear_pointer (&priv->size_hints, g_free)do { _Static_assert (sizeof *(&priv->size_hints) == sizeof
(gpointer), "Expression evaluates to false"); __typeof__ ((&
priv->size_hints)) _pp = (&priv->size_hints); __typeof__
(*(&priv->size_hints)) _ptr = *_pp; *_pp = ((void*)0)
; if (_ptr) (g_free) (_ptr); } while (0)
;
858 g_clear_pointer (&priv->prefs_path, g_free)do { _Static_assert (sizeof *(&priv->prefs_path) == sizeof
(gpointer), "Expression evaluates to false"); __typeof__ ((&
priv->prefs_path)) _pp = (&priv->prefs_path); __typeof__
(*(&priv->prefs_path)) _ptr = *_pp; *_pp = ((void*)0)
; if (_ptr) (g_free) (_ptr); } while (0)
;
859 g_clear_pointer (&priv->background, g_free)do { _Static_assert (sizeof *(&priv->background) == sizeof
(gpointer), "Expression evaluates to false"); __typeof__ ((&
priv->background)) _pp = (&priv->background); __typeof__
(*(&priv->background)) _ptr = *_pp; *_pp = ((void*)0)
; if (_ptr) (g_free) (_ptr); } while (0)
;
860 g_clear_pointer (&priv->id, g_free)do { _Static_assert (sizeof *(&priv->id) == sizeof (gpointer
), "Expression evaluates to false"); __typeof__ ((&priv->
id)) _pp = (&priv->id); __typeof__ (*(&priv->id
)) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (g_free) (_ptr);
} while (0)
;
861
862 /* closure is owned by the factory */
863 priv->closure = NULL((void*)0);
864
865 G_OBJECT_CLASS (mate_panel_applet_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((mate_panel_applet_parent_class)), (((GType) ((20) <<
(2))))))))
->finalize (object);
866}
867
868static gboolean
869container_has_focusable_child (GtkContainer *container)
870{
871 GList *list;
872 GList *t;
873 gboolean retval = FALSE(0);
874
875 list = gtk_container_get_children (container);
876
877 for (t = list; t; t = t->next) {
878 GtkWidget *child = GTK_WIDGET (t->data)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((t->data)), ((gtk_widget_get_type ()))))))
;
879 if (gtk_widget_get_can_focus (child)) {
880 retval = TRUE(!(0));
881 break;
882 } else if (GTK_IS_CONTAINER (child)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(child)); GType __t = ((gtk_container_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; }))))
) {
883 retval = container_has_focusable_child (GTK_CONTAINER (child)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((child)), ((gtk_container_get_type ()))))))
);
884 if (retval)
885 break;
886 }
887 }
888 g_list_free (list);
889 return retval;
890}
891
892static void
893mate_panel_applet_menu_popup (MatePanelApplet *applet,
894 GdkEvent *event)
895{
896 MatePanelAppletPrivate *priv;
897 GtkWidget *menu;
898
899 priv = mate_panel_applet_get_instance_private (applet);
900 menu = gtk_ui_manager_get_widget (priv->ui_manager,
901 "/MatePanelAppletPopup");
902
903/* Set up theme and transparency support */
904 GtkWidget *toplevel = gtk_widget_get_toplevel (menu);
905/* Fix any failures of compiz/other wm's to communicate with gtk for transparency */
906 GdkScreen *screen = gtk_widget_get_screen(GTK_WIDGET(toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
907 GdkVisual *visual = gdk_screen_get_rgba_visual(screen);
908 gtk_widget_set_visual(GTK_WIDGET(toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
, visual);
909/* Set menu and it's toplevel window to follow panel theme */
910 GtkStyleContext *context;
911 context = gtk_widget_get_style_context (GTK_WIDGET(toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
912 gtk_style_context_add_class(context,"gnome-panel-menu-bar");
913 gtk_style_context_add_class(context,"mate-panel-menu-bar");
914 GdkGravity widget_anchor = GDK_GRAVITY_NORTH_WEST;
915 GdkGravity menu_anchor = GDK_GRAVITY_NORTH_WEST;
916 switch (priv->orient) {
917 case MATE_PANEL_APPLET_ORIENT_UP:
918 menu_anchor = GDK_GRAVITY_SOUTH_WEST;
919 break;
920 case MATE_PANEL_APPLET_ORIENT_DOWN:
921 widget_anchor = GDK_GRAVITY_SOUTH_WEST;
922 break;
923 case MATE_PANEL_APPLET_ORIENT_LEFT:
924 menu_anchor = GDK_GRAVITY_NORTH_EAST;
925 break;
926 case MATE_PANEL_APPLET_ORIENT_RIGHT:
927 widget_anchor = GDK_GRAVITY_NORTH_EAST;
928 break;
929 }
930 gtk_menu_popup_at_widget (GTK_MENU (menu)((((GtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((menu)), ((gtk_menu_get_type ()))))))
,
931 GTK_WIDGET (applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
,
932 widget_anchor,
933 menu_anchor,
934 event);
935}
936
937static gboolean
938mate_panel_applet_can_focus (GtkWidget *widget)
939{
940 /*
941 * A MatePanelApplet widget can focus if it has a tooltip or it does
942 * not have any focusable children.
943 */
944 if (gtk_widget_get_has_tooltip (widget))
945 return TRUE(!(0));
946
947 if (!MATE_PANEL_IS_APPLET (widget))
948 return FALSE(0);
949
950 return !container_has_focusable_child (GTK_CONTAINER (widget)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_container_get_type ()))))))
);
951}
952
953/* Taken from libmatecomponentui/matecomponent/matecomponent-plug.c */
954static gboolean
955mate_panel_applet_button_event (MatePanelApplet *applet,
956 GdkEventButton *event)
957{
958#ifdef HAVE_X111
959 MatePanelAppletPrivate *priv;
960 GtkWidget *widget;
961 GdkWindow *window;
962 GdkWindow *socket_window;
963 XEvent xevent;
964 GdkDisplay *display;
965
966 priv = mate_panel_applet_get_instance_private (applet);
967
968 if (!priv->out_of_process)
969 return FALSE(0);
970
971 widget = priv->plug;
972
973 if (!gtk_widget_is_toplevel (widget))
974 return FALSE(0);
975
976 window = gtk_widget_get_window (widget);
977 socket_window = gtk_plug_get_socket_window (GTK_PLUG (widget)((((GtkPlug*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_plug_get_type ()))))))
);
978
979 display = gdk_display_get_default ();
980
981 if (!GDK_IS_X11_DISPLAY (display)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(display)); GType __t = ((gdk_x11_display_get_type())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
)
982 return FALSE(0);
983
984 if (event->type == GDK_BUTTON_PRESS) {
985 GdkSeat *seat;
986
987 xevent.xbutton.type = ButtonPress4;
988
989 seat = gdk_display_get_default_seat (display);
990
991 /* X does an automatic pointer grab on button press
992 * if we have both button press and release events
993 * selected.
994 * We don't want to hog the pointer on our parent.
995 */
996 gdk_seat_ungrab (seat);
997 } else {
998 xevent.xbutton.type = ButtonRelease5;
999 }
1000
1001 xevent.xbutton.display = GDK_WINDOW_XDISPLAY (window)((gdk_x11_display_get_xdisplay (gdk_window_get_display (window
))))
;
1002 xevent.xbutton.window = GDK_WINDOW_XID (socket_window)(gdk_x11_window_get_xid (socket_window));
1003 xevent.xbutton.root = GDK_WINDOW_XID (gdk_screen_get_root_window(gdk_x11_window_get_xid (gdk_screen_get_root_window (gdk_window_get_screen
(window))))
1004 (gdk_window_get_screen (window)))(gdk_x11_window_get_xid (gdk_screen_get_root_window (gdk_window_get_screen
(window))))
;
1005 /*
1006 * FIXME: the following might cause
1007 * big problems for non-GTK apps
1008 */
1009 xevent.xbutton.x = 0;
1010 xevent.xbutton.y = 0;
1011 xevent.xbutton.x_root = 0;
1012 xevent.xbutton.y_root = 0;
1013 xevent.xbutton.state = event->state;
1014 xevent.xbutton.button = event->button;
1015 xevent.xbutton.same_screen = TRUE(!(0)); /* FIXME ? */
1016
1017 gdk_x11_display_error_trap_push (display);
1018
1019 XSendEvent (GDK_WINDOW_XDISPLAY (window)((gdk_x11_display_get_xdisplay (gdk_window_get_display (window
))))
,
1020 GDK_WINDOW_XID (socket_window)(gdk_x11_window_get_xid (socket_window)),
1021 False0, NoEventMask0L, &xevent);
1022
1023 gdk_display_flush (display);
1024 gdk_x11_display_error_trap_pop_ignored (display);
1025
1026 return TRUE(!(0));
1027#else
1028 return FALSE(0);
1029#endif
1030}
1031
1032static gboolean
1033mate_panel_applet_button_press (GtkWidget *widget,
1034 GdkEventButton *event)
1035{
1036 MatePanelApplet *applet = MATE_PANEL_APPLET (widget);
1037
1038 if (!container_has_focusable_child (GTK_CONTAINER (applet)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_container_get_type ()))))))
)) {
1039 if (!gtk_widget_has_focus (widget)) {
1040 gtk_widget_set_can_focus (widget, TRUE(!(0)));
1041 gtk_widget_grab_focus (widget);
1042 }
1043 }
1044
1045#ifdef HAVE_WAYLAND1
1046 /*Limit the window list's applet menu to the handle area*/
1047 if (!(GDK_IS_X11_DISPLAY (gdk_display_get_default ())(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gdk_display_get_default ())); GType __t = ((gdk_x11_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
))
1048 {
1049 MatePanelAppletFlags flags;
1050 flags = mate_panel_applet_get_flags (applet);
1051 if (flags & MATE_PANEL_APPLET_EXPAND_MAJOR)
1052 return FALSE(0);
1053 }
1054#endif
1055
1056 if (event->button == 3) {
1057 mate_panel_applet_menu_popup (applet, (GdkEvent *) event);
1058
1059 return TRUE(!(0));
1060 }
1061 return mate_panel_applet_button_event (applet, event);
1062}
1063
1064static gboolean
1065mate_panel_applet_button_release (GtkWidget *widget,
1066 GdkEventButton *event)
1067{
1068 MatePanelApplet *applet = MATE_PANEL_APPLET (widget);
1069
1070 return mate_panel_applet_button_event (applet, event);
1071}
1072
1073/*Open the applet context menu only on Menu key
1074 *Do not open it on Return or some applets won't work
1075 */
1076static gboolean
1077mate_panel_applet_key_press_event (GtkWidget *widget,
1078 GdkEventKey *event)
1079{
1080 if (event->keyval == GDK_KEY_Menu0xff67) {
1081 mate_panel_applet_menu_popup (MATE_PANEL_APPLET (widget), (GdkEvent *) event);
1082 return TRUE(!(0));
1083 }
1084 else
1085 return FALSE(0);
1086}
1087
1088static void
1089mate_panel_applet_get_preferred_width (GtkWidget *widget,
1090 int *minimum_width,
1091 int *natural_width)
1092{
1093 GTK_WIDGET_CLASS (mate_panel_applet_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((mate_panel_applet_parent_class)), ((gtk_widget_get_type (
)))))))
->get_preferred_width (widget,
1094 minimum_width,
1095 natural_width);
1096
1097#if !GTK_CHECK_VERSION (3, 23, 0)((3) > (3) || ((3) == (3) && (24) > (23)) || ((
3) == (3) && (24) == (23) && (42) >= (0)))
1098 MatePanelAppletPrivate *priv;
1099
1100 priv = mate_panel_applet_get_instance_private (MATE_PANEL_APPLET (widget));
1101 if (priv->out_of_process) {
1102 /* Out-of-process applets end up scaled up doubly with GTK 3.22.
1103 * For these builds divide by the scale factor to ensure
1104 * they are back at their own intended size.
1105 */
1106 gint scale;
1107 scale = gtk_widget_get_scale_factor (widget);
1108 *minimum_width /= scale;
1109 *natural_width /= scale;
1110 }
1111#endif
1112}
1113
1114static void
1115mate_panel_applet_get_preferred_height (GtkWidget *widget,
1116 int *minimum_height,
1117 int *natural_height)
1118{
1119 GTK_WIDGET_CLASS (mate_panel_applet_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((mate_panel_applet_parent_class)), ((gtk_widget_get_type (
)))))))
->get_preferred_height (widget,
1120 minimum_height,
1121 natural_height);
1122
1123#if !GTK_CHECK_VERSION (3, 23, 0)((3) > (3) || ((3) == (3) && (24) > (23)) || ((
3) == (3) && (24) == (23) && (42) >= (0)))
1124 MatePanelAppletPrivate *priv;
1125
1126 priv = mate_panel_applet_get_instance_private (MATE_PANEL_APPLET (widget));
1127 if (priv->out_of_process) {
1128 gint scale;
1129 /* Out-of-process applets end up scaled up doubly with GTK 3.22.
1130 * For these builds divide by the scale factor to ensure
1131 * they are back at their own intended size.
1132 */
1133 scale = gtk_widget_get_scale_factor (widget);
1134 *minimum_height /= scale;
1135 *natural_height /= scale;
1136 }
1137#endif
1138}
1139
1140static GtkSizeRequestMode
1141mate_panel_applet_get_request_mode (GtkWidget *widget)
1142{
1143 /* Do not use GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH
1144 * or GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT
1145 * to avoid problems with in-process applets
1146 * when the panel is not expanded
1147 * See https://github.com/mate-desktop/mate-panel/issues/797
1148 * and https://github.com/mate-desktop/mate-panel/issues/799
1149 * Out of process applets already use GTK_SIZE_REQUEST_CONSTANT_SIZE
1150 */
1151 return GTK_SIZE_REQUEST_CONSTANT_SIZE;
1152}
1153
1154static void
1155mate_panel_applet_size_allocate (GtkWidget *widget,
1156 GtkAllocation *allocation)
1157{
1158 MatePanelAppletPrivate *priv;
1159 GtkAllocation child_allocation;
1160 MatePanelApplet *applet;
1161
1162 if (!mate_panel_applet_can_focus (widget)) {
1163 GTK_WIDGET_CLASS (mate_panel_applet_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((mate_panel_applet_parent_class)), ((gtk_widget_get_type (
)))))))
->size_allocate (widget, allocation);
1164 } else {
1165 int border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_container_get_type ()))))))
);
1166
1167 gtk_widget_set_allocation (widget, allocation);
1168 GtkBin *bin = GTK_BIN (widget)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_bin_get_type ()))))))
;
1169
1170 child_allocation.x = 0;
1171 child_allocation.y = 0;
1172
1173 child_allocation.width = MAX (allocation->width - border_width * 2, 0)(((allocation->width - border_width * 2) > (0)) ? (allocation
->width - border_width * 2) : (0))
;
1174 child_allocation.height = MAX (allocation->height - border_width * 2, 0)(((allocation->height - border_width * 2) > (0)) ? (allocation
->height - border_width * 2) : (0))
;
1175
1176 if (gtk_widget_get_realized (widget))
1177 gdk_window_move_resize (gtk_widget_get_window (widget),
1178 allocation->x + border_width,
1179 allocation->y + border_width,
1180 child_allocation.width,
1181 child_allocation.height);
1182
1183 GtkWidget *child = gtk_bin_get_child (bin);
1184 if (child)
1185 gtk_widget_size_allocate (child, &child_allocation);
1186 }
1187
1188 applet = MATE_PANEL_APPLET (widget);
1189 priv = mate_panel_applet_get_instance_private (applet);
1190
1191 if ((priv->previous_height != allocation->height) ||
1192 (priv->previous_width != allocation->width)) {
1193 priv->previous_height = allocation->height;
1194 priv->previous_width = allocation->width;
1195 mate_panel_applet_handle_background (applet);
1196 }
1197}
1198
1199static gboolean mate_panel_applet_draw(GtkWidget* widget, cairo_t* cr)
1200{
1201 GtkStyleContext *context;
1202 int border_width;
1203 gdouble x, y, width, height;
1204
1205 GTK_WIDGET_CLASS (mate_panel_applet_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((mate_panel_applet_parent_class)), ((gtk_widget_get_type (
)))))))
->draw(widget, cr);
1206
1207 if (!gtk_widget_has_focus (widget))
1208 return FALSE(0);
1209
1210 width = gtk_widget_get_allocated_width (widget);
1211 height = gtk_widget_get_allocated_height (widget);
1212
1213 border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_container_get_type ()))))))
);
1214
1215 x = 0;
1216 y = 0;
1217
1218 width -= 2 * border_width;
1219 height -= 2 * border_width;
1220
1221 context = gtk_widget_get_style_context (widget);
1222 gtk_style_context_save (context);
1223
1224 cairo_save (cr);
1225 gtk_render_focus (context, cr, x, y, width, height);
1226 cairo_restore (cr);
1227
1228 gtk_style_context_restore (context);
1229
1230 return FALSE(0);
1231}
1232
1233static gboolean
1234mate_panel_applet_focus (GtkWidget *widget,
1235 GtkDirectionType dir)
1236{
1237 MatePanelAppletPrivate *priv;
1238 gboolean ret;
1239 GtkWidget *previous_focus_child;
1240
1241 g_return_val_if_fail (MATE_PANEL_IS_APPLET (widget), FALSE)do { if ((MATE_PANEL_IS_APPLET (widget))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (widget)"
); return ((0)); } } while (0)
;
1242
1243 priv = mate_panel_applet_get_instance_private (MATE_PANEL_APPLET (widget));
1244 if (priv->moving_focus_out) {
1245 /*
1246 * Applet will retain focus if there is nothing else on the
1247 * panel to get focus
1248 */
1249 priv->moving_focus_out = FALSE(0);
1250 return FALSE(0);
1251 }
1252
1253 previous_focus_child = gtk_container_get_focus_child (GTK_CONTAINER (widget)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_container_get_type ()))))))
);
1254 if (!previous_focus_child && !gtk_widget_has_focus (widget)) {
1255 if (gtk_widget_get_has_tooltip (widget)) {
1256 gtk_widget_set_can_focus (widget, TRUE(!(0)));
1257 gtk_widget_grab_focus (widget);
1258 gtk_widget_set_can_focus (widget, FALSE(0));
1259 return TRUE(!(0));
1260 }
1261 }
1262 ret = GTK_WIDGET_CLASS (mate_panel_applet_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((mate_panel_applet_parent_class)), ((gtk_widget_get_type (
)))))))
->focus (widget, dir);
1263
1264 if (!ret && !previous_focus_child) {
1265 if (!gtk_widget_has_focus (widget)) {
1266 /*
1267 * Applet does not have a widget which can focus so set
1268 * the focus on the applet unless it already had focus
1269 * because it had a tooltip.
1270 */
1271 gtk_widget_set_can_focus (widget, TRUE(!(0)));
1272 gtk_widget_grab_focus (widget);
1273 gtk_widget_set_can_focus (widget, FALSE(0));
1274 ret = TRUE(!(0));
1275 }
1276 }
1277
1278 return ret;
1279}
1280
1281static gboolean
1282mate_panel_applet_parse_color (const gchar *color_str,
1283 GdkRGBA *color)
1284{
1285 g_assert (color_str && color)do { if (color_str && color) ; else g_assertion_message_expr
(((gchar*) 0), "mate-panel-applet.c", 1285, ((const char*) (
__func__)), "color_str && color"); } while (0)
;
1286
1287 return gdk_rgba_parse (color, color_str);
1288}
1289
1290#ifdef HAVE_X111
1291static gboolean
1292mate_panel_applet_parse_pixmap_str (const char *str,
1293 Window *xid,
1294 int *x,
1295 int *y)
1296{
1297 char **elements;
1298 char *tmp;
1299
1300 g_return_val_if_fail (str != NULL, FALSE)do { if ((str != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "str != NULL"); return
((0)); } } while (0)
;
1301 g_return_val_if_fail (xid != NULL, FALSE)do { if ((xid != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "xid != NULL"); return
((0)); } } while (0)
;
1302 g_return_val_if_fail (x != NULL, FALSE)do { if ((x != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "x != NULL"); return
((0)); } } while (0)
;
1303 g_return_val_if_fail (y != NULL, FALSE)do { if ((y != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "y != NULL"); return
((0)); } } while (0)
;
1304
1305 elements = g_strsplit (str, ",", -1);
1306
1307 if (!elements)
1308 return FALSE(0);
1309
1310 if (!elements [0] || !*elements [0] ||
1311 !elements [1] || !*elements [1] ||
1312 !elements [2] || !*elements [2])
1313 goto ERROR_AND_FREE;
1314
1315 *xid = strtol (elements [0], &tmp, 10);
1316 if (tmp == elements [0])
1317 goto ERROR_AND_FREE;
1318
1319 *x = strtol (elements [1], &tmp, 10);
1320 if (tmp == elements [1])
1321 goto ERROR_AND_FREE;
1322
1323 *y = strtol (elements [2], &tmp, 10);
1324 if (tmp == elements [2])
1325 goto ERROR_AND_FREE;
1326
1327 g_strfreev (elements);
1328 return TRUE(!(0));
1329
1330ERROR_AND_FREE:
1331 g_strfreev (elements);
1332 return FALSE(0);
1333}
1334
1335static cairo_surface_t *
1336mate_panel_applet_create_foreign_surface_for_display (GdkDisplay *display,
1337 GdkVisual *visual,
1338 Window xid)
1339{
1340 Statusint result = 0;
1341 Window window;
1342 gint x, y;
1343 guint width, height, border, depth;
1344
1345 gdk_x11_display_error_trap_push (display);
1346 result = XGetGeometry (GDK_DISPLAY_XDISPLAY (display)(gdk_x11_display_get_xdisplay (display)), xid, &window,
1347 &x, &y, &width, &height, &border, &depth);
1348 gdk_x11_display_error_trap_pop_ignored (display);
1349
1350 if (result == 0)
1351 return NULL((void*)0);
1352
1353 return cairo_xlib_surface_create (GDK_DISPLAY_XDISPLAY (display)(gdk_x11_display_get_xdisplay (display)),
1354 xid, gdk_x11_visual_get_xvisual (visual),
1355 width, height);
1356}
1357
1358static cairo_pattern_t *
1359mate_panel_applet_get_pattern_from_pixmap (MatePanelApplet *applet,
1360 Window xid,
1361 int x,
1362 int y)
1363{
1364 cairo_surface_t *background;
1365 cairo_surface_t *surface;
1366 GdkWindow *window;
1367 int width;
1368 int height;
1369 GdkDisplay *display;
1370 cairo_t *cr;
1371 cairo_pattern_t *pattern;
1372
1373 g_return_val_if_fail (MATE_PANEL_IS_APPLET (applet), NULL)do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return (((void*)0)); } } while (0)
;
1374
1375 if (!gtk_widget_get_realized (GTK_WIDGET (applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
))
1376 return NULL((void*)0);
1377
1378 window = gtk_widget_get_window (GTK_WIDGET (applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
);
1379 display = gdk_window_get_display (window);
1380
1381 background = mate_panel_applet_create_foreign_surface_for_display (display,
1382 gdk_window_get_visual (window),
1383 xid);
1384
1385 /* background can be NULL if the user changes the background very fast.
1386 * We'll get the next update, so it's not a big deal. */
1387 if (!background || cairo_surface_status (background) != CAIRO_STATUS_SUCCESS) {
1388 if (background)
1389 cairo_surface_destroy (background);
1390 return NULL((void*)0);
1391 }
1392
1393 width = gdk_window_get_width(window);
1394 height = gdk_window_get_height(window);
1395 surface = gdk_window_create_similar_surface (window,
1396 CAIRO_CONTENT_COLOR_ALPHA,
1397 width,
1398 height);
1399 gdk_x11_display_error_trap_push (display);
1400 cr = cairo_create (surface);
1401 cairo_set_source_surface (cr, background, -x, -y);
1402 cairo_rectangle (cr, 0, 0, width, height);
1403 cairo_fill (cr);
1404 gdk_x11_display_error_trap_pop_ignored (display);
1405
1406 cairo_surface_destroy (background);
1407 pattern = NULL((void*)0);
1408
1409 if (cairo_status (cr) == CAIRO_STATUS_SUCCESS) {
1410 pattern = cairo_pattern_create_for_surface (surface);
1411 }
1412
1413 cairo_destroy (cr);
1414 cairo_surface_destroy (surface);
1415
1416 return pattern;
1417}
1418#endif
1419
1420static MatePanelAppletBackgroundType
1421mate_panel_applet_handle_background_string (MatePanelApplet *applet,
1422 GdkRGBA *color,
1423 cairo_pattern_t **pattern)
1424{
1425 MatePanelAppletPrivate *priv;
1426 MatePanelAppletBackgroundType retval;
1427 char **elements;
1428
1429 priv = mate_panel_applet_get_instance_private (applet);
1430 retval = PANEL_NO_BACKGROUND;
1431
1432 if (!gtk_widget_get_realized (GTK_WIDGET (applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
) || !priv->background)
1433 return retval;
1434
1435 elements = g_strsplit (priv->background, ":", -1);
1436
1437 if (elements [0] && !strcmp (elements [0], "none" )) {
1438 retval = PANEL_NO_BACKGROUND;
1439
1440 } else if (elements [0] && !strcmp (elements [0], "color")) {
1441 g_return_val_if_fail (color != NULL, PANEL_NO_BACKGROUND)do { if ((color != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "color != NULL");
return (PANEL_NO_BACKGROUND); } } while (0)
;
1442
1443 if (!elements [1] || !mate_panel_applet_parse_color (elements [1], color)) {
1444
1445 g_warning ("Incomplete '%s' background type received", elements [0]);
1446 g_strfreev (elements);
1447 return PANEL_NO_BACKGROUND;
1448 }
1449
1450 retval = PANEL_COLOR_BACKGROUND;
1451
1452 } else if (elements [0] && !strcmp (elements [0], "pixmap")) {
1453#ifdef HAVE_X111
1454 if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gdk_display_get_default ())); GType __t = ((gdk_x11_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
) {
1455 Window pixmap_id;
1456 int x, y;
1457
1458 g_return_val_if_fail (pattern != NULL, PANEL_NO_BACKGROUND)do { if ((pattern != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "pattern != NULL"
); return (PANEL_NO_BACKGROUND); } } while (0)
;
1459
1460 if (!mate_panel_applet_parse_pixmap_str (elements [1], &pixmap_id, &x, &y)) {
1461 g_warning ("Incomplete '%s' background type received: %s",
1462 elements [0], elements [1]);
1463
1464 g_strfreev (elements);
1465 return PANEL_NO_BACKGROUND;
1466 }
1467
1468 *pattern = mate_panel_applet_get_pattern_from_pixmap (applet, pixmap_id, x, y);
1469 if (!*pattern) {
1470 g_warning ("Failed to get pattern %s", elements [1]);
1471 g_strfreev (elements);
1472 return PANEL_NO_BACKGROUND;
1473 }
1474
1475 retval = PANEL_PIXMAP_BACKGROUND;
1476 } else
1477#endif
1478 { /* not using X11 */
1479 g_warning("Received pixmap background type, which is only supported on X11");
1480 }
1481 } else
1482 g_warning ("Unknown background type received");
1483
1484 g_strfreev (elements);
1485
1486 return retval;
1487}
1488
1489MatePanelAppletBackgroundType
1490mate_panel_applet_get_background (MatePanelApplet *applet,
1491 GdkRGBA *color,
1492 cairo_pattern_t **pattern)
1493{
1494 g_return_val_if_fail (MATE_PANEL_IS_APPLET (applet), PANEL_NO_BACKGROUND)do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return (PANEL_NO_BACKGROUND); } } while (0)
;
1495
1496 /* initial sanity */
1497 if (pattern != NULL((void*)0))
1498 *pattern = NULL((void*)0);
1499
1500 if (color != NULL((void*)0))
1501 memset (color, 0, sizeof (GdkRGBA));
1502
1503 return mate_panel_applet_handle_background_string (applet, color, pattern);
1504}
1505
1506static void
1507mate_panel_applet_set_background_string (MatePanelApplet *applet,
1508 const gchar *background)
1509{
1510 MatePanelAppletPrivate *priv;
1511
1512 priv = mate_panel_applet_get_instance_private (applet);
1513
1514 if (priv->background == background)
1515 return;
1516
1517 if (g_strcmp0 (priv->background, background) == 0)
1518 return;
1519
1520 g_free (priv->background);
1521 priv->background = background ? g_strdup (background)g_strdup_inline (background) : NULL((void*)0);
1522 mate_panel_applet_handle_background (applet);
1523
1524 g_object_notify (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
, "background");
1525}
1526
1527static void
1528mate_panel_applet_handle_background (MatePanelApplet *applet)
1529{
1530 MatePanelAppletBackgroundType type;
1531
1532 GdkRGBA color;
1533 cairo_pattern_t *pattern;
1534
1535 type = mate_panel_applet_get_background (applet, &color, &pattern);
1536
1537 if (!gdk_screen_is_composited (gdk_screen_get_default ())) {
1538 color.alpha = 1.;
1539 }
1540
1541 switch (type) {
1542 case PANEL_NO_BACKGROUND:
1543 g_signal_emit (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
,
1544 mate_panel_applet_signals [CHANGE_BACKGROUND],
1545 0, PANEL_NO_BACKGROUND, NULL((void*)0), NULL((void*)0));
1546 break;
1547 case PANEL_COLOR_BACKGROUND:
1548 g_signal_emit (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
,
1549 mate_panel_applet_signals [CHANGE_BACKGROUND],
1550 0, PANEL_COLOR_BACKGROUND, &color, NULL((void*)0));
1551 break;
1552 case PANEL_PIXMAP_BACKGROUND:
1553 g_signal_emit (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
,
1554 mate_panel_applet_signals [CHANGE_BACKGROUND],
1555
1556 0, PANEL_PIXMAP_BACKGROUND, NULL((void*)0), pattern);
1557
1558 cairo_pattern_destroy (pattern);
1559
1560 break;
1561 default:
1562 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "mate-panel-applet.c"
, 1562, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1563 break;
1564 }
1565}
1566
1567static void
1568mate_panel_applet_realize (GtkWidget *widget)
1569{
1570 MatePanelApplet *applet;
1571 MatePanelAppletPrivate *priv;
1572
1573 GTK_WIDGET_CLASS (mate_panel_applet_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((mate_panel_applet_parent_class)), ((gtk_widget_get_type (
)))))))
->realize (widget);
1574
1575 applet = MATE_PANEL_APPLET (widget);
1576 priv = mate_panel_applet_get_instance_private (applet);
1577 if (priv->background)
1578 mate_panel_applet_handle_background (applet);
1579}
1580
1581static void
1582mate_panel_applet_move_focus_out_of_applet (MatePanelApplet *applet,
1583 GtkDirectionType dir)
1584{
1585 MatePanelAppletPrivate *priv;
1586 GtkWidget *toplevel;
1587
1588 priv = mate_panel_applet_get_instance_private (applet);
1589 priv->moving_focus_out = TRUE(!(0));
1590 toplevel = gtk_widget_get_toplevel (GTK_WIDGET (applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
);
1591 g_return_if_fail (toplevel)do { if ((toplevel)) { } else { g_return_if_fail_warning (((gchar
*) 0), ((const char*) (__func__)), "toplevel"); return; } } while
(0)
;
1592
1593 gtk_widget_child_focus (toplevel, dir);
1594 priv->moving_focus_out = FALSE(0);
1595}
1596
1597static void
1598mate_panel_applet_change_background(MatePanelApplet *applet,
1599 MatePanelAppletBackgroundType type,
1600 GdkRGBA* color,
1601 cairo_pattern_t *pattern)
1602{
1603 MatePanelAppletPrivate *priv;
1604 GdkWindow *window;
1605
1606 priv = mate_panel_applet_get_instance_private (applet);
1607
1608 if (priv->out_of_process)
1609 window = gtk_widget_get_window (GTK_WIDGET (priv->plug)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->plug)), ((gtk_widget_get_type ()))))))
);
1610 else
1611 window = gtk_widget_get_window (GTK_WIDGET (applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
);
1612
1613 gtk_widget_set_app_paintable (GTK_WIDGET (applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
,TRUE(!(0)));
1614
1615 if (priv->out_of_process)
1616 _mate_panel_applet_apply_css (GTK_WIDGET (priv->plug)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->plug)), ((gtk_widget_get_type ()))))))
,type);
1617
1618 switch (type) {
1619 case PANEL_NO_BACKGROUND:
1620 if (priv->out_of_process){
1621 cairo_pattern_t *transparent = cairo_pattern_create_rgba (0, 0, 0, 0); /* Using NULL here breaks transparent */
1622 gdk_window_set_background_pattern (window, transparent); /* backgrounds set by GTK theme */
1623 cairo_pattern_destroy (transparent);
1624 }
1625 break;
1626 case PANEL_COLOR_BACKGROUND:
1627 if (priv->out_of_process){
1628 gdk_window_set_background_rgba(window,color);
1629 gtk_widget_queue_draw (priv->plug); /*change the bg right away always */
1630 }
1631 break;
1632 case PANEL_PIXMAP_BACKGROUND:
1633 if (priv->out_of_process){
1634 gdk_window_set_background_pattern(window,pattern);
1635 gtk_widget_queue_draw (priv->plug); /*change the bg right away always */
1636 }
1637 break;
1638 default:
1639 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "mate-panel-applet.c"
, 1639, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1640 break;
1641 }
1642
1643 if (priv->out_of_process){
1644 GtkStyleContext *context;
1645
1646 context = gtk_widget_get_style_context (GTK_WIDGET (priv->plug)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->plug)), ((gtk_widget_get_type ()))))))
);
1647
1648 if (priv->orient == MATE_PANEL_APPLET_ORIENT_UP ||
1649 priv->orient == MATE_PANEL_APPLET_ORIENT_DOWN)
1650 gtk_style_context_add_class (context, "horizontal");
1651 else
1652 gtk_style_context_add_class (context, "vertical");
1653 }
1654}
1655
1656static void
1657mate_panel_applet_get_property (GObject *object,
1658 guint prop_id,
1659 GValue *value,
1660 GParamSpec *pspec)
1661{
1662 MatePanelApplet *applet;
1663 MatePanelAppletPrivate *priv;
1664
1665 applet = MATE_PANEL_APPLET (object);
1666 priv = mate_panel_applet_get_instance_private (applet);
1667
1668 switch (prop_id) {
1669 case PROP_OUT_OF_PROCESS:
1670 g_value_set_boolean (value, priv->out_of_process);
1671 break;
1672 case PROP_ID:
1673 g_value_set_string (value, priv->id);
1674 break;
1675 case PROP_CLOSURE:
1676 g_value_set_pointer (value, priv->closure);
1677 break;
1678 case PROP_CONNECTION:
1679 g_value_set_object (value, priv->connection);
1680 break;
1681 case PROP_PREFS_PATH:
1682 g_value_set_string (value, priv->prefs_path);
1683 break;
1684 case PROP_ORIENT:
1685 g_value_set_uint (value, priv->orient);
1686 break;
1687 case PROP_SIZE:
1688 g_value_set_uint (value, priv->size);
1689 break;
1690 case PROP_BACKGROUND:
1691 g_value_set_string (value, priv->background);
1692 break;
1693 case PROP_FLAGS:
1694 g_value_set_uint (value, priv->flags);
1695 break;
1696 case PROP_SIZE_HINTS: {
1697 GVariant **children;
1698 GVariant *variant;
1699 gint i;
1700
1701 children = g_new (GVariant *, priv->size_hints_len)((GVariant * *) g_malloc_n ((priv->size_hints_len), sizeof
(GVariant *)))
;
1702 for (i = 0; i < priv->size_hints_len; i++)
1703 children[i] = g_variant_new_int32 (priv->size_hints[i]);
1704 variant = g_variant_new_array (G_VARIANT_TYPE_INT32((const GVariantType *) "i"),
Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption
1705 children, priv->size_hints_len);
1706 g_free (children);
1707 g_value_set_pointer (value, variant);
1708 break;
1709 }
1710 case PROP_LOCKED:
1711 g_value_set_boolean (value, priv->locked);
1712 break;
1713 case PROP_LOCKED_DOWN:
1714 g_value_set_boolean (value, priv->locked_down);
1715 break;
1716 default:
1717 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "mate-panel-applet.c", 1717, ("property"), _glib__property_id
, _glib__pspec->name, g_type_name ((((((GTypeClass*) (((GTypeInstance
*) (_glib__pspec))->g_class))->g_type)))), (g_type_name
((((((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
1718 }
1719}
1720
1721static void
1722mate_panel_applet_set_property (GObject *object,
1723 guint prop_id,
1724 const GValue *value,
1725 GParamSpec *pspec)
1726{
1727 MatePanelApplet *applet;
1728 MatePanelAppletPrivate *priv;
1729
1730 applet = MATE_PANEL_APPLET (object);
1731 priv = mate_panel_applet_get_instance_private (applet);
1732
1733 switch (prop_id) {
1734 case PROP_OUT_OF_PROCESS:
1735 priv->out_of_process = g_value_get_boolean (value);
1736 break;
1737 case PROP_ID:
1738 priv->id = g_value_dup_string (value);
1739 break;
1740 case PROP_CLOSURE:
1741 priv->closure = g_value_get_pointer (value);
1742 g_closure_set_marshal (priv->closure,
1743 mate_panel_applet_marshal_BOOLEAN__STRING);
1744 break;
1745 case PROP_CONNECTION:
1746 priv->connection = g_value_dup_object (value);
1747 break;
1748 case PROP_PREFS_PATH:
1749 mate_panel_applet_set_preferences_path (applet, g_value_get_string (value));
1750 break;
1751 case PROP_ORIENT:
1752 mate_panel_applet_set_orient (applet, g_value_get_uint (value));
1753 break;
1754 case PROP_SIZE:
1755 mate_panel_applet_set_size (applet, g_value_get_uint (value));
1756 break;
1757 case PROP_BACKGROUND:
1758 mate_panel_applet_set_background_string (applet, g_value_get_string (value));
1759 break;
1760 case PROP_FLAGS:
1761 mate_panel_applet_set_flags (applet, g_value_get_uint (value));
1762 break;
1763 case PROP_SIZE_HINTS: {
1764 const int *size_hints;
1765 gsize n_elements;
1766
1767 size_hints = g_variant_get_fixed_array (g_value_get_pointer (value),
1768 &n_elements, sizeof (gint32));
1769 mate_panel_applet_set_size_hints (applet, size_hints, n_elements, 0);
1770 }
1771 break;
1772 case PROP_LOCKED:
1773 mate_panel_applet_set_locked (applet, g_value_get_boolean (value));
1774 break;
1775 case PROP_LOCKED_DOWN:
1776 mate_panel_applet_set_locked_down (applet, g_value_get_boolean (value));
1777 break;
1778 default:
1779 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "mate-panel-applet.c", 1779, ("property"), _glib__property_id
, _glib__pspec->name, g_type_name ((((((GTypeClass*) (((GTypeInstance
*) (_glib__pspec))->g_class))->g_type)))), (g_type_name
((((((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
1780 }
1781}
1782
1783static void
1784add_tab_bindings (GtkBindingSet *binding_set,
1785 GdkModifierType modifiers,
1786 GtkDirectionType direction)
1787{
1788 gtk_binding_entry_add_signal (binding_set, GDK_KEY_Tab0xff09, modifiers,
1789 "move_focus_out_of_applet", 1,
1790 GTK_TYPE_DIRECTION_TYPE(gtk_direction_type_get_type ()), direction);
1791 gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Tab0xff89, modifiers,
1792 "move_focus_out_of_applet", 1,
1793 GTK_TYPE_DIRECTION_TYPE(gtk_direction_type_get_type ()), direction);
1794}
1795
1796static void
1797mate_panel_applet_setup (MatePanelApplet *applet)
1798{
1799 MatePanelAppletPrivate *priv;
1800 GValue value = {0, };
1801 GArray *params;
1802 guint i;
1803 gboolean ret;
1804
1805 priv = mate_panel_applet_get_instance_private (applet);
1806
1807 g_assert ((priv->id != NULL) && (priv->closure != NULL))do { if ((priv->id != ((void*)0)) && (priv->closure
!= ((void*)0))) ; else g_assertion_message_expr (((gchar*) 0
), "mate-panel-applet.c", 1807, ((const char*) (__func__)), "(priv->id != NULL) && (priv->closure != NULL)"
); } while (0)
;
1808
1809 params = g_array_sized_new (FALSE(0), TRUE(!(0)), sizeof (GValue), 2);
1810 value.g_type = 0;
1811 g_value_init (&value, G_TYPE_OBJECT((GType) ((20) << (2))));
1812 g_value_set_object (&value, G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
);
1813 g_array_append_val (params, value)g_array_append_vals (params, &(value), 1);
1814
1815 value.g_type = 0;
1816 g_value_init (&value, G_TYPE_STRING((GType) ((16) << (2))));
1817 g_value_set_string (&value, priv->id);
1818 g_array_append_val (params, value)g_array_append_vals (params, &(value), 1);
1819
1820 value.g_type = 0;
1821 g_value_init (&value, G_TYPE_BOOLEAN((GType) ((5) << (2))));
1822
1823 g_closure_invoke (priv->closure,
1824 &value, params->len,
1825 (GValue *) params->data,
1826 NULL((void*)0));
1827
1828 for (i = 0; i < params->len; i++)
1829 g_value_unset (&g_array_index (params, GValue, i)(((GValue*) (void *) (params)->data) [(i)]));
1830 g_array_free (params, TRUE(!(0)));
1831
1832 ret = g_value_get_boolean (&value);
1833 g_value_unset (&value);
1834
1835 if (!ret) { /* FIXME */
1836 g_warning ("need to free the control here");
1837
1838 return;
1839 }
1840}
1841
1842void _mate_panel_applet_apply_css(GtkWidget* widget, MatePanelAppletBackgroundType type)
1843{
1844 GtkStyleContext* context;
1845
1846 context = gtk_widget_get_style_context (widget);
1847
1848 switch (type) {
1849 case PANEL_NO_BACKGROUND:
1850 gtk_style_context_remove_class (context, "mate-custom-panel-background");
1851 break;
1852 case PANEL_COLOR_BACKGROUND:
1853 case PANEL_PIXMAP_BACKGROUND:
1854 gtk_style_context_add_class (context, "mate-custom-panel-background");
1855 break;
1856 default:
1857 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "mate-panel-applet.c"
, 1857, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1858 break;
1859 }
1860}
1861
1862#ifdef HAVE_X111
1863static void _mate_panel_applet_prepare_css (GtkStyleContext *context)
1864{
1865 GtkCssProvider *provider;
1866
1867 g_return_if_fail (GDK_IS_X11_DISPLAY (gdk_display_get_default ()))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((gdk_display_get_default ())); GType __t = ((gdk_x11_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0
), ((const char*) (__func__)), "GDK_IS_X11_DISPLAY (gdk_display_get_default ())"
); return; } } while (0)
;
1868 provider = gtk_css_provider_new ();
1869 gtk_css_provider_load_from_data (provider,
1870 "#PanelPlug {\n"
1871 " background-repeat: no-repeat;\n" /*disable in gtk theme features */
1872 " background-size: cover; " /*that don't work on panel-toplevel */
1873 " }\n"
1874 ".mate-custom-panel-background{\n" /*prepare CSS for user set theme */
1875 " background-color: rgba (0, 0, 0, 0);\n"
1876 " background-image: none;\n"
1877 "}",
1878 -1, NULL((void*)0));
1879
1880 gtk_style_context_add_provider (context,
1881 GTK_STYLE_PROVIDER (provider)((((GtkStyleProvider*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((provider)), ((gtk_style_provider_get_type (
)))))))
,
1882 GTK_STYLE_PROVIDER_PRIORITY_APPLICATION600);
1883 g_object_unref (provider);
1884}
1885#endif /* HAVE_X11 */
1886
1887static void
1888mate_panel_applet_init (MatePanelApplet *applet)
1889{
1890 MatePanelAppletPrivate *priv;
1891
1892 priv = mate_panel_applet_get_instance_private (applet);
1893
1894 priv->flags = MATE_PANEL_APPLET_FLAGS_NONE;
1895 priv->orient = MATE_PANEL_APPLET_ORIENT_UP;
1896 priv->size = 24;
1897
1898 priv->panel_action_group = gtk_action_group_new ("PanelActions");
1899 gtk_action_group_set_translation_domain (priv->panel_action_group, GETTEXT_PACKAGE"mate-panel");
1900 gtk_action_group_add_actions (priv->panel_action_group,
1901 menu_entries,
1902 G_N_ELEMENTS (menu_entries)(sizeof (menu_entries) / sizeof ((menu_entries)[0])),
1903 applet);
1904 gtk_action_group_add_toggle_actions (priv->panel_action_group,
1905 menu_toggle_entries,
1906 G_N_ELEMENTS (menu_toggle_entries)(sizeof (menu_toggle_entries) / sizeof ((menu_toggle_entries)
[0]))
,
1907 applet);
1908
1909 priv->ui_manager = gtk_ui_manager_new ();
1910 gtk_ui_manager_insert_action_group (priv->ui_manager,
1911 priv->panel_action_group, 1);
1912 gtk_ui_manager_add_ui_from_string (priv->ui_manager,
1913 panel_menu_ui, -1, NULL((void*)0));
1914
1915 gtk_widget_set_events (GTK_WIDGET (applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
,
1916 GDK_BUTTON_PRESS_MASK |
1917 GDK_BUTTON_RELEASE_MASK);
1918}
1919
1920static GObject *
1921mate_panel_applet_constructor (GType type,
1922 guint n_construct_properties,
1923 GObjectConstructParam *construct_properties)
1924{
1925 GObject *object;
1926 MatePanelApplet *applet;
1927 MatePanelAppletPrivate *priv;
1928
1929 object = G_OBJECT_CLASS (mate_panel_applet_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((mate_panel_applet_parent_class)), (((GType) ((20) <<
(2))))))))
->constructor (type,
1930 n_construct_properties,
1931 construct_properties);
1932 applet = MATE_PANEL_APPLET (object);
1933 priv = mate_panel_applet_get_instance_private (applet);
1934
1935 if (!priv->out_of_process)
1936 return object;
1937
1938#ifdef HAVE_X111
1939 if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gdk_display_get_default ())); GType __t = ((gdk_x11_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
)
1940 {
1941 GtkStyleContext *context;
1942 GtkWidget *widget;
1943
1944 priv->plug = gtk_plug_new (0);
1945 widget = GTK_WIDGET (priv->plug)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->plug)), ((gtk_widget_get_type ()))))))
;
1946 gtk_widget_set_visual (widget,
1947 gdk_screen_get_rgba_visual (gtk_widget_get_screen (widget)));
1948 context = gtk_widget_get_style_context (widget);
1949 gtk_style_context_add_class (context, "gnome-panel-menu-bar");
1950 gtk_style_context_add_class (context, "mate-panel-menu-bar");
1951 gtk_widget_set_name (widget, "PanelPlug");
1952 _mate_panel_applet_prepare_css (context);
1953
1954 g_signal_connect_swapped (priv->plug, "embedded",g_signal_connect_data ((priv->plug), ("embedded"), (((GCallback
) (mate_panel_applet_setup))), (applet), ((void*)0), G_CONNECT_SWAPPED
)
1955 G_CALLBACK (mate_panel_applet_setup),g_signal_connect_data ((priv->plug), ("embedded"), (((GCallback
) (mate_panel_applet_setup))), (applet), ((void*)0), G_CONNECT_SWAPPED
)
1956 applet)g_signal_connect_data ((priv->plug), ("embedded"), (((GCallback
) (mate_panel_applet_setup))), (applet), ((void*)0), G_CONNECT_SWAPPED
)
;
1957
1958 gtk_container_add (GTK_CONTAINER (priv->plug)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->plug)), ((gtk_container_get_type ()))))))
, GTK_WIDGET (applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
);
1959 } else
1960#endif
1961 { /* not using X11 */
1962 g_warning ("Requested construction of an out-of-process applet, which is only possible on X11");
1963 }
1964
1965 return object;
1966}
1967
1968static void
1969mate_panel_applet_constructed (GObject* object)
1970{
1971 MatePanelApplet* applet = MATE_PANEL_APPLET(object);
1972
1973 /* Rename the class to have compatibility with all GTK2 themes
1974 * https://github.com/perberos/Mate-Desktop-Environment/issues/27
1975 */
1976 gtk_widget_set_name(GTK_WIDGET(applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
, "PanelApplet");
1977
1978 mate_panel_applet_register_object (applet);
1979}
1980
1981static void
1982mate_panel_applet_class_init (MatePanelAppletClass *klass)
1983{
1984 GObjectClass *gobject_class = (GObjectClass *) klass;
1985 GtkWidgetClass *widget_class = (GtkWidgetClass *) klass;
1986 GtkBindingSet *binding_set;
1987
1988 gobject_class->get_property = mate_panel_applet_get_property;
1989 gobject_class->set_property = mate_panel_applet_set_property;
1990 gobject_class->constructor = mate_panel_applet_constructor;
1991 gobject_class->constructed = mate_panel_applet_constructed;
1992 klass->move_focus_out_of_applet = mate_panel_applet_move_focus_out_of_applet;
1993 klass->change_background = mate_panel_applet_change_background;
1994 widget_class->button_press_event = mate_panel_applet_button_press;
1995 widget_class->button_release_event = mate_panel_applet_button_release;
1996 widget_class->get_request_mode = mate_panel_applet_get_request_mode;
1997 widget_class->get_preferred_width = mate_panel_applet_get_preferred_width;
1998 widget_class->get_preferred_height = mate_panel_applet_get_preferred_height;
1999 widget_class->draw = mate_panel_applet_draw;
2000 widget_class->size_allocate = mate_panel_applet_size_allocate;
2001 widget_class->focus = mate_panel_applet_focus;
2002 widget_class->realize = mate_panel_applet_realize;
2003 widget_class->key_press_event = mate_panel_applet_key_press_event;
2004
2005 gobject_class->finalize = mate_panel_applet_finalize;
2006
2007 g_object_class_install_property (gobject_class,
2008 PROP_OUT_OF_PROCESS,
2009 g_param_spec_boolean ("out-of-process",
2010 "out-of-process",
2011 "out-of-process",
2012 TRUE(!(0)),
2013 G_PARAM_CONSTRUCT_ONLY |
2014 G_PARAM_READWRITE));
2015 g_object_class_install_property (gobject_class,
2016 PROP_ID,
2017 g_param_spec_string ("id",
2018 "Id",
2019 "The Applet identifier",
2020 NULL((void*)0),
2021 G_PARAM_CONSTRUCT_ONLY |
2022 G_PARAM_READWRITE));
2023 g_object_class_install_property (gobject_class,
2024 PROP_CLOSURE,
2025 g_param_spec_pointer ("closure",
2026 "GClosure",
2027 "The Applet closure",
2028 G_PARAM_CONSTRUCT_ONLY |
2029 G_PARAM_READWRITE));
2030 g_object_class_install_property (gobject_class,
2031 PROP_CONNECTION,
2032 g_param_spec_object ("connection",
2033 "Connection",
2034 "The DBus Connection",
2035 G_TYPE_DBUS_CONNECTION(g_dbus_connection_get_type ()),
2036 G_PARAM_CONSTRUCT_ONLY |
2037 G_PARAM_READWRITE));
2038 g_object_class_install_property (gobject_class,
2039 PROP_PREFS_PATH,
2040 g_param_spec_string ("prefs-path",
2041 "PrefsPath",
2042 "GSettings Preferences Path",
2043 NULL((void*)0),
2044 G_PARAM_READWRITE));
2045 g_object_class_install_property (gobject_class,
2046 PROP_ORIENT,
2047 g_param_spec_uint ("orient",
2048 "Orient",
2049 "Panel Applet Orientation",
2050 MATE_PANEL_APPLET_ORIENT_FIRSTMATE_PANEL_APPLET_ORIENT_UP,
2051 MATE_PANEL_APPLET_ORIENT_LASTMATE_PANEL_APPLET_ORIENT_RIGHT,
2052 MATE_PANEL_APPLET_ORIENT_UP,
2053 G_PARAM_READWRITE));
2054 g_object_class_install_property (gobject_class,
2055 PROP_SIZE,
2056 g_param_spec_uint ("size",
2057 "Size",
2058 "Panel Applet Size",
2059 0, G_MAXUINT(2147483647 *2U +1U), 0,
2060 G_PARAM_READWRITE));
2061 g_object_class_install_property (gobject_class,
2062 PROP_BACKGROUND,
2063 g_param_spec_string ("background",
2064 "Background",
2065 "Panel Applet Background",
2066 NULL((void*)0),
2067 G_PARAM_READWRITE));
2068 g_object_class_install_property (gobject_class,
2069 PROP_FLAGS,
2070 g_param_spec_uint ("flags",
2071 "Flags",
2072 "Panel Applet flags",
2073 MATE_PANEL_APPLET_FLAGS_NONE,
2074 MATE_PANEL_APPLET_FLAGS_ALL(MATE_PANEL_APPLET_EXPAND_MAJOR|MATE_PANEL_APPLET_EXPAND_MINOR
|MATE_PANEL_APPLET_HAS_HANDLE)
,
2075 MATE_PANEL_APPLET_FLAGS_NONE,
2076 G_PARAM_READWRITE));
2077 g_object_class_install_property (gobject_class,
2078 PROP_SIZE_HINTS,
2079 /* FIXME: value_array? */
2080 g_param_spec_pointer ("size-hints",
2081 "SizeHints",
2082 "Panel Applet Size Hints",
2083 G_PARAM_READWRITE));
2084 g_object_class_install_property (gobject_class,
2085 PROP_LOCKED,
2086 g_param_spec_boolean ("locked",
2087 "Locked",
2088 "Whether Panel Applet is locked",
2089 FALSE(0),
2090 G_PARAM_READWRITE));
2091 g_object_class_install_property (gobject_class,
2092 PROP_LOCKED_DOWN,
2093 g_param_spec_boolean ("locked-down",
2094 "LockedDown",
2095 "Whether Panel Applet is locked down",
2096 FALSE(0),
2097 G_PARAM_READWRITE));
2098
2099 mate_panel_applet_signals [CHANGE_ORIENT] =
2100 g_signal_new ("change-orient",
2101 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2102 G_SIGNAL_RUN_LAST,
2103 G_STRUCT_OFFSET (MatePanelAppletClass, change_orient)((glong) __builtin_offsetof(MatePanelAppletClass, change_orient
))
,
2104 NULL((void*)0),
2105 NULL((void*)0),
2106 mate_panel_applet_marshal_VOID__UINTg_cclosure_marshal_VOID__UINT,
2107 G_TYPE_NONE((GType) ((1) << (2))),
2108 1,
2109 G_TYPE_UINT((GType) ((7) << (2))));
2110
2111 mate_panel_applet_signals [CHANGE_SIZE] =
2112 g_signal_new ("change-size",
2113 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2114 G_SIGNAL_RUN_LAST,
2115 G_STRUCT_OFFSET (MatePanelAppletClass, change_size)((glong) __builtin_offsetof(MatePanelAppletClass, change_size
))
,
2116 NULL((void*)0),
2117 NULL((void*)0),
2118 mate_panel_applet_marshal_VOID__INTg_cclosure_marshal_VOID__INT,
2119 G_TYPE_NONE((GType) ((1) << (2))),
2120 1,
2121 G_TYPE_INT((GType) ((6) << (2))));
2122
2123 mate_panel_applet_signals [CHANGE_BACKGROUND] =
2124 g_signal_new ("change-background",
2125 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2126 G_SIGNAL_RUN_LAST,
2127 G_STRUCT_OFFSET (MatePanelAppletClass, change_background)((glong) __builtin_offsetof(MatePanelAppletClass, change_background
))
,
2128 NULL((void*)0),
2129 NULL((void*)0),
2130 mate_panel_applet_marshal_VOID__ENUM_BOXED_OBJECT,
2131 G_TYPE_NONE((GType) ((1) << (2))),
2132 3,
2133 PANEL_TYPE_MATE_PANEL_APPLET_BACKGROUND_TYPEmate_panel_applet_background_type_get_type(),
2134 GDK_TYPE_RGBA(gdk_rgba_get_type ()),
2135 CAIRO_GOBJECT_TYPE_PATTERNcairo_gobject_pattern_get_type ());
2136
2137 mate_panel_applet_signals [MOVE_FOCUS_OUT_OF_APPLET] =
2138 g_signal_new ("move_focus_out_of_applet",
2139 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2140 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
2141 G_STRUCT_OFFSET (MatePanelAppletClass, move_focus_out_of_applet)((glong) __builtin_offsetof(MatePanelAppletClass, move_focus_out_of_applet
))
,
2142 NULL((void*)0),
2143 NULL((void*)0),
2144 mate_panel_applet_marshal_VOID__ENUMg_cclosure_marshal_VOID__ENUM,
2145 G_TYPE_NONE((GType) ((1) << (2))),
2146 1,
2147 GTK_TYPE_DIRECTION_TYPE(gtk_direction_type_get_type ()));
2148
2149 binding_set = gtk_binding_set_by_class (gobject_class);
2150 add_tab_bindings (binding_set, 0, GTK_DIR_TAB_FORWARD);
2151 add_tab_bindings (binding_set, GDK_SHIFT_MASK, GTK_DIR_TAB_BACKWARD);
2152 add_tab_bindings (binding_set, GDK_CONTROL_MASK, GTK_DIR_TAB_FORWARD);
2153 add_tab_bindings (binding_set, GDK_CONTROL_MASK | GDK_SHIFT_MASK, GTK_DIR_TAB_BACKWARD);
2154
2155 gtk_widget_class_set_css_name (widget_class, "PanelApplet");
2156}
2157
2158GtkWidget* mate_panel_applet_new(void)
2159{
2160 MatePanelApplet* applet = g_object_new(PANEL_TYPE_APPLETmate_panel_applet_get_type (), NULL((void*)0));
2161
2162 return GTK_WIDGET(applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
;
2163}
2164
2165static GdkEvent *
2166button_press_event_new (MatePanelApplet *applet,
2167 guint button,
2168 guint time)
2169{
2170 GdkDisplay *display;
2171 GdkSeat *seat;
2172 GdkDevice *device;
2173 GdkEvent *event;
2174
2175 display = gdk_display_get_default ();
2176 seat = gdk_display_get_default_seat (display);
2177 device = gdk_seat_get_pointer (seat);
2178
2179 event = gdk_event_new (GDK_BUTTON_PRESS);
2180
2181 event->button.time = time;
2182 event->button.button = button;
2183
2184 gdk_event_set_device (event, device);
2185
2186 return event;
2187}
2188
2189static void
2190method_call_cb (GDBusConnection *connection,
2191 const gchar *sender,
2192 const gchar *object_path,
2193 const gchar *interface_name,
2194 const gchar *method_name,
2195 GVariant *parameters,
2196 GDBusMethodInvocation *invocation,
2197 gpointer user_data)
2198{
2199 MatePanelApplet *applet = MATE_PANEL_APPLET (user_data);
2200
2201 if (g_strcmp0 (method_name, "PopupMenu") == 0) {
2202 guint button;
2203 guint time;
2204
2205 g_variant_get (parameters, "(uu)", &button, &time);
2206
2207 GdkEvent *event = button_press_event_new (applet, button, time);
2208 mate_panel_applet_menu_popup (applet, event);
2209 gdk_event_free (event);
2210
2211 g_dbus_method_invocation_return_value (invocation, NULL((void*)0));
2212 }
2213}
2214
2215static GVariant *
2216get_property_cb (GDBusConnection *connection,
2217 const gchar *sender,
2218 const gchar *object_path,
2219 const gchar *interface_name,
2220 const gchar *property_name,
2221 GError **error,
2222 gpointer user_data)
2223{
2224 MatePanelAppletPrivate *priv;
2225 GVariant *retval = NULL((void*)0);
2226
2227 priv = mate_panel_applet_get_instance_private (MATE_PANEL_APPLET (user_data));
2228
2229 if (g_strcmp0 (property_name, "PrefsPath") == 0) {
2230 retval = g_variant_new_string (priv->prefs_path ? priv->prefs_path : "");
2231 } else if (g_strcmp0 (property_name, "Orient") == 0) {
2232 retval = g_variant_new_uint32 (priv->orient);
2233 } else if (g_strcmp0 (property_name, "Size") == 0) {
2234 retval = g_variant_new_uint32 (priv->size);
2235 } else if (g_strcmp0 (property_name, "Background") == 0) {
2236 retval = g_variant_new_string (priv->background ? priv->background : "");
2237 } else if (g_strcmp0 (property_name, "Flags") == 0) {
2238 retval = g_variant_new_uint32 (priv->flags);
2239 } else if (g_strcmp0 (property_name, "SizeHints") == 0) {
2240 GVariant **children;
2241 gint i;
2242
2243 children = g_new (GVariant *, priv->size_hints_len)((GVariant * *) g_malloc_n ((priv->size_hints_len), sizeof
(GVariant *)))
;
2244 for (i = 0; i < priv->size_hints_len; i++)
2245 children[i] = g_variant_new_int32 (priv->size_hints[i]);
2246 retval = g_variant_new_array (G_VARIANT_TYPE_INT32((const GVariantType *) "i"),
2247 children, priv->size_hints_len);
2248 g_free (children);
2249 } else if (g_strcmp0 (property_name, "Locked") == 0) {
2250 retval = g_variant_new_boolean (priv->locked);
2251 } else if (g_strcmp0 (property_name, "LockedDown") == 0) {
2252 retval = g_variant_new_boolean (priv->locked_down);
2253 }
2254
2255 return retval;
2256}
2257
2258static gboolean
2259set_property_cb (GDBusConnection *connection,
2260 const gchar *sender,
2261 const gchar *object_path,
2262 const gchar *interface_name,
2263 const gchar *property_name,
2264 GVariant *value,
2265 GError **error,
2266 gpointer user_data)
2267{
2268 MatePanelApplet *applet = MATE_PANEL_APPLET (user_data);
2269
2270 if (g_strcmp0 (property_name, "PrefsPath") == 0) {
2271 mate_panel_applet_set_preferences_path (applet, g_variant_get_string (value, NULL((void*)0)));
2272 } else if (g_strcmp0 (property_name, "Orient") == 0) {
2273 mate_panel_applet_set_orient (applet, g_variant_get_uint32 (value));
2274 } else if (g_strcmp0 (property_name, "Size") == 0) {
2275 mate_panel_applet_set_size (applet, g_variant_get_uint32 (value));
2276 } else if (g_strcmp0 (property_name, "Background") == 0) {
2277 mate_panel_applet_set_background_string (applet, g_variant_get_string (value, NULL((void*)0)));
2278 } else if (g_strcmp0 (property_name, "Flags") == 0) {
2279 mate_panel_applet_set_flags (applet, g_variant_get_uint32 (value));
2280 } else if (g_strcmp0 (property_name, "SizeHints") == 0) {
2281 const int *size_hints;
2282 gsize n_elements;
2283
2284 size_hints = g_variant_get_fixed_array (value, &n_elements, sizeof (gint32));
2285 mate_panel_applet_set_size_hints (applet, size_hints, n_elements, 0);
2286 } else if (g_strcmp0 (property_name, "Locked") == 0) {
2287 mate_panel_applet_set_locked (applet, g_variant_get_boolean (value));
2288 } else if (g_strcmp0 (property_name, "LockedDown") == 0) {
2289 mate_panel_applet_set_locked_down (applet, g_variant_get_boolean (value));
2290 }
2291
2292 return TRUE(!(0));
2293}
2294
2295static const gchar introspection_xml[] =
2296 "<node>"
2297 "<interface name='org.mate.panel.applet.Applet'>"
2298 "<method name='PopupMenu'>"
2299 "<arg name='button' type='u' direction='in'/>"
2300 "<arg name='time' type='u' direction='in'/>"
2301 "</method>"
2302 "<property name='PrefsPath' type='s' access='readwrite'/>"
2303 "<property name='Orient' type='u' access='readwrite' />"
2304 "<property name='Size' type='u' access='readwrite'/>"
2305 "<property name='Background' type='s' access='readwrite'/>"
2306 "<property name='Flags' type='u' access='readwrite'/>"
2307 "<property name='SizeHints' type='ai' access='readwrite'/>"
2308 "<property name='Locked' type='b' access='readwrite'/>"
2309 "<property name='LockedDown' type='b' access='readwrite'/>"
2310 "<signal name='Move' />"
2311 "<signal name='RemoveFromPanel' />"
2312 "<signal name='Lock' />"
2313 "<signal name='Unlock' />"
2314 "</interface>"
2315 "</node>";
2316
2317static const GDBusInterfaceVTable interface_vtable = {
2318 method_call_cb,
2319 get_property_cb,
2320 set_property_cb,
2321 { 0 }
2322};
2323
2324static GDBusNodeInfo *introspection_data = NULL((void*)0);
2325
2326static void
2327mate_panel_applet_register_object (MatePanelApplet *applet)
2328{
2329 MatePanelAppletPrivate *priv;
2330 GError *error = NULL((void*)0);
2331 static gint id = 0;
2332
2333 if (!introspection_data)
2334 introspection_data = g_dbus_node_info_new_for_xml (introspection_xml, NULL((void*)0));
2335
2336 priv = mate_panel_applet_get_instance_private (applet);
2337 priv->object_path = g_strdup_printf (MATE_PANEL_APPLET_OBJECT_PATH"/org/mate/panel/applet/%s/%d", priv->id, id++);
2338 priv->object_id =
2339 g_dbus_connection_register_object (priv->connection,
2340 priv->object_path,
2341 introspection_data->interfaces[0],
2342 &interface_vtable,
2343 applet, NULL((void*)0),
2344 &error);
2345 if (!priv->object_id) {
2346 g_printerr ("Failed to register object %s: %s\n", priv->object_path, error->message);
2347 g_error_free (error);
2348 }
2349}
2350
2351static void mate_panel_applet_factory_main_finalized(gpointer data, GObject* object)
2352{
2353 gtk_main_quit();
2354
2355 if (introspection_data)
2356 {
2357 g_dbus_node_info_unref(introspection_data);
2358 introspection_data = NULL((void*)0);
2359 }
2360}
2361
2362#ifdef HAVE_X111
2363static int (*_x_error_func) (Display *, XErrorEvent *);
2364
2365static int
2366_x_error_handler (Display *display, XErrorEvent *error)
2367{
2368 if (!error->error_code)
2369 return 0;
2370
2371 /* If we got a BadDrawable or a BadWindow, we ignore it for now.
2372 * FIXME: We need to somehow distinguish real errors from
2373 * X-server-induced errors. Keeping a list of windows for which we
2374 * will ignore BadDrawables would be a good idea. */
2375 if (error->error_code == BadDrawable9 ||
2376 error->error_code == BadWindow3)
2377 return 0;
2378
2379 return _x_error_func (display, error);
2380}
2381
2382/*
2383 * To do graphical embedding in the X window system, MATE Panel
2384 * uses the classic foreign-window-reparenting trick. The
2385 * GtkPlug/GtkSocket widgets are used for this purpose. However,
2386 * serious robustness problems arise if the GtkSocket end of the
2387 * connection unexpectedly dies. The X server sends out DestroyNotify
2388 * events for the descendants of the GtkPlug (i.e., your embedded
2389 * component's windows) in effectively random order. Furthermore, if
2390 * you happened to be drawing on any of those windows when the
2391 * GtkSocket was destroyed (a common state of affairs), an X error
2392 * will kill your application.
2393 *
2394 * To solve this latter problem, MATE Panel sets up its own X error
2395 * handler which ignores certain X errors that might have been
2396 * caused by such a scenario. Other X errors get passed to gdk_x_error
2397 * normally.
2398 */
2399static void
2400_mate_panel_applet_setup_x_error_handler (void)
2401{
2402 static gboolean error_handler_setup = FALSE(0);
2403
2404 if (error_handler_setup)
2405 return;
2406
2407 error_handler_setup = TRUE(!(0));
2408
2409 _x_error_func = XSetErrorHandler (_x_error_handler);
2410}
2411#endif
2412
2413static int
2414_mate_panel_applet_factory_main_internal (const gchar *factory_id,
2415 gboolean out_process,
2416 GType applet_type,
2417 MatePanelAppletFactoryCallback callback,
2418 gpointer user_data)
2419{
2420 MatePanelAppletFactory* factory;
2421 GClosure* closure;
2422
2423 g_return_val_if_fail(factory_id != NULL, 1)do { if ((factory_id != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "factory_id != NULL"
); return (1); } } while (0)
;
2424 g_return_val_if_fail(callback != NULL, 1)do { if ((callback != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "callback != NULL"
); return (1); } } while (0)
;
2425 g_assert(g_type_is_a(applet_type, PANEL_TYPE_APPLET))do { if (((applet_type) == (mate_panel_applet_get_type ()) ||
(g_type_is_a) ((applet_type), (mate_panel_applet_get_type ()
)))) ; else g_assertion_message_expr (((gchar*) 0), "mate-panel-applet.c"
, 2425, ((const char*) (__func__)), "g_type_is_a(applet_type, PANEL_TYPE_APPLET)"
); } while (0)
;
2426
2427#ifdef HAVE_X111
2428 if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gdk_display_get_default ())); GType __t = ((gdk_x11_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
) {
2429 /*Use this both in and out of process as the tray applet always uses GtkSocket
2430 *to handle GtkStatusIcons whether the tray itself is built in or out of process
2431 */
2432 _mate_panel_applet_setup_x_error_handler();
2433 } else
2434#endif
2435 { /* not using X11 */
2436 if (out_process) {
2437 g_warning("Requested out-of-process applet, which is only supported on X11");
2438 return 1;
2439 }
2440 }
2441
2442 closure = g_cclosure_new(G_CALLBACK(callback)((GCallback) (callback)), user_data, NULL((void*)0));
2443 factory = mate_panel_applet_factory_new(factory_id, out_process, applet_type, closure);
2444 g_closure_unref(closure);
2445
2446 if (mate_panel_applet_factory_register_service(factory))
2447 {
2448 if (out_process)
2449 {
2450 g_object_weak_ref(G_OBJECT(factory)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((factory)), (((GType) ((20) << (2))))))))
, mate_panel_applet_factory_main_finalized, NULL((void*)0));
2451 gtk_main();
2452 }
2453
2454 return 0;
2455 }
2456
2457 g_object_unref (factory);
2458
2459 return 1;
2460}
2461
2462/**
2463 * mate_panel_applet_factory_main:
2464 * @out_process: boolean, dummy to support applets sending it
2465 * @factory_id: Factory ID.
2466 * @applet_type: GType of the applet this factory creates.
2467 * @callback: (scope call): Callback to be called when a new applet is to be created.
2468 * @data: (closure): Callback data.
2469 *
2470 * Returns: 0 on success, 1 if there is an error.
2471 */
2472int
2473mate_panel_applet_factory_main (const gchar *factory_id,
2474 gboolean out_process, /*Dummy to support applets w issues with this */
2475 GType applet_type,
2476 MatePanelAppletFactoryCallback callback,
2477 gpointer user_data)
2478{
2479 return _mate_panel_applet_factory_main_internal (factory_id, TRUE(!(0)), applet_type,
2480 callback, user_data);
2481}
2482
2483/**
2484 * mate_panel_applet_factory_setup_in_process: (skip)
2485 * @factory_id: Factory ID.
2486 * @applet_type: GType of the applet this factory creates.
2487 * @callback: (scope call): Callback to be called when a new applet is to be created.
2488 * @data: (closure): Callback data.
2489 *
2490 * Returns: 0 on success, 1 if there is an error.
2491 */
2492int
2493mate_panel_applet_factory_setup_in_process (const gchar *factory_id,
2494 GType applet_type,
2495 MatePanelAppletFactoryCallback callback,
2496 gpointer user_data)
2497{
2498 return _mate_panel_applet_factory_main_internal (factory_id, FALSE(0), applet_type,
2499 callback, user_data);
2500}
2501
2502/**
2503 * mate_panel_applet_set_background_widget:
2504 * @applet: a #PanelApplet.
2505 * @widget: a #GtkWidget.
2506 *
2507 * Configure #PanelApplet to automatically draw the background of the applet on
2508 * @widget. It is generally enough to call this function with @applet as
2509 * @widget.
2510 *
2511 * Deprecated: 3.20: Do not use this API. Since 3.20 this function does nothing.
2512 **/
2513
2514void
2515mate_panel_applet_set_background_widget (MatePanelApplet *applet,
2516 GtkWidget *widget)
2517{
2518}
2519
2520guint32
2521mate_panel_applet_get_xid (MatePanelApplet *applet,
2522 GdkScreen *screen)
2523{
2524 MatePanelAppletPrivate *priv;
2525
2526 priv = mate_panel_applet_get_instance_private (applet);
2527
2528 /* out_of_process should only be true on X11, so an extra runtime Wayland check is not needed */
2529 if (priv->out_of_process == FALSE(0))
2530 return 0;
2531
2532#ifdef HAVE_X111
2533 gtk_window_set_screen (GTK_WINDOW (priv->plug)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->plug)), ((gtk_window_get_type ()))))))
, screen);
2534 gtk_widget_show (priv->plug);
2535
2536 return gtk_plug_get_id (GTK_PLUG (priv->plug)((((GtkPlug*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->plug)), ((gtk_plug_get_type ()))))))
);
2537#else
2538 return 0;
2539#endif
2540}
2541
2542const gchar *
2543mate_panel_applet_get_object_path (MatePanelApplet *applet)
2544{
2545 MatePanelAppletPrivate *priv;
2546
2547 priv = mate_panel_applet_get_instance_private (applet);
2548
2549 return priv->object_path;
2550}
2551
2552G_MODULE_EXPORT__attribute__((visibility("default"))) GtkWidget *
2553mate_panel_applet_get_applet_widget (const gchar *factory_id,
2554 guint uid)
2555{
2556 GtkWidget *widget;
2557
2558 widget = mate_panel_applet_factory_get_applet_widget (factory_id, uid);
2559 if (!widget) {
2560 return NULL((void*)0);
2561 }
2562
2563 mate_panel_applet_setup (MATE_PANEL_APPLET (widget));
2564
2565 return widget;
2566}
diff --git a/2024-06-18-172109-13286-1@e182420b844f_master/report-a82458.html b/2024-06-18-172109-13286-1@e182420b844f_master/report-a82458.html new file mode 100644 index 00000000..5865c201 --- /dev/null +++ b/2024-06-18-172109-13286-1@e182420b844f_master/report-a82458.html @@ -0,0 +1,967 @@ + + + +panel-launch.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:mate-panel/libpanel-util/panel-launch.c
Warning:line 285, column 9
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name panel-launch.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/mate-panel/libpanel-util -fcoverage-compilation-dir=/rootdir/mate-panel/libpanel-util -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I ../.. -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/startup-notification-1.0 -I /usr/include/mate-menus -I /usr/include/gio-unix-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/dconf -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/dconf -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I . -I . -I ../../mate-panel/libpanel-util -D DATADIR="/usr/local/share" -D PIC -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-18-172109-13286-1 -x c panel-launch.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * panel-launch.c: some helpers to launch desktop files
3 *
4 * Copyright (C) 2008 Novell, Inc.
5 * Copyright (C) 2012-2021 MATE Developers
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of the
10 * License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301, USA.
21 *
22 * Authors:
23 * Vincent Untz <vuntz@gnome.org>
24 */
25
26#include <glib/gi18n.h>
27#include <gio/gio.h>
28#include <gio/gdesktopappinfo.h>
29
30#include <gdk/gdk.h>
31#include <gtk/gtk.h>
32
33#include "panel-error.h"
34#include "panel-glib.h"
35
36#include "panel-launch.h"
37
38static void
39_panel_launch_error_dialog (const gchar *name,
40 GdkScreen *screen,
41 const gchar *message)
42{
43 char *primary;
44
45 if (name)
46 primary = g_markup_printf_escaped (_("Could not launch '%s'")gettext ("Could not launch '%s'"),
47 name);
48 else
49 primary = g_strdup (_("Could not launch application"))g_strdup_inline (gettext ("Could not launch application"));
50
51 panel_error_dialog (NULL((void*)0), screen, "cannot_launch", TRUE(!(0)),
52 primary, message);
53 g_free (primary);
54}
55
56static gboolean
57_panel_launch_handle_error (const gchar *name,
58 GdkScreen *screen,
59 GError *local_error,
60 GError **error)
61{
62 if (g_error_matches (local_error,
63 G_IO_ERRORg_io_error_quark(), G_IO_ERROR_CANCELLED)) {
64 g_error_free (local_error);
65 return TRUE(!(0));
66 }
67
68 else if (error != NULL((void*)0))
69 g_propagate_error (error, local_error);
70
71 else {
72 _panel_launch_error_dialog (name, screen, local_error->message);
73 g_error_free (local_error);
74 }
75
76 return FALSE(0);
77}
78
79static void
80dummy_child_watch (GPid pid,
81 gint status,
82 gpointer user_data)
83{
84 /* Nothing, this is just to ensure we don't double fork
85 * and break pkexec:
86 * https://bugzilla.gnome.org/show_bug.cgi?id=675789
87 */
88}
89
90static void
91gather_pid_callback (GDesktopAppInfo *gapp,
92 GPid pid,
93 gpointer data)
94{
95 g_child_watch_add (pid, dummy_child_watch, NULL((void*)0));
96}
97
98gboolean
99panel_app_info_launch_uris (GDesktopAppInfo *appinfo,
100 GList *uris,
101 GdkScreen *screen,
102 const gchar *action,
103 guint32 timestamp,
104 GError **error)
105{
106 GdkAppLaunchContext *context;
107 GError *local_error;
108 gboolean retval;
109
110 g_return_val_if_fail (G_IS_DESKTOP_APP_INFO (appinfo), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((appinfo)); GType __t = ((g_desktop_app_info_get_type ())
); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0
), ((const char*) (__func__)), "G_IS_DESKTOP_APP_INFO (appinfo)"
); return ((0)); } } while (0)
;
111 g_return_val_if_fail (GDK_IS_SCREEN (screen), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((screen)); GType __t = ((gdk_screen_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "GDK_IS_SCREEN (screen)"); return ((0)); } } while
(0)
;
112 g_return_val_if_fail (error == NULL || *error == NULL, FALSE)do { if ((error == ((void*)0) || *error == ((void*)0))) { } else
{ g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__
)), "error == NULL || *error == NULL"); return ((0)); } } while
(0)
;
113
114 GdkDisplay *display = gdk_display_get_default ();
115 context = gdk_display_get_app_launch_context (display);
116 gdk_app_launch_context_set_screen (context, screen);
117 gdk_app_launch_context_set_timestamp (context, timestamp);
118
119 local_error = NULL((void*)0);
120 if (action == NULL((void*)0)) {
121 retval = g_desktop_app_info_launch_uris_as_manager (appinfo, uris,
122 G_APP_LAUNCH_CONTEXT (context)((((GAppLaunchContext*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((context)), ((g_app_launch_context_get_type
()))))))
,
123 G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
124 NULL((void*)0), NULL((void*)0), gather_pid_callback, appinfo,
125 &local_error);
126 } else {
127 g_desktop_app_info_launch_action (appinfo, action, G_APP_LAUNCH_CONTEXT (context)((((GAppLaunchContext*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((context)), ((g_app_launch_context_get_type
()))))))
);
128 retval = TRUE(!(0));
129 }
130
131 g_object_unref (context);
132
133 if ((local_error == NULL((void*)0)) && (retval == TRUE(!(0))))
134 return TRUE(!(0));
135
136 return _panel_launch_handle_error (g_app_info_get_name (G_APP_INFO(appinfo)((((GAppInfo*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((appinfo)), ((g_app_info_get_type ()))))))
),
137 screen, local_error, error);
138}
139
140gboolean
141panel_app_info_launch_uri (GDesktopAppInfo *appinfo,
142 const gchar *uri,
143 GdkScreen *screen,
144 guint32 timestamp,
145 GError **error)
146{
147 GList *uris;
148 gboolean retval;
149
150 g_return_val_if_fail (G_IS_APP_INFO (appinfo), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((appinfo)); GType __t = ((g_app_info_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "G_IS_APP_INFO (appinfo)"); return ((0)); } } while
(0)
;
151 g_return_val_if_fail (GDK_IS_SCREEN (screen), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((screen)); GType __t = ((gdk_screen_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "GDK_IS_SCREEN (screen)"); return ((0)); } } while
(0)
;
152 g_return_val_if_fail (error == NULL || *error == NULL, FALSE)do { if ((error == ((void*)0) || *error == ((void*)0))) { } else
{ g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__
)), "error == NULL || *error == NULL"); return ((0)); } } while
(0)
;
153
154 uris = NULL((void*)0);
155 if (uri)
156 uris = g_list_prepend (uris, (gpointer) uri);
157
158 retval = panel_app_info_launch_uris (appinfo, uris,
159 screen, NULL((void*)0), timestamp, error);
160
161 g_list_free (uris);
162
163 return retval;
164}
165
166gboolean
167panel_launch_key_file (GKeyFile *keyfile,
168 GList *uri_list,
169 GdkScreen *screen,
170 const gchar *action,
171 GError **error)
172{
173 GDesktopAppInfo *appinfo;
174 gboolean retval;
175
176 g_return_val_if_fail (keyfile != NULL, FALSE)do { if ((keyfile != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "keyfile != NULL"
); return ((0)); } } while (0)
;
177 g_return_val_if_fail (GDK_IS_SCREEN (screen), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((screen)); GType __t = ((gdk_screen_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "GDK_IS_SCREEN (screen)"); return ((0)); } } while
(0)
;
178 g_return_val_if_fail (error == NULL || *error == NULL, FALSE)do { if ((error == ((void*)0) || *error == ((void*)0))) { } else
{ g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__
)), "error == NULL || *error == NULL"); return ((0)); } } while
(0)
;
179
180 appinfo = g_desktop_app_info_new_from_keyfile (keyfile);
181 if (appinfo == NULL((void*)0))
182 return FALSE(0);
183
184 retval = panel_app_info_launch_uris (appinfo,
185 uri_list, screen, action,
186 gtk_get_current_event_time (),
187 error);
188
189 g_object_unref (appinfo);
190 return retval;
191}
192
193gboolean
194panel_launch_desktop_file (const char *desktop_file,
195 GdkScreen *screen,
196 GError **error)
197{
198 GDesktopAppInfo *appinfo;
199 gboolean retval;
200
201 g_return_val_if_fail (desktop_file != NULL, FALSE)do { if ((desktop_file != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "desktop_file != NULL"
); return ((0)); } } while (0)
;
202 g_return_val_if_fail (GDK_IS_SCREEN (screen), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((screen)); GType __t = ((gdk_screen_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "GDK_IS_SCREEN (screen)"); return ((0)); } } while
(0)
;
203 g_return_val_if_fail (error == NULL || *error == NULL, FALSE)do { if ((error == ((void*)0) || *error == ((void*)0))) { } else
{ g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__
)), "error == NULL || *error == NULL"); return ((0)); } } while
(0)
;
204
205 appinfo = NULL((void*)0);
206
207 if (g_path_is_absolute (desktop_file))
208 appinfo = g_desktop_app_info_new_from_filename (desktop_file);
209 else {
210 char *full;
211
212 full = panel_g_lookup_in_applications_dirs (desktop_file);
213 if (full) {
214 appinfo = g_desktop_app_info_new_from_filename (full);
215 g_free (full);
216 }
217 }
218
219 if (appinfo == NULL((void*)0))
220 return FALSE(0);
221
222 retval = panel_app_info_launch_uris (appinfo, NULL((void*)0), screen, NULL((void*)0),
223 gtk_get_current_event_time (),
224 error);
225
226 g_object_unref (appinfo);
227
228 return retval;
229}
230
231/*
232 * Set the DISPLAY variable, to be use by g_spawn_async.
233 */
234static void
235set_environment (gpointer display)
236{
237 g_setenv ("DISPLAY", display, TRUE(!(0)));
238}
239
240gboolean
241panel_launch_desktop_file_with_fallback (const char *desktop_file,
242 const char *fallback_exec,
243 GdkScreen *screen,
244 GError **error)
245{
246 char *argv[2] = { (char *) fallback_exec, NULL((void*)0) };
247 GError *local_error;
248 gboolean retval;
249 GPid pid;
250 GdkDisplay *display;
251 char *display_name;
252
253 g_return_val_if_fail (desktop_file != NULL, FALSE)do { if ((desktop_file != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "desktop_file != NULL"
); return ((0)); } } while (0)
;
254 g_return_val_if_fail (fallback_exec != NULL, FALSE)do { if ((fallback_exec != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "fallback_exec != NULL"
); return ((0)); } } while (0)
;
255 g_return_val_if_fail (GDK_IS_SCREEN (screen), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((screen)); GType __t = ((gdk_screen_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "GDK_IS_SCREEN (screen)"); return ((0)); } } while
(0)
;
256 g_return_val_if_fail (error == NULL || *error == NULL, FALSE)do { if ((error == ((void*)0) || *error == ((void*)0))) { } else
{ g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__
)), "error == NULL || *error == NULL"); return ((0)); } } while
(0)
;
257
258 /* need to pass a non-NULL error to avoid getting a dialog */
259 local_error = NULL((void*)0);
260 if (panel_launch_desktop_file (desktop_file, screen, &local_error))
261 return TRUE(!(0));
262
263 if (local_error) {
264 g_error_free (local_error);
265 local_error = NULL((void*)0);
266 }
267
268 display = gdk_screen_get_display (screen);
269 display_name = g_strdup (gdk_display_get_name (display))g_strdup_inline (gdk_display_get_name (display));
270 retval = g_spawn_async (NULL((void*)0), /* working directory */
271 argv,
272 NULL((void*)0), /* envp */
273 G_SPAWN_SEARCH_PATH,
274 set_environment,
275 &display_name,
276 &pid,
277 &local_error);
278 g_free (display_name);
279
280 if (local_error == NULL((void*)0) && retval == TRUE(!(0))) {
281 g_child_watch_add (pid, dummy_child_watch, NULL((void*)0));
282 }
283 return TRUE(!(0));
284
285 return _panel_launch_handle_error (fallback_exec,
This statement is never executed
286 screen, local_error, error);
287}
diff --git a/2024-06-18-172109-13286-1@e182420b844f_master/report-b083bc.html b/2024-06-18-172109-13286-1@e182420b844f_master/report-b083bc.html new file mode 100644 index 00000000..30edd22f --- /dev/null +++ b/2024-06-18-172109-13286-1@e182420b844f_master/report-b083bc.html @@ -0,0 +1,3246 @@ + + + +mate-panel-applet.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:libmate-panel-applet/mate-panel-applet.c
Warning:line 1825, column 20
Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name mate-panel-applet.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/libmate-panel-applet -fcoverage-compilation-dir=/rootdir/libmate-panel-applet -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I .. -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/gio-unix-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I ../libmate-panel-applet -D MATELOCALEDIR="/usr/local/share/locale" -D PIC -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-18-172109-13286-1 -x c mate-panel-applet.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * mate-panel-applet.c: panel applet writing library.
3 *
4 * Copyright (c) 2010 Carlos Garcia Campos <carlosgc@gnome.org>
5 * Copyright (C) 2001 Sun Microsystems, Inc.
6 * Copyright (C) 2012-2021 MATE Developers
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
17 *
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the
20 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22 *
23 * Authors:
24 * Mark McLoughlin <mark@skynet.ie>
25 */
26
27#ifdef HAVE_CONFIG_H1
28#include <config.h>
29#endif
30
31#include <unistd.h>
32#include <stdlib.h>
33#include <string.h>
34
35#include <glib/gi18n-lib.h>
36#include <cairo.h>
37#include <gdk/gdk.h>
38#include <gdk/gdkkeysyms.h>
39#include <gtk/gtk.h>
40
41#ifdef HAVE_X111
42#include <cairo-xlib.h>
43#include <gdk/gdkx.h>
44#include <gtk/gtkx.h>
45#include <X11/Xatom.h>
46#include "panel-plug-private.h"
47#endif
48
49#include "mate-panel-applet.h"
50#include "panel-applet-private.h"
51#include "mate-panel-applet-factory.h"
52#include "mate-panel-applet-marshal.h"
53#include "mate-panel-applet-enums.h"
54
55typedef struct {
56 GtkWidget *plug;
57 GDBusConnection *connection;
58
59 gboolean out_of_process;
60
61 char *id;
62 GClosure *closure;
63 char *object_path;
64 guint object_id;
65 char *prefs_path;
66
67 GtkUIManager *ui_manager;
68 GtkActionGroup *applet_action_group;
69 GtkActionGroup *panel_action_group;
70
71 MatePanelAppletFlags flags;
72 MatePanelAppletOrient orient;
73 guint size;
74 char *background;
75
76 int previous_width;
77 int previous_height;
78
79 int *size_hints;
80 int size_hints_len;
81
82 gboolean moving_focus_out;
83
84 gboolean locked;
85 gboolean locked_down;
86} MatePanelAppletPrivate;
87
88enum {
89 CHANGE_ORIENT,
90 CHANGE_SIZE,
91 CHANGE_BACKGROUND,
92 MOVE_FOCUS_OUT_OF_APPLET,
93 LAST_SIGNAL
94};
95
96static guint mate_panel_applet_signals[LAST_SIGNAL] = { 0 };
97
98enum {
99 PROP_0,
100 PROP_OUT_OF_PROCESS,
101 PROP_ID,
102 PROP_CLOSURE,
103 PROP_CONNECTION,
104 PROP_PREFS_PATH,
105 PROP_ORIENT,
106 PROP_SIZE,
107 PROP_BACKGROUND,
108 PROP_FLAGS,
109 PROP_SIZE_HINTS,
110 PROP_LOCKED,
111 PROP_LOCKED_DOWN
112};
113
114static void mate_panel_applet_handle_background (MatePanelApplet *applet);
115static GtkAction *mate_panel_applet_menu_get_action (MatePanelApplet *applet,
116 const gchar *action);
117static void mate_panel_applet_menu_update_actions (MatePanelApplet *applet);
118static void mate_panel_applet_menu_cmd_remove (GtkAction *action,
119 MatePanelApplet *applet);
120static void mate_panel_applet_menu_cmd_move (GtkAction *action,
121 MatePanelApplet *applet);
122static void mate_panel_applet_menu_cmd_lock (GtkAction *action,
123 MatePanelApplet *applet);
124static void mate_panel_applet_register_object (MatePanelApplet *applet);
125void _mate_panel_applet_apply_css (GtkWidget* widget, MatePanelAppletBackgroundType type);
126
127static const gchar panel_menu_ui[] =
128 "<ui>\n"
129 " <popup name=\"MatePanelAppletPopup\" action=\"PopupAction\">\n"
130 " <placeholder name=\"AppletItems\"/>\n"
131 " <separator/>\n"
132 " <menuitem name=\"RemoveItem\" action=\"Remove\"/>\n"
133 " <menuitem name=\"MoveItem\" action=\"Move\"/>\n"
134 " <separator/>\n"
135 " <menuitem name=\"LockItem\" action=\"Lock\"/>\n"
136 " </popup>\n"
137 "</ui>\n";
138
139static const GtkActionEntry menu_entries[] = {
140 { "Remove", "list-remove", N_("_Remove From Panel")("_Remove From Panel"),
141 NULL((void*)0), NULL((void*)0),
142 G_CALLBACK (mate_panel_applet_menu_cmd_remove)((GCallback) (mate_panel_applet_menu_cmd_remove)) },
143 { "Move", NULL((void*)0), N_("_Move")("_Move"),
144 NULL((void*)0), NULL((void*)0),
145 G_CALLBACK (mate_panel_applet_menu_cmd_move)((GCallback) (mate_panel_applet_menu_cmd_move)) }
146};
147
148static const GtkToggleActionEntry menu_toggle_entries[] = {
149 { "Lock", NULL((void*)0), N_("Loc_k To Panel")("Loc_k To Panel"),
150 NULL((void*)0), NULL((void*)0),
151 G_CALLBACK (mate_panel_applet_menu_cmd_lock)((GCallback) (mate_panel_applet_menu_cmd_lock)),
152 FALSE(0) }
153};
154
155G_DEFINE_TYPE_WITH_PRIVATE (MatePanelApplet, mate_panel_applet, GTK_TYPE_EVENT_BOX)static void mate_panel_applet_init (MatePanelApplet *self); static
void mate_panel_applet_class_init (MatePanelAppletClass *klass
); static GType mate_panel_applet_get_type_once (void); static
gpointer mate_panel_applet_parent_class = ((void*)0); static
gint MatePanelApplet_private_offset; static void mate_panel_applet_class_intern_init
(gpointer klass) { mate_panel_applet_parent_class = g_type_class_peek_parent
(klass); if (MatePanelApplet_private_offset != 0) g_type_class_adjust_private_offset
(klass, &MatePanelApplet_private_offset); mate_panel_applet_class_init
((MatePanelAppletClass*) klass); } __attribute__ ((__unused__
)) static inline gpointer mate_panel_applet_get_instance_private
(MatePanelApplet *self) { return (((gpointer) ((guint8*) (self
) + (glong) (MatePanelApplet_private_offset)))); } GType mate_panel_applet_get_type
(void) { static GType static_g_define_type_id = 0; if ((__extension__
({ _Static_assert (sizeof *(&static_g_define_type_id) ==
sizeof (gpointer), "Expression evaluates to false"); (void) (
0 ? (gpointer) * (&static_g_define_type_id) : ((void*)0))
; (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter_pointer (
&static_g_define_type_id)); })) ) { GType g_define_type_id
= mate_panel_applet_get_type_once (); (__extension__ ({ _Static_assert
(sizeof *(&static_g_define_type_id) == sizeof (gpointer)
, "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id
) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer
((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id
)); })) ; } return static_g_define_type_id; } __attribute__ (
(__noinline__)) static GType mate_panel_applet_get_type_once (
void) { GType g_define_type_id = g_type_register_static_simple
((gtk_event_box_get_type ()), g_intern_static_string ("MatePanelApplet"
), sizeof (MatePanelAppletClass), (GClassInitFunc)(void (*)(void
)) mate_panel_applet_class_intern_init, sizeof (MatePanelApplet
), (GInstanceInitFunc)(void (*)(void)) mate_panel_applet_init
, (GTypeFlags) 0); { {{ MatePanelApplet_private_offset = g_type_add_instance_private
(g_define_type_id, sizeof (MatePanelAppletPrivate)); };} } return
g_define_type_id; }
156
157#define MATE_PANEL_APPLET_INTERFACE"org.mate.panel.applet.Applet" "org.mate.panel.applet.Applet"
158#define MATE_PANEL_APPLET_OBJECT_PATH"/org/mate/panel/applet/%s/%d" "/org/mate/panel/applet/%s/%d"
159
160char *
161mate_panel_applet_get_preferences_path (MatePanelApplet *applet)
162{
163 MatePanelAppletPrivate *priv;
164
165 g_return_val_if_fail (MATE_PANEL_IS_APPLET (applet), NULL)do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return (((void*)0)); } } while (0)
;
166
167 priv = mate_panel_applet_get_instance_private (applet);
168 if (!priv->prefs_path)
169 return NULL((void*)0);
170
171 return g_strdup (priv->prefs_path)g_strdup_inline (priv->prefs_path);
172}
173
174static void
175mate_panel_applet_set_preferences_path (MatePanelApplet *applet,
176 const char *prefs_path)
177{
178 MatePanelAppletPrivate *priv;
179
180 priv = mate_panel_applet_get_instance_private (applet);
181
182 if (priv->prefs_path == prefs_path)
183 return;
184
185 if (g_strcmp0 (priv->prefs_path, prefs_path) == 0)
186 return;
187
188 if (prefs_path)
189 priv->prefs_path = g_strdup (prefs_path)g_strdup_inline (prefs_path);
190
191 g_object_notify (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
, "prefs-path");
192}
193
194MatePanelAppletFlags
195mate_panel_applet_get_flags (MatePanelApplet *applet)
196{
197 MatePanelAppletPrivate *priv;
198
199 g_return_val_if_fail (MATE_PANEL_IS_APPLET (applet), MATE_PANEL_APPLET_FLAGS_NONE)do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return (MATE_PANEL_APPLET_FLAGS_NONE); } } while (0)
;
200
201 priv = mate_panel_applet_get_instance_private (applet);
202
203 return priv->flags;
204}
205
206void
207mate_panel_applet_set_flags (MatePanelApplet *applet,
208 MatePanelAppletFlags flags)
209{
210 MatePanelAppletPrivate *priv;
211
212 g_return_if_fail (MATE_PANEL_IS_APPLET (applet))do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return; } } while (0)
;
213
214 priv = mate_panel_applet_get_instance_private (applet);
215
216 if (priv->flags == flags)
217 return;
218
219 priv->flags = flags;
220
221 g_object_notify (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
, "flags");
222
223 if (priv->connection) {
224 GVariantBuilder builder;
225 GVariantBuilder invalidated_builder;
226 GError *error = NULL((void*)0);
227
228 g_variant_builder_init (&builder, G_VARIANT_TYPE_ARRAY((const GVariantType *) "a*"));
229 g_variant_builder_init (&invalidated_builder, G_VARIANT_TYPE ("as")(g_variant_type_checked_ (("as"))));
230
231 g_variant_builder_add (&builder, "{sv}", "Flags",
232 g_variant_new_uint32 (priv->flags));
233
234 g_dbus_connection_emit_signal (priv->connection,
235 NULL((void*)0),
236 priv->object_path,
237 "org.freedesktop.DBus.Properties",
238 "PropertiesChanged",
239 g_variant_new ("(sa{sv}as)",
240 MATE_PANEL_APPLET_INTERFACE"org.mate.panel.applet.Applet",
241 &builder,
242 &invalidated_builder),
243 &error);
244 if (error) {
245 g_printerr ("Failed to send signal PropertiesChanged::Flags: %s\n",
246 error->message);
247 g_error_free (error);
248 }
249 g_variant_builder_clear (&builder);
250 g_variant_builder_clear (&invalidated_builder);
251 }
252}
253
254static void
255mate_panel_applet_size_hints_ensure (MatePanelApplet *applet,
256 int new_size)
257{
258 MatePanelAppletPrivate *priv;
259
260 priv = mate_panel_applet_get_instance_private (applet);
261 if (priv->size_hints && priv->size_hints_len < new_size) {
262 g_free (priv->size_hints);
263 priv->size_hints = g_new (gint, new_size)((gint *) g_malloc_n ((new_size), sizeof (gint)));
264 } else if (!priv->size_hints) {
265 priv->size_hints = g_new (gint, new_size)((gint *) g_malloc_n ((new_size), sizeof (gint)));
266 }
267 priv->size_hints_len = new_size;
268}
269
270static gboolean
271mate_panel_applet_size_hints_changed (MatePanelApplet *applet,
272 const int *size_hints,
273 int n_elements,
274 int base_size)
275{
276 MatePanelAppletPrivate *priv;
277 gint i;
278
279 priv = mate_panel_applet_get_instance_private (applet);
280
281 if (!priv->size_hints)
282 return TRUE(!(0));
283
284 if (priv->size_hints_len != n_elements)
285 return TRUE(!(0));
286
287 for (i = 0; i < n_elements; i++) {
288 if (size_hints[i] + base_size != priv->size_hints[i])
289 return TRUE(!(0));
290 }
291
292 return FALSE(0);
293}
294
295/**
296 * mate_panel_applet_set_size_hints:
297 * @applet: applet
298 * @size_hints: (array length=n_elements): List of integers
299 * @n_elements: Length of @size_hints
300 * @base_size: base_size
301 */
302void
303mate_panel_applet_set_size_hints (MatePanelApplet *applet,
304 const int *size_hints,
305 int n_elements,
306 int base_size)
307{
308 MatePanelAppletPrivate *priv;
309 gint i;
310
311 /* Make sure property has really changed to avoid bus traffic */
312 if (!mate_panel_applet_size_hints_changed (applet, size_hints, n_elements, base_size))
313 return;
314
315 priv = mate_panel_applet_get_instance_private (applet);
316
317 mate_panel_applet_size_hints_ensure (applet, n_elements);
318 for (i = 0; i < n_elements; i++)
319 priv->size_hints[i] = size_hints[i] + base_size;
320
321 g_object_notify (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
, "size-hints");
322
323 if (priv->connection) {
324 GVariantBuilder builder;
325 GVariantBuilder invalidated_builder;
326 GVariant **children;
327 GError *error = NULL((void*)0);
328
329 g_variant_builder_init (&builder, G_VARIANT_TYPE_ARRAY((const GVariantType *) "a*"));
330 g_variant_builder_init (&invalidated_builder, G_VARIANT_TYPE ("as")(g_variant_type_checked_ (("as"))));
331
332 children = g_new (GVariant *, priv->size_hints_len)((GVariant * *) g_malloc_n ((priv->size_hints_len), sizeof
(GVariant *)))
;
333 for (i = 0; i < n_elements; i++)
334 children[i] = g_variant_new_int32 (priv->size_hints[i]);
335 g_variant_builder_add (&builder, "{sv}", "SizeHints",
336 g_variant_new_array (G_VARIANT_TYPE_INT32((const GVariantType *) "i"),
337 children, priv->size_hints_len));
338 g_free (children);
339
340 g_dbus_connection_emit_signal (priv->connection,
341 NULL((void*)0),
342 priv->object_path,
343 "org.freedesktop.DBus.Properties",
344 "PropertiesChanged",
345 g_variant_new ("(sa{sv}as)",
346 MATE_PANEL_APPLET_INTERFACE"org.mate.panel.applet.Applet",
347 &builder,
348 &invalidated_builder),
349 &error);
350 if (error) {
351 g_printerr ("Failed to send signal PropertiesChanged::SizeHints: %s\n",
352 error->message);
353 g_error_free (error);
354 }
355 g_variant_builder_clear (&builder);
356 g_variant_builder_clear (&invalidated_builder);
357 }
358}
359
360guint
361mate_panel_applet_get_size (MatePanelApplet *applet)
362{
363 MatePanelAppletPrivate *priv;
364
365 g_return_val_if_fail (MATE_PANEL_IS_APPLET (applet), 0)do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return (0); } } while (0)
;
366
367 priv = mate_panel_applet_get_instance_private (applet);
368
369 return priv->size;
370}
371
372/* Applets cannot set their size, so API is not public. */
373static void
374mate_panel_applet_set_size (MatePanelApplet *applet,
375 guint size)
376{
377 MatePanelAppletPrivate *priv;
378
379 g_return_if_fail (MATE_PANEL_IS_APPLET (applet))do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return; } } while (0)
;
380
381 priv = mate_panel_applet_get_instance_private (applet);
382
383 if (priv->size == size)
384 return;
385
386 priv->size = size;
387 g_signal_emit (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
,
388 mate_panel_applet_signals [CHANGE_SIZE],
389 0, size);
390
391 g_object_notify (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
, "size");
392}
393
394MatePanelAppletOrient
395mate_panel_applet_get_orient (MatePanelApplet *applet)
396{
397 MatePanelAppletPrivate *priv;
398
399 g_return_val_if_fail (MATE_PANEL_IS_APPLET (applet), 0)do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return (0); } } while (0)
;
400
401 priv = mate_panel_applet_get_instance_private (applet);
402
403 return priv->orient;
404}
405
406/* Applets cannot set their orientation, so API is not public. */
407static void
408mate_panel_applet_set_orient (MatePanelApplet *applet,
409 MatePanelAppletOrient orient)
410{
411 MatePanelAppletPrivate *priv;
412
413 g_return_if_fail (MATE_PANEL_IS_APPLET (applet))do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return; } } while (0)
;
414
415 priv = mate_panel_applet_get_instance_private (applet);
416
417 if (priv->orient == orient)
418 return;
419
420 priv->orient = orient;
421 g_signal_emit (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
,
422 mate_panel_applet_signals [CHANGE_ORIENT],
423 0, orient);
424
425 g_object_notify (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
, "orient");
426}
427
428static void
429mate_panel_applet_set_locked (MatePanelApplet *applet,
430 gboolean locked)
431{
432 MatePanelAppletPrivate *priv;
433 GtkAction *action;
434
435 g_return_if_fail (MATE_PANEL_IS_APPLET (applet))do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return; } } while (0)
;
436
437 priv = mate_panel_applet_get_instance_private (applet);
438
439 if (priv->locked == locked)
440 return;
441
442 priv->locked = locked;
443
444 action = mate_panel_applet_menu_get_action (applet, "Lock");
445 g_signal_handlers_block_by_func (action,g_signal_handlers_block_matched ((action), (GSignalMatchType)
(G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0
), (mate_panel_applet_menu_cmd_lock), (applet))
446 mate_panel_applet_menu_cmd_lock,g_signal_handlers_block_matched ((action), (GSignalMatchType)
(G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0
), (mate_panel_applet_menu_cmd_lock), (applet))
447 applet)g_signal_handlers_block_matched ((action), (GSignalMatchType)
(G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0
), (mate_panel_applet_menu_cmd_lock), (applet))
;
448 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action)((((GtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((gtk_toggle_action_get_type ()))))))
, locked);
449 g_signal_handlers_unblock_by_func (action,g_signal_handlers_unblock_matched ((action), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (mate_panel_applet_menu_cmd_lock), (applet))
450 mate_panel_applet_menu_cmd_lock,g_signal_handlers_unblock_matched ((action), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (mate_panel_applet_menu_cmd_lock), (applet))
451 applet)g_signal_handlers_unblock_matched ((action), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (mate_panel_applet_menu_cmd_lock), (applet))
;
452
453 mate_panel_applet_menu_update_actions (applet);
454
455 g_object_notify (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
, "locked");
456
457 if (priv->connection) {
458 GError *error = NULL((void*)0);
459
460 g_dbus_connection_emit_signal (priv->connection,
461 NULL((void*)0),
462 priv->object_path,
463 MATE_PANEL_APPLET_INTERFACE"org.mate.panel.applet.Applet",
464 locked ? "Lock" : "Unlock",
465 NULL((void*)0), &error);
466 if (error) {
467 g_printerr ("Failed to send signal %s: %s\n",
468 locked ? "Lock" : "Unlock",
469 error->message);
470 g_error_free (error);
471 }
472 }
473}
474
475gboolean
476mate_panel_applet_get_locked_down (MatePanelApplet *applet)
477{
478 MatePanelAppletPrivate *priv;
479
480 g_return_val_if_fail (MATE_PANEL_IS_APPLET (applet), FALSE)do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return ((0)); } } while (0)
;
481
482 priv = mate_panel_applet_get_instance_private (applet);
483
484 return priv->locked_down;
485}
486
487/* Applets cannot set the lockdown state, so API is not public. */
488static void
489mate_panel_applet_set_locked_down (MatePanelApplet *applet,
490 gboolean locked_down)
491{
492 MatePanelAppletPrivate *priv;
493
494 g_return_if_fail (MATE_PANEL_IS_APPLET (applet))do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return; } } while (0)
;
495
496 priv = mate_panel_applet_get_instance_private (applet);
497
498 if (priv->locked_down == locked_down)
499 return;
500
501 priv->locked_down = locked_down;
502 mate_panel_applet_menu_update_actions (applet);
503
504 g_object_notify (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
, "locked-down");
505}
506
507#ifdef HAVE_X111
508
509static Atom _net_wm_window_type = None0L;
510static Atom _net_wm_window_type_dock = None0L;
511static Atom _net_active_window = None0L;
512
513static void
514mate_panel_applet_init_atoms (Display *xdisplay)
515{
516 if (_net_wm_window_type == None0L)
517 _net_wm_window_type = XInternAtom (xdisplay,
518 "_NET_WM_WINDOW_TYPE",
519 False0);
520
521 if (_net_wm_window_type_dock == None0L)
522 _net_wm_window_type_dock = XInternAtom (xdisplay,
523 "_NET_WM_WINDOW_TYPE_DOCK",
524 False0);
525
526 if (_net_active_window == None0L)
527 _net_active_window = XInternAtom (xdisplay,
528 "_NET_ACTIVE_WINDOW",
529 False0);
530}
531
532static Window
533mate_panel_applet_find_toplevel_dock_window (MatePanelApplet *applet,
534 Display *xdisplay)
535{
536 GtkWidget *toplevel;
537 Window xwin;
538 Window root, parent, *child;
539 int num_children;
540
541 toplevel = gtk_widget_get_toplevel (GTK_WIDGET (applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
);
542 if (!gtk_widget_get_realized (toplevel))
543 return None0L;
544
545 xwin = GDK_WINDOW_XID (gtk_widget_get_window (toplevel))(gdk_x11_window_get_xid (gtk_widget_get_window (toplevel)));
546
547 child = NULL((void*)0);
548 parent = root = None0L;
549 do {
550 Atom type_return;
551 Atom window_type;
552 int format_return;
553 gulong number_return, bytes_after_return;
554 guchar *data_return;
555
556 XGetWindowProperty (xdisplay,
557 xwin,
558 _net_wm_window_type,
559 0, 1, False0,
560 XA_ATOM((Atom) 4),
561 &type_return, &format_return,
562 &number_return,
563 &bytes_after_return,
564 &data_return);
565
566 if (type_return == XA_ATOM((Atom) 4)) {
567 window_type = *(Atom *) data_return;
568
569 XFree (data_return);
570 data_return = NULL((void*)0);
571
572 if (window_type == _net_wm_window_type_dock)
573 return xwin;
574 }
575
576 if (!XQueryTree (xdisplay,
577 xwin,
578 &root, &parent, &child,
579 (guint *) &num_children)) {
580 return None0L;
581 }
582
583 if (child && num_children > 0)
584 XFree (child);
585
586 xwin = parent;
587
588 } while (xwin != None0L && xwin != root);
589
590 return None0L;
591}
592
593#endif /* HAVE_X11 */
594
595/* This function
596 * 1) Gets the window id of the panel that contains the applet
597 * using XQueryTree and XGetWindowProperty to find an ancestor
598 * window with the _NET_WM_WINDOW_TYPE_DOCK window type.
599 * 2) Sends a _NET_ACTIVE_WINDOW message to get that panel focused
600 */
601void
602mate_panel_applet_request_focus (MatePanelApplet *applet,
603 guint32 timestamp)
604{
605#ifdef HAVE_X111
606 GdkScreen *screen;
607 GdkWindow *root;
608 GdkDisplay *display;
609 Display *xdisplay;
610 Window dock_xwindow;
611 Window xroot;
612 XEvent xev;
613
614 if (!GDK_IS_X11_DISPLAY (gdk_display_get_default ())(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gdk_display_get_default ())); GType __t = ((gdk_x11_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
)
615 return;
616
617 g_return_if_fail (MATE_PANEL_IS_APPLET (applet))do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return; } } while (0)
;
618
619 screen = gdk_screen_get_default(); /*There is only one screen since GTK 3.22*/
620 root = gdk_screen_get_root_window (screen);
621 display = gdk_screen_get_display (screen);
622
623 xdisplay = GDK_DISPLAY_XDISPLAY (display)(gdk_x11_display_get_xdisplay (display));
624 xroot = GDK_WINDOW_XID (root)(gdk_x11_window_get_xid (root));
625
626 mate_panel_applet_init_atoms (xdisplay);
627
628 dock_xwindow = mate_panel_applet_find_toplevel_dock_window (applet, xdisplay);
629 if (dock_xwindow == None0L)
630 return;
631
632 xev.xclient.type = ClientMessage33;
633 xev.xclient.serial = 0;
634 xev.xclient.send_event = True1;
635 xev.xclient.window = dock_xwindow;
636 xev.xclient.message_type = _net_active_window;
637 xev.xclient.format = 32;
638 xev.xclient.data.l[0] = 1; /* requestor type; we're an app, I guess */
639 xev.xclient.data.l[1] = timestamp;
640 xev.xclient.data.l[2] = None0L; /* "currently active window", supposedly */
641 xev.xclient.data.l[3] = 0;
642 xev.xclient.data.l[4] = 0;
643
644 XSendEvent (xdisplay,
645 xroot, False0,
646 SubstructureRedirectMask(1L<<20) | SubstructureNotifyMask(1L<<19),
647 &xev);
648#endif
649}
650
651static GtkAction *
652mate_panel_applet_menu_get_action (MatePanelApplet *applet,
653 const gchar *action)
654{
655 MatePanelAppletPrivate *priv;
656
657 priv = mate_panel_applet_get_instance_private (applet);
658
659 return gtk_action_group_get_action (priv->panel_action_group, action);
660}
661
662static void
663mate_panel_applet_menu_update_actions (MatePanelApplet *applet)
664{
665 MatePanelAppletPrivate *priv;
666
667 priv = mate_panel_applet_get_instance_private (applet);
668 g_object_set (mate_panel_applet_menu_get_action (applet, "Lock"),
669 "visible", !priv->locked_down,
670 NULL((void*)0));
671 g_object_set (mate_panel_applet_menu_get_action (applet, "Move"),
672 "sensitive", !priv->locked,
673 "visible", !priv->locked_down,
674 NULL((void*)0));
675 g_object_set (mate_panel_applet_menu_get_action (applet, "Remove"),
676 "sensitive", !priv->locked,
677 "visible", !priv->locked_down,
678 NULL((void*)0));
679}
680
681static void
682mate_panel_applet_menu_cmd_remove (GtkAction *action,
683 MatePanelApplet *applet)
684{
685 MatePanelAppletPrivate *priv;
686 GError *error = NULL((void*)0);
687
688 priv = mate_panel_applet_get_instance_private (applet);
689
690 if (!priv->connection)
691 return;
692
693 g_dbus_connection_emit_signal (priv->connection,
694 NULL((void*)0),
695 priv->object_path,
696 MATE_PANEL_APPLET_INTERFACE"org.mate.panel.applet.Applet",
697 "RemoveFromPanel",
698 NULL((void*)0), &error);
699 if (error) {
700 g_printerr ("Failed to send signal RemoveFromPanel: %s\n",
701 error->message);
702 g_error_free (error);
703 }
704}
705
706static void
707mate_panel_applet_menu_cmd_move (GtkAction *action,
708 MatePanelApplet *applet)
709{
710 MatePanelAppletPrivate *priv;
711 GError *error = NULL((void*)0);
712
713 priv = mate_panel_applet_get_instance_private (applet);
714
715 if (!priv->connection)
716 return;
717
718 g_dbus_connection_emit_signal (priv->connection,
719 NULL((void*)0),
720 priv->object_path,
721 MATE_PANEL_APPLET_INTERFACE"org.mate.panel.applet.Applet",
722 "Move",
723 NULL((void*)0), &error);
724 if (error) {
725 g_printerr ("Failed to send signal RemoveFromPanel: %s\n",
726 error->message);
727 g_error_free (error);
728 }
729}
730
731static void
732mate_panel_applet_menu_cmd_lock (GtkAction *action,
733 MatePanelApplet *applet)
734{
735 gboolean locked;
736
737 locked = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)((((GtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((gtk_toggle_action_get_type ()))))))
);
738 mate_panel_applet_set_locked (applet, locked);
739}
740
741void
742mate_panel_applet_setup_menu (MatePanelApplet *applet,
743 const gchar *xml,
744 GtkActionGroup *applet_action_group)
745{
746 MatePanelAppletPrivate *priv;
747 gchar *new_xml;
748 GError *error = NULL((void*)0);
749
750 g_return_if_fail (MATE_PANEL_IS_APPLET (applet))do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return; } } while (0)
;
751 g_return_if_fail (xml != NULL)do { if ((xml != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "xml != NULL"); return
; } } while (0)
;
752
753 priv = mate_panel_applet_get_instance_private (applet);
754
755 if (priv->applet_action_group)
756 return;
757
758 priv->applet_action_group = g_object_ref (applet_action_group)((__typeof__ (applet_action_group)) (g_object_ref) (applet_action_group
))
;
759 gtk_ui_manager_insert_action_group (priv->ui_manager,
760 applet_action_group, 0);
761
762 new_xml = g_strdup_printf ("<ui><popup name=\"MatePanelAppletPopup\" action=\"AppletItems\">"
763 "<placeholder name=\"AppletItems\">%s\n</placeholder>\n"
764 "</popup></ui>\n", xml);
765 gtk_ui_manager_add_ui_from_string (priv->ui_manager, new_xml, -1, &error);
766 g_free (new_xml);
767 gtk_ui_manager_ensure_update (priv->ui_manager);
768 if (error) {
769 g_warning ("Error merging menus: %s\n", error->message);
770 g_error_free (error);
771 }
772}
773
774void
775mate_panel_applet_setup_menu_from_file (MatePanelApplet *applet,
776 const gchar *filename,
777 GtkActionGroup *applet_action_group)
778{
779 gchar *xml = NULL((void*)0);
780 GError *error = NULL((void*)0);
781
782 if (g_file_get_contents (filename, &xml, NULL((void*)0), &error)) {
783 mate_panel_applet_setup_menu (applet, xml, applet_action_group);
784 } else {
785 g_warning ("%s", error->message);
786 g_error_free (error);
787 }
788
789 g_free (xml);
790}
791
792/**
793 * mate_panel_applet_setup_menu_from_resource:
794 * @applet: a #MatePanelApplet.
795 * @resource_path: a resource path
796 * @action_group: a #GtkActionGroup.
797 *
798 * Sets up the context menu of @applet. @filename is a resource path to a menu
799 * XML file, containing a #GtkUIManager UI definition that describes how to
800 * display the menu items. @action_group contains the various #GtkAction that
801 * are referenced in @xml.
802 *
803 * See also the <link linkend="getting-started.context-menu">Context
804 * Menu</link> section.
805 *
806 * Since: 1.20.1
807 **/
808void
809mate_panel_applet_setup_menu_from_resource (MatePanelApplet *applet,
810 const gchar *resource_path,
811 GtkActionGroup *action_group)
812{
813 GBytes *bytes;
814 GError *error = NULL((void*)0);
815
816 bytes = g_resources_lookup_data (resource_path,
817 G_RESOURCE_LOOKUP_FLAGS_NONE,
818 &error);
819
820 if (bytes) {
821 mate_panel_applet_setup_menu (applet,
822 g_bytes_get_data (bytes, NULL((void*)0)),
823 action_group);
824 } else {
825 g_warning ("%s", error->message);
826 g_error_free (error);
827 }
828
829 g_bytes_unref (bytes);
830}
831
832static void
833mate_panel_applet_finalize (GObject *object)
834{
835 MatePanelApplet *applet;
836 MatePanelAppletPrivate *priv;
837
838 applet = MATE_PANEL_APPLET (object);
839 priv = mate_panel_applet_get_instance_private (applet);
840
841 if (priv->connection) {
842 if (priv->object_id)
843 g_dbus_connection_unregister_object (priv->connection,
844 priv->object_id);
845 priv->object_id = 0;
846 g_clear_object (&priv->connection)do { _Static_assert (sizeof *((&priv->connection)) == sizeof
(gpointer), "Expression evaluates to false"); __typeof__ (((
&priv->connection))) _pp = ((&priv->connection)
); __typeof__ (*((&priv->connection))) _ptr = *_pp; *_pp
= ((void*)0); if (_ptr) (g_object_unref) (_ptr); } while (0)
;
847 }
848
849 g_clear_pointer (&priv->object_path, g_free)do { _Static_assert (sizeof *(&priv->object_path) == sizeof
(gpointer), "Expression evaluates to false"); __typeof__ ((&
priv->object_path)) _pp = (&priv->object_path); __typeof__
(*(&priv->object_path)) _ptr = *_pp; *_pp = ((void*)0
); if (_ptr) (g_free) (_ptr); } while (0)
;
850
851 mate_panel_applet_set_preferences_path (applet, NULL((void*)0));
852
853 g_clear_object (&priv->applet_action_group)do { _Static_assert (sizeof *((&priv->applet_action_group
)) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(((&priv->applet_action_group))) _pp = ((&priv->
applet_action_group)); __typeof__ (*((&priv->applet_action_group
))) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (g_object_unref
) (_ptr); } while (0)
;
854 g_clear_object (&priv->panel_action_group)do { _Static_assert (sizeof *((&priv->panel_action_group
)) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(((&priv->panel_action_group))) _pp = ((&priv->
panel_action_group)); __typeof__ (*((&priv->panel_action_group
))) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (g_object_unref
) (_ptr); } while (0)
;
855 g_clear_object (&priv->ui_manager)do { _Static_assert (sizeof *((&priv->ui_manager)) == sizeof
(gpointer), "Expression evaluates to false"); __typeof__ (((
&priv->ui_manager))) _pp = ((&priv->ui_manager)
); __typeof__ (*((&priv->ui_manager))) _ptr = *_pp; *_pp
= ((void*)0); if (_ptr) (g_object_unref) (_ptr); } while (0)
;
856
857 g_clear_pointer (&priv->size_hints, g_free)do { _Static_assert (sizeof *(&priv->size_hints) == sizeof
(gpointer), "Expression evaluates to false"); __typeof__ ((&
priv->size_hints)) _pp = (&priv->size_hints); __typeof__
(*(&priv->size_hints)) _ptr = *_pp; *_pp = ((void*)0)
; if (_ptr) (g_free) (_ptr); } while (0)
;
858 g_clear_pointer (&priv->prefs_path, g_free)do { _Static_assert (sizeof *(&priv->prefs_path) == sizeof
(gpointer), "Expression evaluates to false"); __typeof__ ((&
priv->prefs_path)) _pp = (&priv->prefs_path); __typeof__
(*(&priv->prefs_path)) _ptr = *_pp; *_pp = ((void*)0)
; if (_ptr) (g_free) (_ptr); } while (0)
;
859 g_clear_pointer (&priv->background, g_free)do { _Static_assert (sizeof *(&priv->background) == sizeof
(gpointer), "Expression evaluates to false"); __typeof__ ((&
priv->background)) _pp = (&priv->background); __typeof__
(*(&priv->background)) _ptr = *_pp; *_pp = ((void*)0)
; if (_ptr) (g_free) (_ptr); } while (0)
;
860 g_clear_pointer (&priv->id, g_free)do { _Static_assert (sizeof *(&priv->id) == sizeof (gpointer
), "Expression evaluates to false"); __typeof__ ((&priv->
id)) _pp = (&priv->id); __typeof__ (*(&priv->id
)) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (g_free) (_ptr);
} while (0)
;
861
862 /* closure is owned by the factory */
863 priv->closure = NULL((void*)0);
864
865 G_OBJECT_CLASS (mate_panel_applet_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((mate_panel_applet_parent_class)), (((GType) ((20) <<
(2))))))))
->finalize (object);
866}
867
868static gboolean
869container_has_focusable_child (GtkContainer *container)
870{
871 GList *list;
872 GList *t;
873 gboolean retval = FALSE(0);
874
875 list = gtk_container_get_children (container);
876
877 for (t = list; t; t = t->next) {
878 GtkWidget *child = GTK_WIDGET (t->data)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((t->data)), ((gtk_widget_get_type ()))))))
;
879 if (gtk_widget_get_can_focus (child)) {
880 retval = TRUE(!(0));
881 break;
882 } else if (GTK_IS_CONTAINER (child)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(child)); GType __t = ((gtk_container_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; }))))
) {
883 retval = container_has_focusable_child (GTK_CONTAINER (child)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((child)), ((gtk_container_get_type ()))))))
);
884 if (retval)
885 break;
886 }
887 }
888 g_list_free (list);
889 return retval;
890}
891
892static void
893mate_panel_applet_menu_popup (MatePanelApplet *applet,
894 GdkEvent *event)
895{
896 MatePanelAppletPrivate *priv;
897 GtkWidget *menu;
898
899 priv = mate_panel_applet_get_instance_private (applet);
900 menu = gtk_ui_manager_get_widget (priv->ui_manager,
901 "/MatePanelAppletPopup");
902
903/* Set up theme and transparency support */
904 GtkWidget *toplevel = gtk_widget_get_toplevel (menu);
905/* Fix any failures of compiz/other wm's to communicate with gtk for transparency */
906 GdkScreen *screen = gtk_widget_get_screen(GTK_WIDGET(toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
907 GdkVisual *visual = gdk_screen_get_rgba_visual(screen);
908 gtk_widget_set_visual(GTK_WIDGET(toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
, visual);
909/* Set menu and it's toplevel window to follow panel theme */
910 GtkStyleContext *context;
911 context = gtk_widget_get_style_context (GTK_WIDGET(toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
912 gtk_style_context_add_class(context,"gnome-panel-menu-bar");
913 gtk_style_context_add_class(context,"mate-panel-menu-bar");
914 GdkGravity widget_anchor = GDK_GRAVITY_NORTH_WEST;
915 GdkGravity menu_anchor = GDK_GRAVITY_NORTH_WEST;
916 switch (priv->orient) {
917 case MATE_PANEL_APPLET_ORIENT_UP:
918 menu_anchor = GDK_GRAVITY_SOUTH_WEST;
919 break;
920 case MATE_PANEL_APPLET_ORIENT_DOWN:
921 widget_anchor = GDK_GRAVITY_SOUTH_WEST;
922 break;
923 case MATE_PANEL_APPLET_ORIENT_LEFT:
924 menu_anchor = GDK_GRAVITY_NORTH_EAST;
925 break;
926 case MATE_PANEL_APPLET_ORIENT_RIGHT:
927 widget_anchor = GDK_GRAVITY_NORTH_EAST;
928 break;
929 }
930 gtk_menu_popup_at_widget (GTK_MENU (menu)((((GtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((menu)), ((gtk_menu_get_type ()))))))
,
931 GTK_WIDGET (applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
,
932 widget_anchor,
933 menu_anchor,
934 event);
935}
936
937static gboolean
938mate_panel_applet_can_focus (GtkWidget *widget)
939{
940 /*
941 * A MatePanelApplet widget can focus if it has a tooltip or it does
942 * not have any focusable children.
943 */
944 if (gtk_widget_get_has_tooltip (widget))
945 return TRUE(!(0));
946
947 if (!MATE_PANEL_IS_APPLET (widget))
948 return FALSE(0);
949
950 return !container_has_focusable_child (GTK_CONTAINER (widget)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_container_get_type ()))))))
);
951}
952
953/* Taken from libmatecomponentui/matecomponent/matecomponent-plug.c */
954static gboolean
955mate_panel_applet_button_event (MatePanelApplet *applet,
956 GdkEventButton *event)
957{
958#ifdef HAVE_X111
959 MatePanelAppletPrivate *priv;
960 GtkWidget *widget;
961 GdkWindow *window;
962 GdkWindow *socket_window;
963 XEvent xevent;
964 GdkDisplay *display;
965
966 priv = mate_panel_applet_get_instance_private (applet);
967
968 if (!priv->out_of_process)
969 return FALSE(0);
970
971 widget = priv->plug;
972
973 if (!gtk_widget_is_toplevel (widget))
974 return FALSE(0);
975
976 window = gtk_widget_get_window (widget);
977 socket_window = gtk_plug_get_socket_window (GTK_PLUG (widget)((((GtkPlug*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_plug_get_type ()))))))
);
978
979 display = gdk_display_get_default ();
980
981 if (!GDK_IS_X11_DISPLAY (display)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(display)); GType __t = ((gdk_x11_display_get_type())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
)
982 return FALSE(0);
983
984 if (event->type == GDK_BUTTON_PRESS) {
985 GdkSeat *seat;
986
987 xevent.xbutton.type = ButtonPress4;
988
989 seat = gdk_display_get_default_seat (display);
990
991 /* X does an automatic pointer grab on button press
992 * if we have both button press and release events
993 * selected.
994 * We don't want to hog the pointer on our parent.
995 */
996 gdk_seat_ungrab (seat);
997 } else {
998 xevent.xbutton.type = ButtonRelease5;
999 }
1000
1001 xevent.xbutton.display = GDK_WINDOW_XDISPLAY (window)((gdk_x11_display_get_xdisplay (gdk_window_get_display (window
))))
;
1002 xevent.xbutton.window = GDK_WINDOW_XID (socket_window)(gdk_x11_window_get_xid (socket_window));
1003 xevent.xbutton.root = GDK_WINDOW_XID (gdk_screen_get_root_window(gdk_x11_window_get_xid (gdk_screen_get_root_window (gdk_window_get_screen
(window))))
1004 (gdk_window_get_screen (window)))(gdk_x11_window_get_xid (gdk_screen_get_root_window (gdk_window_get_screen
(window))))
;
1005 /*
1006 * FIXME: the following might cause
1007 * big problems for non-GTK apps
1008 */
1009 xevent.xbutton.x = 0;
1010 xevent.xbutton.y = 0;
1011 xevent.xbutton.x_root = 0;
1012 xevent.xbutton.y_root = 0;
1013 xevent.xbutton.state = event->state;
1014 xevent.xbutton.button = event->button;
1015 xevent.xbutton.same_screen = TRUE(!(0)); /* FIXME ? */
1016
1017 gdk_x11_display_error_trap_push (display);
1018
1019 XSendEvent (GDK_WINDOW_XDISPLAY (window)((gdk_x11_display_get_xdisplay (gdk_window_get_display (window
))))
,
1020 GDK_WINDOW_XID (socket_window)(gdk_x11_window_get_xid (socket_window)),
1021 False0, NoEventMask0L, &xevent);
1022
1023 gdk_display_flush (display);
1024 gdk_x11_display_error_trap_pop_ignored (display);
1025
1026 return TRUE(!(0));
1027#else
1028 return FALSE(0);
1029#endif
1030}
1031
1032static gboolean
1033mate_panel_applet_button_press (GtkWidget *widget,
1034 GdkEventButton *event)
1035{
1036 MatePanelApplet *applet = MATE_PANEL_APPLET (widget);
1037
1038 if (!container_has_focusable_child (GTK_CONTAINER (applet)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_container_get_type ()))))))
)) {
1039 if (!gtk_widget_has_focus (widget)) {
1040 gtk_widget_set_can_focus (widget, TRUE(!(0)));
1041 gtk_widget_grab_focus (widget);
1042 }
1043 }
1044
1045#ifdef HAVE_WAYLAND1
1046 /*Limit the window list's applet menu to the handle area*/
1047 if (!(GDK_IS_X11_DISPLAY (gdk_display_get_default ())(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gdk_display_get_default ())); GType __t = ((gdk_x11_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
))
1048 {
1049 MatePanelAppletFlags flags;
1050 flags = mate_panel_applet_get_flags (applet);
1051 if (flags & MATE_PANEL_APPLET_EXPAND_MAJOR)
1052 return FALSE(0);
1053 }
1054#endif
1055
1056 if (event->button == 3) {
1057 mate_panel_applet_menu_popup (applet, (GdkEvent *) event);
1058
1059 return TRUE(!(0));
1060 }
1061 return mate_panel_applet_button_event (applet, event);
1062}
1063
1064static gboolean
1065mate_panel_applet_button_release (GtkWidget *widget,
1066 GdkEventButton *event)
1067{
1068 MatePanelApplet *applet = MATE_PANEL_APPLET (widget);
1069
1070 return mate_panel_applet_button_event (applet, event);
1071}
1072
1073/*Open the applet context menu only on Menu key
1074 *Do not open it on Return or some applets won't work
1075 */
1076static gboolean
1077mate_panel_applet_key_press_event (GtkWidget *widget,
1078 GdkEventKey *event)
1079{
1080 if (event->keyval == GDK_KEY_Menu0xff67) {
1081 mate_panel_applet_menu_popup (MATE_PANEL_APPLET (widget), (GdkEvent *) event);
1082 return TRUE(!(0));
1083 }
1084 else
1085 return FALSE(0);
1086}
1087
1088static void
1089mate_panel_applet_get_preferred_width (GtkWidget *widget,
1090 int *minimum_width,
1091 int *natural_width)
1092{
1093 GTK_WIDGET_CLASS (mate_panel_applet_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((mate_panel_applet_parent_class)), ((gtk_widget_get_type (
)))))))
->get_preferred_width (widget,
1094 minimum_width,
1095 natural_width);
1096
1097#if !GTK_CHECK_VERSION (3, 23, 0)((3) > (3) || ((3) == (3) && (24) > (23)) || ((
3) == (3) && (24) == (23) && (42) >= (0)))
1098 MatePanelAppletPrivate *priv;
1099
1100 priv = mate_panel_applet_get_instance_private (MATE_PANEL_APPLET (widget));
1101 if (priv->out_of_process) {
1102 /* Out-of-process applets end up scaled up doubly with GTK 3.22.
1103 * For these builds divide by the scale factor to ensure
1104 * they are back at their own intended size.
1105 */
1106 gint scale;
1107 scale = gtk_widget_get_scale_factor (widget);
1108 *minimum_width /= scale;
1109 *natural_width /= scale;
1110 }
1111#endif
1112}
1113
1114static void
1115mate_panel_applet_get_preferred_height (GtkWidget *widget,
1116 int *minimum_height,
1117 int *natural_height)
1118{
1119 GTK_WIDGET_CLASS (mate_panel_applet_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((mate_panel_applet_parent_class)), ((gtk_widget_get_type (
)))))))
->get_preferred_height (widget,
1120 minimum_height,
1121 natural_height);
1122
1123#if !GTK_CHECK_VERSION (3, 23, 0)((3) > (3) || ((3) == (3) && (24) > (23)) || ((
3) == (3) && (24) == (23) && (42) >= (0)))
1124 MatePanelAppletPrivate *priv;
1125
1126 priv = mate_panel_applet_get_instance_private (MATE_PANEL_APPLET (widget));
1127 if (priv->out_of_process) {
1128 gint scale;
1129 /* Out-of-process applets end up scaled up doubly with GTK 3.22.
1130 * For these builds divide by the scale factor to ensure
1131 * they are back at their own intended size.
1132 */
1133 scale = gtk_widget_get_scale_factor (widget);
1134 *minimum_height /= scale;
1135 *natural_height /= scale;
1136 }
1137#endif
1138}
1139
1140static GtkSizeRequestMode
1141mate_panel_applet_get_request_mode (GtkWidget *widget)
1142{
1143 /* Do not use GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH
1144 * or GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT
1145 * to avoid problems with in-process applets
1146 * when the panel is not expanded
1147 * See https://github.com/mate-desktop/mate-panel/issues/797
1148 * and https://github.com/mate-desktop/mate-panel/issues/799
1149 * Out of process applets already use GTK_SIZE_REQUEST_CONSTANT_SIZE
1150 */
1151 return GTK_SIZE_REQUEST_CONSTANT_SIZE;
1152}
1153
1154static void
1155mate_panel_applet_size_allocate (GtkWidget *widget,
1156 GtkAllocation *allocation)
1157{
1158 MatePanelAppletPrivate *priv;
1159 GtkAllocation child_allocation;
1160 MatePanelApplet *applet;
1161
1162 if (!mate_panel_applet_can_focus (widget)) {
1163 GTK_WIDGET_CLASS (mate_panel_applet_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((mate_panel_applet_parent_class)), ((gtk_widget_get_type (
)))))))
->size_allocate (widget, allocation);
1164 } else {
1165 int border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_container_get_type ()))))))
);
1166
1167 gtk_widget_set_allocation (widget, allocation);
1168 GtkBin *bin = GTK_BIN (widget)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_bin_get_type ()))))))
;
1169
1170 child_allocation.x = 0;
1171 child_allocation.y = 0;
1172
1173 child_allocation.width = MAX (allocation->width - border_width * 2, 0)(((allocation->width - border_width * 2) > (0)) ? (allocation
->width - border_width * 2) : (0))
;
1174 child_allocation.height = MAX (allocation->height - border_width * 2, 0)(((allocation->height - border_width * 2) > (0)) ? (allocation
->height - border_width * 2) : (0))
;
1175
1176 if (gtk_widget_get_realized (widget))
1177 gdk_window_move_resize (gtk_widget_get_window (widget),
1178 allocation->x + border_width,
1179 allocation->y + border_width,
1180 child_allocation.width,
1181 child_allocation.height);
1182
1183 GtkWidget *child = gtk_bin_get_child (bin);
1184 if (child)
1185 gtk_widget_size_allocate (child, &child_allocation);
1186 }
1187
1188 applet = MATE_PANEL_APPLET (widget);
1189 priv = mate_panel_applet_get_instance_private (applet);
1190
1191 if ((priv->previous_height != allocation->height) ||
1192 (priv->previous_width != allocation->width)) {
1193 priv->previous_height = allocation->height;
1194 priv->previous_width = allocation->width;
1195 mate_panel_applet_handle_background (applet);
1196 }
1197}
1198
1199static gboolean mate_panel_applet_draw(GtkWidget* widget, cairo_t* cr)
1200{
1201 GtkStyleContext *context;
1202 int border_width;
1203 gdouble x, y, width, height;
1204
1205 GTK_WIDGET_CLASS (mate_panel_applet_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((mate_panel_applet_parent_class)), ((gtk_widget_get_type (
)))))))
->draw(widget, cr);
1206
1207 if (!gtk_widget_has_focus (widget))
1208 return FALSE(0);
1209
1210 width = gtk_widget_get_allocated_width (widget);
1211 height = gtk_widget_get_allocated_height (widget);
1212
1213 border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_container_get_type ()))))))
);
1214
1215 x = 0;
1216 y = 0;
1217
1218 width -= 2 * border_width;
1219 height -= 2 * border_width;
1220
1221 context = gtk_widget_get_style_context (widget);
1222 gtk_style_context_save (context);
1223
1224 cairo_save (cr);
1225 gtk_render_focus (context, cr, x, y, width, height);
1226 cairo_restore (cr);
1227
1228 gtk_style_context_restore (context);
1229
1230 return FALSE(0);
1231}
1232
1233static gboolean
1234mate_panel_applet_focus (GtkWidget *widget,
1235 GtkDirectionType dir)
1236{
1237 MatePanelAppletPrivate *priv;
1238 gboolean ret;
1239 GtkWidget *previous_focus_child;
1240
1241 g_return_val_if_fail (MATE_PANEL_IS_APPLET (widget), FALSE)do { if ((MATE_PANEL_IS_APPLET (widget))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (widget)"
); return ((0)); } } while (0)
;
1242
1243 priv = mate_panel_applet_get_instance_private (MATE_PANEL_APPLET (widget));
1244 if (priv->moving_focus_out) {
1245 /*
1246 * Applet will retain focus if there is nothing else on the
1247 * panel to get focus
1248 */
1249 priv->moving_focus_out = FALSE(0);
1250 return FALSE(0);
1251 }
1252
1253 previous_focus_child = gtk_container_get_focus_child (GTK_CONTAINER (widget)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_container_get_type ()))))))
);
1254 if (!previous_focus_child && !gtk_widget_has_focus (widget)) {
1255 if (gtk_widget_get_has_tooltip (widget)) {
1256 gtk_widget_set_can_focus (widget, TRUE(!(0)));
1257 gtk_widget_grab_focus (widget);
1258 gtk_widget_set_can_focus (widget, FALSE(0));
1259 return TRUE(!(0));
1260 }
1261 }
1262 ret = GTK_WIDGET_CLASS (mate_panel_applet_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((mate_panel_applet_parent_class)), ((gtk_widget_get_type (
)))))))
->focus (widget, dir);
1263
1264 if (!ret && !previous_focus_child) {
1265 if (!gtk_widget_has_focus (widget)) {
1266 /*
1267 * Applet does not have a widget which can focus so set
1268 * the focus on the applet unless it already had focus
1269 * because it had a tooltip.
1270 */
1271 gtk_widget_set_can_focus (widget, TRUE(!(0)));
1272 gtk_widget_grab_focus (widget);
1273 gtk_widget_set_can_focus (widget, FALSE(0));
1274 ret = TRUE(!(0));
1275 }
1276 }
1277
1278 return ret;
1279}
1280
1281static gboolean
1282mate_panel_applet_parse_color (const gchar *color_str,
1283 GdkRGBA *color)
1284{
1285 g_assert (color_str && color)do { if (color_str && color) ; else g_assertion_message_expr
(((gchar*) 0), "mate-panel-applet.c", 1285, ((const char*) (
__func__)), "color_str && color"); } while (0)
;
1286
1287 return gdk_rgba_parse (color, color_str);
1288}
1289
1290#ifdef HAVE_X111
1291static gboolean
1292mate_panel_applet_parse_pixmap_str (const char *str,
1293 Window *xid,
1294 int *x,
1295 int *y)
1296{
1297 char **elements;
1298 char *tmp;
1299
1300 g_return_val_if_fail (str != NULL, FALSE)do { if ((str != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "str != NULL"); return
((0)); } } while (0)
;
1301 g_return_val_if_fail (xid != NULL, FALSE)do { if ((xid != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "xid != NULL"); return
((0)); } } while (0)
;
1302 g_return_val_if_fail (x != NULL, FALSE)do { if ((x != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "x != NULL"); return
((0)); } } while (0)
;
1303 g_return_val_if_fail (y != NULL, FALSE)do { if ((y != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "y != NULL"); return
((0)); } } while (0)
;
1304
1305 elements = g_strsplit (str, ",", -1);
1306
1307 if (!elements)
1308 return FALSE(0);
1309
1310 if (!elements [0] || !*elements [0] ||
1311 !elements [1] || !*elements [1] ||
1312 !elements [2] || !*elements [2])
1313 goto ERROR_AND_FREE;
1314
1315 *xid = strtol (elements [0], &tmp, 10);
1316 if (tmp == elements [0])
1317 goto ERROR_AND_FREE;
1318
1319 *x = strtol (elements [1], &tmp, 10);
1320 if (tmp == elements [1])
1321 goto ERROR_AND_FREE;
1322
1323 *y = strtol (elements [2], &tmp, 10);
1324 if (tmp == elements [2])
1325 goto ERROR_AND_FREE;
1326
1327 g_strfreev (elements);
1328 return TRUE(!(0));
1329
1330ERROR_AND_FREE:
1331 g_strfreev (elements);
1332 return FALSE(0);
1333}
1334
1335static cairo_surface_t *
1336mate_panel_applet_create_foreign_surface_for_display (GdkDisplay *display,
1337 GdkVisual *visual,
1338 Window xid)
1339{
1340 Statusint result = 0;
1341 Window window;
1342 gint x, y;
1343 guint width, height, border, depth;
1344
1345 gdk_x11_display_error_trap_push (display);
1346 result = XGetGeometry (GDK_DISPLAY_XDISPLAY (display)(gdk_x11_display_get_xdisplay (display)), xid, &window,
1347 &x, &y, &width, &height, &border, &depth);
1348 gdk_x11_display_error_trap_pop_ignored (display);
1349
1350 if (result == 0)
1351 return NULL((void*)0);
1352
1353 return cairo_xlib_surface_create (GDK_DISPLAY_XDISPLAY (display)(gdk_x11_display_get_xdisplay (display)),
1354 xid, gdk_x11_visual_get_xvisual (visual),
1355 width, height);
1356}
1357
1358static cairo_pattern_t *
1359mate_panel_applet_get_pattern_from_pixmap (MatePanelApplet *applet,
1360 Window xid,
1361 int x,
1362 int y)
1363{
1364 cairo_surface_t *background;
1365 cairo_surface_t *surface;
1366 GdkWindow *window;
1367 int width;
1368 int height;
1369 GdkDisplay *display;
1370 cairo_t *cr;
1371 cairo_pattern_t *pattern;
1372
1373 g_return_val_if_fail (MATE_PANEL_IS_APPLET (applet), NULL)do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return (((void*)0)); } } while (0)
;
1374
1375 if (!gtk_widget_get_realized (GTK_WIDGET (applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
))
1376 return NULL((void*)0);
1377
1378 window = gtk_widget_get_window (GTK_WIDGET (applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
);
1379 display = gdk_window_get_display (window);
1380
1381 background = mate_panel_applet_create_foreign_surface_for_display (display,
1382 gdk_window_get_visual (window),
1383 xid);
1384
1385 /* background can be NULL if the user changes the background very fast.
1386 * We'll get the next update, so it's not a big deal. */
1387 if (!background || cairo_surface_status (background) != CAIRO_STATUS_SUCCESS) {
1388 if (background)
1389 cairo_surface_destroy (background);
1390 return NULL((void*)0);
1391 }
1392
1393 width = gdk_window_get_width(window);
1394 height = gdk_window_get_height(window);
1395 surface = gdk_window_create_similar_surface (window,
1396 CAIRO_CONTENT_COLOR_ALPHA,
1397 width,
1398 height);
1399 gdk_x11_display_error_trap_push (display);
1400 cr = cairo_create (surface);
1401 cairo_set_source_surface (cr, background, -x, -y);
1402 cairo_rectangle (cr, 0, 0, width, height);
1403 cairo_fill (cr);
1404 gdk_x11_display_error_trap_pop_ignored (display);
1405
1406 cairo_surface_destroy (background);
1407 pattern = NULL((void*)0);
1408
1409 if (cairo_status (cr) == CAIRO_STATUS_SUCCESS) {
1410 pattern = cairo_pattern_create_for_surface (surface);
1411 }
1412
1413 cairo_destroy (cr);
1414 cairo_surface_destroy (surface);
1415
1416 return pattern;
1417}
1418#endif
1419
1420static MatePanelAppletBackgroundType
1421mate_panel_applet_handle_background_string (MatePanelApplet *applet,
1422 GdkRGBA *color,
1423 cairo_pattern_t **pattern)
1424{
1425 MatePanelAppletPrivate *priv;
1426 MatePanelAppletBackgroundType retval;
1427 char **elements;
1428
1429 priv = mate_panel_applet_get_instance_private (applet);
1430 retval = PANEL_NO_BACKGROUND;
1431
1432 if (!gtk_widget_get_realized (GTK_WIDGET (applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
) || !priv->background)
1433 return retval;
1434
1435 elements = g_strsplit (priv->background, ":", -1);
1436
1437 if (elements [0] && !strcmp (elements [0], "none" )) {
1438 retval = PANEL_NO_BACKGROUND;
1439
1440 } else if (elements [0] && !strcmp (elements [0], "color")) {
1441 g_return_val_if_fail (color != NULL, PANEL_NO_BACKGROUND)do { if ((color != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "color != NULL");
return (PANEL_NO_BACKGROUND); } } while (0)
;
1442
1443 if (!elements [1] || !mate_panel_applet_parse_color (elements [1], color)) {
1444
1445 g_warning ("Incomplete '%s' background type received", elements [0]);
1446 g_strfreev (elements);
1447 return PANEL_NO_BACKGROUND;
1448 }
1449
1450 retval = PANEL_COLOR_BACKGROUND;
1451
1452 } else if (elements [0] && !strcmp (elements [0], "pixmap")) {
1453#ifdef HAVE_X111
1454 if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gdk_display_get_default ())); GType __t = ((gdk_x11_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
) {
1455 Window pixmap_id;
1456 int x, y;
1457
1458 g_return_val_if_fail (pattern != NULL, PANEL_NO_BACKGROUND)do { if ((pattern != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "pattern != NULL"
); return (PANEL_NO_BACKGROUND); } } while (0)
;
1459
1460 if (!mate_panel_applet_parse_pixmap_str (elements [1], &pixmap_id, &x, &y)) {
1461 g_warning ("Incomplete '%s' background type received: %s",
1462 elements [0], elements [1]);
1463
1464 g_strfreev (elements);
1465 return PANEL_NO_BACKGROUND;
1466 }
1467
1468 *pattern = mate_panel_applet_get_pattern_from_pixmap (applet, pixmap_id, x, y);
1469 if (!*pattern) {
1470 g_warning ("Failed to get pattern %s", elements [1]);
1471 g_strfreev (elements);
1472 return PANEL_NO_BACKGROUND;
1473 }
1474
1475 retval = PANEL_PIXMAP_BACKGROUND;
1476 } else
1477#endif
1478 { /* not using X11 */
1479 g_warning("Received pixmap background type, which is only supported on X11");
1480 }
1481 } else
1482 g_warning ("Unknown background type received");
1483
1484 g_strfreev (elements);
1485
1486 return retval;
1487}
1488
1489MatePanelAppletBackgroundType
1490mate_panel_applet_get_background (MatePanelApplet *applet,
1491 GdkRGBA *color,
1492 cairo_pattern_t **pattern)
1493{
1494 g_return_val_if_fail (MATE_PANEL_IS_APPLET (applet), PANEL_NO_BACKGROUND)do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return (PANEL_NO_BACKGROUND); } } while (0)
;
1495
1496 /* initial sanity */
1497 if (pattern != NULL((void*)0))
1498 *pattern = NULL((void*)0);
1499
1500 if (color != NULL((void*)0))
1501 memset (color, 0, sizeof (GdkRGBA));
1502
1503 return mate_panel_applet_handle_background_string (applet, color, pattern);
1504}
1505
1506static void
1507mate_panel_applet_set_background_string (MatePanelApplet *applet,
1508 const gchar *background)
1509{
1510 MatePanelAppletPrivate *priv;
1511
1512 priv = mate_panel_applet_get_instance_private (applet);
1513
1514 if (priv->background == background)
1515 return;
1516
1517 if (g_strcmp0 (priv->background, background) == 0)
1518 return;
1519
1520 g_free (priv->background);
1521 priv->background = background ? g_strdup (background)g_strdup_inline (background) : NULL((void*)0);
1522 mate_panel_applet_handle_background (applet);
1523
1524 g_object_notify (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
, "background");
1525}
1526
1527static void
1528mate_panel_applet_handle_background (MatePanelApplet *applet)
1529{
1530 MatePanelAppletBackgroundType type;
1531
1532 GdkRGBA color;
1533 cairo_pattern_t *pattern;
1534
1535 type = mate_panel_applet_get_background (applet, &color, &pattern);
1536
1537 if (!gdk_screen_is_composited (gdk_screen_get_default ())) {
1538 color.alpha = 1.;
1539 }
1540
1541 switch (type) {
1542 case PANEL_NO_BACKGROUND:
1543 g_signal_emit (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
,
1544 mate_panel_applet_signals [CHANGE_BACKGROUND],
1545 0, PANEL_NO_BACKGROUND, NULL((void*)0), NULL((void*)0));
1546 break;
1547 case PANEL_COLOR_BACKGROUND:
1548 g_signal_emit (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
,
1549 mate_panel_applet_signals [CHANGE_BACKGROUND],
1550 0, PANEL_COLOR_BACKGROUND, &color, NULL((void*)0));
1551 break;
1552 case PANEL_PIXMAP_BACKGROUND:
1553 g_signal_emit (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
,
1554 mate_panel_applet_signals [CHANGE_BACKGROUND],
1555
1556 0, PANEL_PIXMAP_BACKGROUND, NULL((void*)0), pattern);
1557
1558 cairo_pattern_destroy (pattern);
1559
1560 break;
1561 default:
1562 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "mate-panel-applet.c"
, 1562, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1563 break;
1564 }
1565}
1566
1567static void
1568mate_panel_applet_realize (GtkWidget *widget)
1569{
1570 MatePanelApplet *applet;
1571 MatePanelAppletPrivate *priv;
1572
1573 GTK_WIDGET_CLASS (mate_panel_applet_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((mate_panel_applet_parent_class)), ((gtk_widget_get_type (
)))))))
->realize (widget);
1574
1575 applet = MATE_PANEL_APPLET (widget);
1576 priv = mate_panel_applet_get_instance_private (applet);
1577 if (priv->background)
1578 mate_panel_applet_handle_background (applet);
1579}
1580
1581static void
1582mate_panel_applet_move_focus_out_of_applet (MatePanelApplet *applet,
1583 GtkDirectionType dir)
1584{
1585 MatePanelAppletPrivate *priv;
1586 GtkWidget *toplevel;
1587
1588 priv = mate_panel_applet_get_instance_private (applet);
1589 priv->moving_focus_out = TRUE(!(0));
1590 toplevel = gtk_widget_get_toplevel (GTK_WIDGET (applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
);
1591 g_return_if_fail (toplevel)do { if ((toplevel)) { } else { g_return_if_fail_warning (((gchar
*) 0), ((const char*) (__func__)), "toplevel"); return; } } while
(0)
;
1592
1593 gtk_widget_child_focus (toplevel, dir);
1594 priv->moving_focus_out = FALSE(0);
1595}
1596
1597static void
1598mate_panel_applet_change_background(MatePanelApplet *applet,
1599 MatePanelAppletBackgroundType type,
1600 GdkRGBA* color,
1601 cairo_pattern_t *pattern)
1602{
1603 MatePanelAppletPrivate *priv;
1604 GdkWindow *window;
1605
1606 priv = mate_panel_applet_get_instance_private (applet);
1607
1608 if (priv->out_of_process)
1609 window = gtk_widget_get_window (GTK_WIDGET (priv->plug)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->plug)), ((gtk_widget_get_type ()))))))
);
1610 else
1611 window = gtk_widget_get_window (GTK_WIDGET (applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
);
1612
1613 gtk_widget_set_app_paintable (GTK_WIDGET (applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
,TRUE(!(0)));
1614
1615 if (priv->out_of_process)
1616 _mate_panel_applet_apply_css (GTK_WIDGET (priv->plug)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->plug)), ((gtk_widget_get_type ()))))))
,type);
1617
1618 switch (type) {
1619 case PANEL_NO_BACKGROUND:
1620 if (priv->out_of_process){
1621 cairo_pattern_t *transparent = cairo_pattern_create_rgba (0, 0, 0, 0); /* Using NULL here breaks transparent */
1622 gdk_window_set_background_pattern (window, transparent); /* backgrounds set by GTK theme */
1623 cairo_pattern_destroy (transparent);
1624 }
1625 break;
1626 case PANEL_COLOR_BACKGROUND:
1627 if (priv->out_of_process){
1628 gdk_window_set_background_rgba(window,color);
1629 gtk_widget_queue_draw (priv->plug); /*change the bg right away always */
1630 }
1631 break;
1632 case PANEL_PIXMAP_BACKGROUND:
1633 if (priv->out_of_process){
1634 gdk_window_set_background_pattern(window,pattern);
1635 gtk_widget_queue_draw (priv->plug); /*change the bg right away always */
1636 }
1637 break;
1638 default:
1639 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "mate-panel-applet.c"
, 1639, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1640 break;
1641 }
1642
1643 if (priv->out_of_process){
1644 GtkStyleContext *context;
1645
1646 context = gtk_widget_get_style_context (GTK_WIDGET (priv->plug)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->plug)), ((gtk_widget_get_type ()))))))
);
1647
1648 if (priv->orient == MATE_PANEL_APPLET_ORIENT_UP ||
1649 priv->orient == MATE_PANEL_APPLET_ORIENT_DOWN)
1650 gtk_style_context_add_class (context, "horizontal");
1651 else
1652 gtk_style_context_add_class (context, "vertical");
1653 }
1654}
1655
1656static void
1657mate_panel_applet_get_property (GObject *object,
1658 guint prop_id,
1659 GValue *value,
1660 GParamSpec *pspec)
1661{
1662 MatePanelApplet *applet;
1663 MatePanelAppletPrivate *priv;
1664
1665 applet = MATE_PANEL_APPLET (object);
1666 priv = mate_panel_applet_get_instance_private (applet);
1667
1668 switch (prop_id) {
1669 case PROP_OUT_OF_PROCESS:
1670 g_value_set_boolean (value, priv->out_of_process);
1671 break;
1672 case PROP_ID:
1673 g_value_set_string (value, priv->id);
1674 break;
1675 case PROP_CLOSURE:
1676 g_value_set_pointer (value, priv->closure);
1677 break;
1678 case PROP_CONNECTION:
1679 g_value_set_object (value, priv->connection);
1680 break;
1681 case PROP_PREFS_PATH:
1682 g_value_set_string (value, priv->prefs_path);
1683 break;
1684 case PROP_ORIENT:
1685 g_value_set_uint (value, priv->orient);
1686 break;
1687 case PROP_SIZE:
1688 g_value_set_uint (value, priv->size);
1689 break;
1690 case PROP_BACKGROUND:
1691 g_value_set_string (value, priv->background);
1692 break;
1693 case PROP_FLAGS:
1694 g_value_set_uint (value, priv->flags);
1695 break;
1696 case PROP_SIZE_HINTS: {
1697 GVariant **children;
1698 GVariant *variant;
1699 gint i;
1700
1701 children = g_new (GVariant *, priv->size_hints_len)((GVariant * *) g_malloc_n ((priv->size_hints_len), sizeof
(GVariant *)))
;
1702 for (i = 0; i < priv->size_hints_len; i++)
1703 children[i] = g_variant_new_int32 (priv->size_hints[i]);
1704 variant = g_variant_new_array (G_VARIANT_TYPE_INT32((const GVariantType *) "i"),
1705 children, priv->size_hints_len);
1706 g_free (children);
1707 g_value_set_pointer (value, variant);
1708 break;
1709 }
1710 case PROP_LOCKED:
1711 g_value_set_boolean (value, priv->locked);
1712 break;
1713 case PROP_LOCKED_DOWN:
1714 g_value_set_boolean (value, priv->locked_down);
1715 break;
1716 default:
1717 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "mate-panel-applet.c", 1717, ("property"), _glib__property_id
, _glib__pspec->name, g_type_name ((((((GTypeClass*) (((GTypeInstance
*) (_glib__pspec))->g_class))->g_type)))), (g_type_name
((((((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
1718 }
1719}
1720
1721static void
1722mate_panel_applet_set_property (GObject *object,
1723 guint prop_id,
1724 const GValue *value,
1725 GParamSpec *pspec)
1726{
1727 MatePanelApplet *applet;
1728 MatePanelAppletPrivate *priv;
1729
1730 applet = MATE_PANEL_APPLET (object);
1731 priv = mate_panel_applet_get_instance_private (applet);
1732
1733 switch (prop_id) {
1734 case PROP_OUT_OF_PROCESS:
1735 priv->out_of_process = g_value_get_boolean (value);
1736 break;
1737 case PROP_ID:
1738 priv->id = g_value_dup_string (value);
1739 break;
1740 case PROP_CLOSURE:
1741 priv->closure = g_value_get_pointer (value);
1742 g_closure_set_marshal (priv->closure,
1743 mate_panel_applet_marshal_BOOLEAN__STRING);
1744 break;
1745 case PROP_CONNECTION:
1746 priv->connection = g_value_dup_object (value);
1747 break;
1748 case PROP_PREFS_PATH:
1749 mate_panel_applet_set_preferences_path (applet, g_value_get_string (value));
1750 break;
1751 case PROP_ORIENT:
1752 mate_panel_applet_set_orient (applet, g_value_get_uint (value));
1753 break;
1754 case PROP_SIZE:
1755 mate_panel_applet_set_size (applet, g_value_get_uint (value));
1756 break;
1757 case PROP_BACKGROUND:
1758 mate_panel_applet_set_background_string (applet, g_value_get_string (value));
1759 break;
1760 case PROP_FLAGS:
1761 mate_panel_applet_set_flags (applet, g_value_get_uint (value));
1762 break;
1763 case PROP_SIZE_HINTS: {
1764 const int *size_hints;
1765 gsize n_elements;
1766
1767 size_hints = g_variant_get_fixed_array (g_value_get_pointer (value),
1768 &n_elements, sizeof (gint32));
1769 mate_panel_applet_set_size_hints (applet, size_hints, n_elements, 0);
1770 }
1771 break;
1772 case PROP_LOCKED:
1773 mate_panel_applet_set_locked (applet, g_value_get_boolean (value));
1774 break;
1775 case PROP_LOCKED_DOWN:
1776 mate_panel_applet_set_locked_down (applet, g_value_get_boolean (value));
1777 break;
1778 default:
1779 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "mate-panel-applet.c", 1779, ("property"), _glib__property_id
, _glib__pspec->name, g_type_name ((((((GTypeClass*) (((GTypeInstance
*) (_glib__pspec))->g_class))->g_type)))), (g_type_name
((((((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
1780 }
1781}
1782
1783static void
1784add_tab_bindings (GtkBindingSet *binding_set,
1785 GdkModifierType modifiers,
1786 GtkDirectionType direction)
1787{
1788 gtk_binding_entry_add_signal (binding_set, GDK_KEY_Tab0xff09, modifiers,
1789 "move_focus_out_of_applet", 1,
1790 GTK_TYPE_DIRECTION_TYPE(gtk_direction_type_get_type ()), direction);
1791 gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Tab0xff89, modifiers,
1792 "move_focus_out_of_applet", 1,
1793 GTK_TYPE_DIRECTION_TYPE(gtk_direction_type_get_type ()), direction);
1794}
1795
1796static void
1797mate_panel_applet_setup (MatePanelApplet *applet)
1798{
1799 MatePanelAppletPrivate *priv;
1800 GValue value = {0, };
1801 GArray *params;
1802 guint i;
1803 gboolean ret;
1804
1805 priv = mate_panel_applet_get_instance_private (applet);
1806
1807 g_assert ((priv->id != NULL) && (priv->closure != NULL))do { if ((priv->id != ((void*)0)) && (priv->closure
!= ((void*)0))) ; else g_assertion_message_expr (((gchar*) 0
), "mate-panel-applet.c", 1807, ((const char*) (__func__)), "(priv->id != NULL) && (priv->closure != NULL)"
); } while (0)
;
1808
1809 params = g_array_sized_new (FALSE(0), TRUE(!(0)), sizeof (GValue), 2);
1810 value.g_type = 0;
1811 g_value_init (&value, G_TYPE_OBJECT((GType) ((20) << (2))));
1812 g_value_set_object (&value, G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
);
1813 g_array_append_val (params, value)g_array_append_vals (params, &(value), 1);
1814
1815 value.g_type = 0;
1816 g_value_init (&value, G_TYPE_STRING((GType) ((16) << (2))));
1817 g_value_set_string (&value, priv->id);
1818 g_array_append_val (params, value)g_array_append_vals (params, &(value), 1);
1819
1820 value.g_type = 0;
1821 g_value_init (&value, G_TYPE_BOOLEAN((GType) ((5) << (2))));
1822
1823 g_closure_invoke (priv->closure,
1824 &value, params->len,
1825 (GValue *) params->data,
Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption
1826 NULL((void*)0));
1827
1828 for (i = 0; i < params->len; i++)
1829 g_value_unset (&g_array_index (params, GValue, i)(((GValue*) (void *) (params)->data) [(i)]));
1830 g_array_free (params, TRUE(!(0)));
1831
1832 ret = g_value_get_boolean (&value);
1833 g_value_unset (&value);
1834
1835 if (!ret) { /* FIXME */
1836 g_warning ("need to free the control here");
1837
1838 return;
1839 }
1840}
1841
1842void _mate_panel_applet_apply_css(GtkWidget* widget, MatePanelAppletBackgroundType type)
1843{
1844 GtkStyleContext* context;
1845
1846 context = gtk_widget_get_style_context (widget);
1847
1848 switch (type) {
1849 case PANEL_NO_BACKGROUND:
1850 gtk_style_context_remove_class (context, "mate-custom-panel-background");
1851 break;
1852 case PANEL_COLOR_BACKGROUND:
1853 case PANEL_PIXMAP_BACKGROUND:
1854 gtk_style_context_add_class (context, "mate-custom-panel-background");
1855 break;
1856 default:
1857 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "mate-panel-applet.c"
, 1857, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1858 break;
1859 }
1860}
1861
1862#ifdef HAVE_X111
1863static void _mate_panel_applet_prepare_css (GtkStyleContext *context)
1864{
1865 GtkCssProvider *provider;
1866
1867 g_return_if_fail (GDK_IS_X11_DISPLAY (gdk_display_get_default ()))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((gdk_display_get_default ())); GType __t = ((gdk_x11_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0
), ((const char*) (__func__)), "GDK_IS_X11_DISPLAY (gdk_display_get_default ())"
); return; } } while (0)
;
1868 provider = gtk_css_provider_new ();
1869 gtk_css_provider_load_from_data (provider,
1870 "#PanelPlug {\n"
1871 " background-repeat: no-repeat;\n" /*disable in gtk theme features */
1872 " background-size: cover; " /*that don't work on panel-toplevel */
1873 " }\n"
1874 ".mate-custom-panel-background{\n" /*prepare CSS for user set theme */
1875 " background-color: rgba (0, 0, 0, 0);\n"
1876 " background-image: none;\n"
1877 "}",
1878 -1, NULL((void*)0));
1879
1880 gtk_style_context_add_provider (context,
1881 GTK_STYLE_PROVIDER (provider)((((GtkStyleProvider*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((provider)), ((gtk_style_provider_get_type (
)))))))
,
1882 GTK_STYLE_PROVIDER_PRIORITY_APPLICATION600);
1883 g_object_unref (provider);
1884}
1885#endif /* HAVE_X11 */
1886
1887static void
1888mate_panel_applet_init (MatePanelApplet *applet)
1889{
1890 MatePanelAppletPrivate *priv;
1891
1892 priv = mate_panel_applet_get_instance_private (applet);
1893
1894 priv->flags = MATE_PANEL_APPLET_FLAGS_NONE;
1895 priv->orient = MATE_PANEL_APPLET_ORIENT_UP;
1896 priv->size = 24;
1897
1898 priv->panel_action_group = gtk_action_group_new ("PanelActions");
1899 gtk_action_group_set_translation_domain (priv->panel_action_group, GETTEXT_PACKAGE"mate-panel");
1900 gtk_action_group_add_actions (priv->panel_action_group,
1901 menu_entries,
1902 G_N_ELEMENTS (menu_entries)(sizeof (menu_entries) / sizeof ((menu_entries)[0])),
1903 applet);
1904 gtk_action_group_add_toggle_actions (priv->panel_action_group,
1905 menu_toggle_entries,
1906 G_N_ELEMENTS (menu_toggle_entries)(sizeof (menu_toggle_entries) / sizeof ((menu_toggle_entries)
[0]))
,
1907 applet);
1908
1909 priv->ui_manager = gtk_ui_manager_new ();
1910 gtk_ui_manager_insert_action_group (priv->ui_manager,
1911 priv->panel_action_group, 1);
1912 gtk_ui_manager_add_ui_from_string (priv->ui_manager,
1913 panel_menu_ui, -1, NULL((void*)0));
1914
1915 gtk_widget_set_events (GTK_WIDGET (applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
,
1916 GDK_BUTTON_PRESS_MASK |
1917 GDK_BUTTON_RELEASE_MASK);
1918}
1919
1920static GObject *
1921mate_panel_applet_constructor (GType type,
1922 guint n_construct_properties,
1923 GObjectConstructParam *construct_properties)
1924{
1925 GObject *object;
1926 MatePanelApplet *applet;
1927 MatePanelAppletPrivate *priv;
1928
1929 object = G_OBJECT_CLASS (mate_panel_applet_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((mate_panel_applet_parent_class)), (((GType) ((20) <<
(2))))))))
->constructor (type,
1930 n_construct_properties,
1931 construct_properties);
1932 applet = MATE_PANEL_APPLET (object);
1933 priv = mate_panel_applet_get_instance_private (applet);
1934
1935 if (!priv->out_of_process)
1936 return object;
1937
1938#ifdef HAVE_X111
1939 if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gdk_display_get_default ())); GType __t = ((gdk_x11_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
)
1940 {
1941 GtkStyleContext *context;
1942 GtkWidget *widget;
1943
1944 priv->plug = gtk_plug_new (0);
1945 widget = GTK_WIDGET (priv->plug)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->plug)), ((gtk_widget_get_type ()))))))
;
1946 gtk_widget_set_visual (widget,
1947 gdk_screen_get_rgba_visual (gtk_widget_get_screen (widget)));
1948 context = gtk_widget_get_style_context (widget);
1949 gtk_style_context_add_class (context, "gnome-panel-menu-bar");
1950 gtk_style_context_add_class (context, "mate-panel-menu-bar");
1951 gtk_widget_set_name (widget, "PanelPlug");
1952 _mate_panel_applet_prepare_css (context);
1953
1954 g_signal_connect_swapped (priv->plug, "embedded",g_signal_connect_data ((priv->plug), ("embedded"), (((GCallback
) (mate_panel_applet_setup))), (applet), ((void*)0), G_CONNECT_SWAPPED
)
1955 G_CALLBACK (mate_panel_applet_setup),g_signal_connect_data ((priv->plug), ("embedded"), (((GCallback
) (mate_panel_applet_setup))), (applet), ((void*)0), G_CONNECT_SWAPPED
)
1956 applet)g_signal_connect_data ((priv->plug), ("embedded"), (((GCallback
) (mate_panel_applet_setup))), (applet), ((void*)0), G_CONNECT_SWAPPED
)
;
1957
1958 gtk_container_add (GTK_CONTAINER (priv->plug)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->plug)), ((gtk_container_get_type ()))))))
, GTK_WIDGET (applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
);
1959 } else
1960#endif
1961 { /* not using X11 */
1962 g_warning ("Requested construction of an out-of-process applet, which is only possible on X11");
1963 }
1964
1965 return object;
1966}
1967
1968static void
1969mate_panel_applet_constructed (GObject* object)
1970{
1971 MatePanelApplet* applet = MATE_PANEL_APPLET(object);
1972
1973 /* Rename the class to have compatibility with all GTK2 themes
1974 * https://github.com/perberos/Mate-Desktop-Environment/issues/27
1975 */
1976 gtk_widget_set_name(GTK_WIDGET(applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
, "PanelApplet");
1977
1978 mate_panel_applet_register_object (applet);
1979}
1980
1981static void
1982mate_panel_applet_class_init (MatePanelAppletClass *klass)
1983{
1984 GObjectClass *gobject_class = (GObjectClass *) klass;
1985 GtkWidgetClass *widget_class = (GtkWidgetClass *) klass;
1986 GtkBindingSet *binding_set;
1987
1988 gobject_class->get_property = mate_panel_applet_get_property;
1989 gobject_class->set_property = mate_panel_applet_set_property;
1990 gobject_class->constructor = mate_panel_applet_constructor;
1991 gobject_class->constructed = mate_panel_applet_constructed;
1992 klass->move_focus_out_of_applet = mate_panel_applet_move_focus_out_of_applet;
1993 klass->change_background = mate_panel_applet_change_background;
1994 widget_class->button_press_event = mate_panel_applet_button_press;
1995 widget_class->button_release_event = mate_panel_applet_button_release;
1996 widget_class->get_request_mode = mate_panel_applet_get_request_mode;
1997 widget_class->get_preferred_width = mate_panel_applet_get_preferred_width;
1998 widget_class->get_preferred_height = mate_panel_applet_get_preferred_height;
1999 widget_class->draw = mate_panel_applet_draw;
2000 widget_class->size_allocate = mate_panel_applet_size_allocate;
2001 widget_class->focus = mate_panel_applet_focus;
2002 widget_class->realize = mate_panel_applet_realize;
2003 widget_class->key_press_event = mate_panel_applet_key_press_event;
2004
2005 gobject_class->finalize = mate_panel_applet_finalize;
2006
2007 g_object_class_install_property (gobject_class,
2008 PROP_OUT_OF_PROCESS,
2009 g_param_spec_boolean ("out-of-process",
2010 "out-of-process",
2011 "out-of-process",
2012 TRUE(!(0)),
2013 G_PARAM_CONSTRUCT_ONLY |
2014 G_PARAM_READWRITE));
2015 g_object_class_install_property (gobject_class,
2016 PROP_ID,
2017 g_param_spec_string ("id",
2018 "Id",
2019 "The Applet identifier",
2020 NULL((void*)0),
2021 G_PARAM_CONSTRUCT_ONLY |
2022 G_PARAM_READWRITE));
2023 g_object_class_install_property (gobject_class,
2024 PROP_CLOSURE,
2025 g_param_spec_pointer ("closure",
2026 "GClosure",
2027 "The Applet closure",
2028 G_PARAM_CONSTRUCT_ONLY |
2029 G_PARAM_READWRITE));
2030 g_object_class_install_property (gobject_class,
2031 PROP_CONNECTION,
2032 g_param_spec_object ("connection",
2033 "Connection",
2034 "The DBus Connection",
2035 G_TYPE_DBUS_CONNECTION(g_dbus_connection_get_type ()),
2036 G_PARAM_CONSTRUCT_ONLY |
2037 G_PARAM_READWRITE));
2038 g_object_class_install_property (gobject_class,
2039 PROP_PREFS_PATH,
2040 g_param_spec_string ("prefs-path",
2041 "PrefsPath",
2042 "GSettings Preferences Path",
2043 NULL((void*)0),
2044 G_PARAM_READWRITE));
2045 g_object_class_install_property (gobject_class,
2046 PROP_ORIENT,
2047 g_param_spec_uint ("orient",
2048 "Orient",
2049 "Panel Applet Orientation",
2050 MATE_PANEL_APPLET_ORIENT_FIRSTMATE_PANEL_APPLET_ORIENT_UP,
2051 MATE_PANEL_APPLET_ORIENT_LASTMATE_PANEL_APPLET_ORIENT_RIGHT,
2052 MATE_PANEL_APPLET_ORIENT_UP,
2053 G_PARAM_READWRITE));
2054 g_object_class_install_property (gobject_class,
2055 PROP_SIZE,
2056 g_param_spec_uint ("size",
2057 "Size",
2058 "Panel Applet Size",
2059 0, G_MAXUINT(2147483647 *2U +1U), 0,
2060 G_PARAM_READWRITE));
2061 g_object_class_install_property (gobject_class,
2062 PROP_BACKGROUND,
2063 g_param_spec_string ("background",
2064 "Background",
2065 "Panel Applet Background",
2066 NULL((void*)0),
2067 G_PARAM_READWRITE));
2068 g_object_class_install_property (gobject_class,
2069 PROP_FLAGS,
2070 g_param_spec_uint ("flags",
2071 "Flags",
2072 "Panel Applet flags",
2073 MATE_PANEL_APPLET_FLAGS_NONE,
2074 MATE_PANEL_APPLET_FLAGS_ALL(MATE_PANEL_APPLET_EXPAND_MAJOR|MATE_PANEL_APPLET_EXPAND_MINOR
|MATE_PANEL_APPLET_HAS_HANDLE)
,
2075 MATE_PANEL_APPLET_FLAGS_NONE,
2076 G_PARAM_READWRITE));
2077 g_object_class_install_property (gobject_class,
2078 PROP_SIZE_HINTS,
2079 /* FIXME: value_array? */
2080 g_param_spec_pointer ("size-hints",
2081 "SizeHints",
2082 "Panel Applet Size Hints",
2083 G_PARAM_READWRITE));
2084 g_object_class_install_property (gobject_class,
2085 PROP_LOCKED,
2086 g_param_spec_boolean ("locked",
2087 "Locked",
2088 "Whether Panel Applet is locked",
2089 FALSE(0),
2090 G_PARAM_READWRITE));
2091 g_object_class_install_property (gobject_class,
2092 PROP_LOCKED_DOWN,
2093 g_param_spec_boolean ("locked-down",
2094 "LockedDown",
2095 "Whether Panel Applet is locked down",
2096 FALSE(0),
2097 G_PARAM_READWRITE));
2098
2099 mate_panel_applet_signals [CHANGE_ORIENT] =
2100 g_signal_new ("change-orient",
2101 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2102 G_SIGNAL_RUN_LAST,
2103 G_STRUCT_OFFSET (MatePanelAppletClass, change_orient)((glong) __builtin_offsetof(MatePanelAppletClass, change_orient
))
,
2104 NULL((void*)0),
2105 NULL((void*)0),
2106 mate_panel_applet_marshal_VOID__UINTg_cclosure_marshal_VOID__UINT,
2107 G_TYPE_NONE((GType) ((1) << (2))),
2108 1,
2109 G_TYPE_UINT((GType) ((7) << (2))));
2110
2111 mate_panel_applet_signals [CHANGE_SIZE] =
2112 g_signal_new ("change-size",
2113 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2114 G_SIGNAL_RUN_LAST,
2115 G_STRUCT_OFFSET (MatePanelAppletClass, change_size)((glong) __builtin_offsetof(MatePanelAppletClass, change_size
))
,
2116 NULL((void*)0),
2117 NULL((void*)0),
2118 mate_panel_applet_marshal_VOID__INTg_cclosure_marshal_VOID__INT,
2119 G_TYPE_NONE((GType) ((1) << (2))),
2120 1,
2121 G_TYPE_INT((GType) ((6) << (2))));
2122
2123 mate_panel_applet_signals [CHANGE_BACKGROUND] =
2124 g_signal_new ("change-background",
2125 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2126 G_SIGNAL_RUN_LAST,
2127 G_STRUCT_OFFSET (MatePanelAppletClass, change_background)((glong) __builtin_offsetof(MatePanelAppletClass, change_background
))
,
2128 NULL((void*)0),
2129 NULL((void*)0),
2130 mate_panel_applet_marshal_VOID__ENUM_BOXED_OBJECT,
2131 G_TYPE_NONE((GType) ((1) << (2))),
2132 3,
2133 PANEL_TYPE_MATE_PANEL_APPLET_BACKGROUND_TYPEmate_panel_applet_background_type_get_type(),
2134 GDK_TYPE_RGBA(gdk_rgba_get_type ()),
2135 CAIRO_GOBJECT_TYPE_PATTERNcairo_gobject_pattern_get_type ());
2136
2137 mate_panel_applet_signals [MOVE_FOCUS_OUT_OF_APPLET] =
2138 g_signal_new ("move_focus_out_of_applet",
2139 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2140 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
2141 G_STRUCT_OFFSET (MatePanelAppletClass, move_focus_out_of_applet)((glong) __builtin_offsetof(MatePanelAppletClass, move_focus_out_of_applet
))
,
2142 NULL((void*)0),
2143 NULL((void*)0),
2144 mate_panel_applet_marshal_VOID__ENUMg_cclosure_marshal_VOID__ENUM,
2145 G_TYPE_NONE((GType) ((1) << (2))),
2146 1,
2147 GTK_TYPE_DIRECTION_TYPE(gtk_direction_type_get_type ()));
2148
2149 binding_set = gtk_binding_set_by_class (gobject_class);
2150 add_tab_bindings (binding_set, 0, GTK_DIR_TAB_FORWARD);
2151 add_tab_bindings (binding_set, GDK_SHIFT_MASK, GTK_DIR_TAB_BACKWARD);
2152 add_tab_bindings (binding_set, GDK_CONTROL_MASK, GTK_DIR_TAB_FORWARD);
2153 add_tab_bindings (binding_set, GDK_CONTROL_MASK | GDK_SHIFT_MASK, GTK_DIR_TAB_BACKWARD);
2154
2155 gtk_widget_class_set_css_name (widget_class, "PanelApplet");
2156}
2157
2158GtkWidget* mate_panel_applet_new(void)
2159{
2160 MatePanelApplet* applet = g_object_new(PANEL_TYPE_APPLETmate_panel_applet_get_type (), NULL((void*)0));
2161
2162 return GTK_WIDGET(applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
;
2163}
2164
2165static GdkEvent *
2166button_press_event_new (MatePanelApplet *applet,
2167 guint button,
2168 guint time)
2169{
2170 GdkDisplay *display;
2171 GdkSeat *seat;
2172 GdkDevice *device;
2173 GdkEvent *event;
2174
2175 display = gdk_display_get_default ();
2176 seat = gdk_display_get_default_seat (display);
2177 device = gdk_seat_get_pointer (seat);
2178
2179 event = gdk_event_new (GDK_BUTTON_PRESS);
2180
2181 event->button.time = time;
2182 event->button.button = button;
2183
2184 gdk_event_set_device (event, device);
2185
2186 return event;
2187}
2188
2189static void
2190method_call_cb (GDBusConnection *connection,
2191 const gchar *sender,
2192 const gchar *object_path,
2193 const gchar *interface_name,
2194 const gchar *method_name,
2195 GVariant *parameters,
2196 GDBusMethodInvocation *invocation,
2197 gpointer user_data)
2198{
2199 MatePanelApplet *applet = MATE_PANEL_APPLET (user_data);
2200
2201 if (g_strcmp0 (method_name, "PopupMenu") == 0) {
2202 guint button;
2203 guint time;
2204
2205 g_variant_get (parameters, "(uu)", &button, &time);
2206
2207 GdkEvent *event = button_press_event_new (applet, button, time);
2208 mate_panel_applet_menu_popup (applet, event);
2209 gdk_event_free (event);
2210
2211 g_dbus_method_invocation_return_value (invocation, NULL((void*)0));
2212 }
2213}
2214
2215static GVariant *
2216get_property_cb (GDBusConnection *connection,
2217 const gchar *sender,
2218 const gchar *object_path,
2219 const gchar *interface_name,
2220 const gchar *property_name,
2221 GError **error,
2222 gpointer user_data)
2223{
2224 MatePanelAppletPrivate *priv;
2225 GVariant *retval = NULL((void*)0);
2226
2227 priv = mate_panel_applet_get_instance_private (MATE_PANEL_APPLET (user_data));
2228
2229 if (g_strcmp0 (property_name, "PrefsPath") == 0) {
2230 retval = g_variant_new_string (priv->prefs_path ? priv->prefs_path : "");
2231 } else if (g_strcmp0 (property_name, "Orient") == 0) {
2232 retval = g_variant_new_uint32 (priv->orient);
2233 } else if (g_strcmp0 (property_name, "Size") == 0) {
2234 retval = g_variant_new_uint32 (priv->size);
2235 } else if (g_strcmp0 (property_name, "Background") == 0) {
2236 retval = g_variant_new_string (priv->background ? priv->background : "");
2237 } else if (g_strcmp0 (property_name, "Flags") == 0) {
2238 retval = g_variant_new_uint32 (priv->flags);
2239 } else if (g_strcmp0 (property_name, "SizeHints") == 0) {
2240 GVariant **children;
2241 gint i;
2242
2243 children = g_new (GVariant *, priv->size_hints_len)((GVariant * *) g_malloc_n ((priv->size_hints_len), sizeof
(GVariant *)))
;
2244 for (i = 0; i < priv->size_hints_len; i++)
2245 children[i] = g_variant_new_int32 (priv->size_hints[i]);
2246 retval = g_variant_new_array (G_VARIANT_TYPE_INT32((const GVariantType *) "i"),
2247 children, priv->size_hints_len);
2248 g_free (children);
2249 } else if (g_strcmp0 (property_name, "Locked") == 0) {
2250 retval = g_variant_new_boolean (priv->locked);
2251 } else if (g_strcmp0 (property_name, "LockedDown") == 0) {
2252 retval = g_variant_new_boolean (priv->locked_down);
2253 }
2254
2255 return retval;
2256}
2257
2258static gboolean
2259set_property_cb (GDBusConnection *connection,
2260 const gchar *sender,
2261 const gchar *object_path,
2262 const gchar *interface_name,
2263 const gchar *property_name,
2264 GVariant *value,
2265 GError **error,
2266 gpointer user_data)
2267{
2268 MatePanelApplet *applet = MATE_PANEL_APPLET (user_data);
2269
2270 if (g_strcmp0 (property_name, "PrefsPath") == 0) {
2271 mate_panel_applet_set_preferences_path (applet, g_variant_get_string (value, NULL((void*)0)));
2272 } else if (g_strcmp0 (property_name, "Orient") == 0) {
2273 mate_panel_applet_set_orient (applet, g_variant_get_uint32 (value));
2274 } else if (g_strcmp0 (property_name, "Size") == 0) {
2275 mate_panel_applet_set_size (applet, g_variant_get_uint32 (value));
2276 } else if (g_strcmp0 (property_name, "Background") == 0) {
2277 mate_panel_applet_set_background_string (applet, g_variant_get_string (value, NULL((void*)0)));
2278 } else if (g_strcmp0 (property_name, "Flags") == 0) {
2279 mate_panel_applet_set_flags (applet, g_variant_get_uint32 (value));
2280 } else if (g_strcmp0 (property_name, "SizeHints") == 0) {
2281 const int *size_hints;
2282 gsize n_elements;
2283
2284 size_hints = g_variant_get_fixed_array (value, &n_elements, sizeof (gint32));
2285 mate_panel_applet_set_size_hints (applet, size_hints, n_elements, 0);
2286 } else if (g_strcmp0 (property_name, "Locked") == 0) {
2287 mate_panel_applet_set_locked (applet, g_variant_get_boolean (value));
2288 } else if (g_strcmp0 (property_name, "LockedDown") == 0) {
2289 mate_panel_applet_set_locked_down (applet, g_variant_get_boolean (value));
2290 }
2291
2292 return TRUE(!(0));
2293}
2294
2295static const gchar introspection_xml[] =
2296 "<node>"
2297 "<interface name='org.mate.panel.applet.Applet'>"
2298 "<method name='PopupMenu'>"
2299 "<arg name='button' type='u' direction='in'/>"
2300 "<arg name='time' type='u' direction='in'/>"
2301 "</method>"
2302 "<property name='PrefsPath' type='s' access='readwrite'/>"
2303 "<property name='Orient' type='u' access='readwrite' />"
2304 "<property name='Size' type='u' access='readwrite'/>"
2305 "<property name='Background' type='s' access='readwrite'/>"
2306 "<property name='Flags' type='u' access='readwrite'/>"
2307 "<property name='SizeHints' type='ai' access='readwrite'/>"
2308 "<property name='Locked' type='b' access='readwrite'/>"
2309 "<property name='LockedDown' type='b' access='readwrite'/>"
2310 "<signal name='Move' />"
2311 "<signal name='RemoveFromPanel' />"
2312 "<signal name='Lock' />"
2313 "<signal name='Unlock' />"
2314 "</interface>"
2315 "</node>";
2316
2317static const GDBusInterfaceVTable interface_vtable = {
2318 method_call_cb,
2319 get_property_cb,
2320 set_property_cb,
2321 { 0 }
2322};
2323
2324static GDBusNodeInfo *introspection_data = NULL((void*)0);
2325
2326static void
2327mate_panel_applet_register_object (MatePanelApplet *applet)
2328{
2329 MatePanelAppletPrivate *priv;
2330 GError *error = NULL((void*)0);
2331 static gint id = 0;
2332
2333 if (!introspection_data)
2334 introspection_data = g_dbus_node_info_new_for_xml (introspection_xml, NULL((void*)0));
2335
2336 priv = mate_panel_applet_get_instance_private (applet);
2337 priv->object_path = g_strdup_printf (MATE_PANEL_APPLET_OBJECT_PATH"/org/mate/panel/applet/%s/%d", priv->id, id++);
2338 priv->object_id =
2339 g_dbus_connection_register_object (priv->connection,
2340 priv->object_path,
2341 introspection_data->interfaces[0],
2342 &interface_vtable,
2343 applet, NULL((void*)0),
2344 &error);
2345 if (!priv->object_id) {
2346 g_printerr ("Failed to register object %s: %s\n", priv->object_path, error->message);
2347 g_error_free (error);
2348 }
2349}
2350
2351static void mate_panel_applet_factory_main_finalized(gpointer data, GObject* object)
2352{
2353 gtk_main_quit();
2354
2355 if (introspection_data)
2356 {
2357 g_dbus_node_info_unref(introspection_data);
2358 introspection_data = NULL((void*)0);
2359 }
2360}
2361
2362#ifdef HAVE_X111
2363static int (*_x_error_func) (Display *, XErrorEvent *);
2364
2365static int
2366_x_error_handler (Display *display, XErrorEvent *error)
2367{
2368 if (!error->error_code)
2369 return 0;
2370
2371 /* If we got a BadDrawable or a BadWindow, we ignore it for now.
2372 * FIXME: We need to somehow distinguish real errors from
2373 * X-server-induced errors. Keeping a list of windows for which we
2374 * will ignore BadDrawables would be a good idea. */
2375 if (error->error_code == BadDrawable9 ||
2376 error->error_code == BadWindow3)
2377 return 0;
2378
2379 return _x_error_func (display, error);
2380}
2381
2382/*
2383 * To do graphical embedding in the X window system, MATE Panel
2384 * uses the classic foreign-window-reparenting trick. The
2385 * GtkPlug/GtkSocket widgets are used for this purpose. However,
2386 * serious robustness problems arise if the GtkSocket end of the
2387 * connection unexpectedly dies. The X server sends out DestroyNotify
2388 * events for the descendants of the GtkPlug (i.e., your embedded
2389 * component's windows) in effectively random order. Furthermore, if
2390 * you happened to be drawing on any of those windows when the
2391 * GtkSocket was destroyed (a common state of affairs), an X error
2392 * will kill your application.
2393 *
2394 * To solve this latter problem, MATE Panel sets up its own X error
2395 * handler which ignores certain X errors that might have been
2396 * caused by such a scenario. Other X errors get passed to gdk_x_error
2397 * normally.
2398 */
2399static void
2400_mate_panel_applet_setup_x_error_handler (void)
2401{
2402 static gboolean error_handler_setup = FALSE(0);
2403
2404 if (error_handler_setup)
2405 return;
2406
2407 error_handler_setup = TRUE(!(0));
2408
2409 _x_error_func = XSetErrorHandler (_x_error_handler);
2410}
2411#endif
2412
2413static int
2414_mate_panel_applet_factory_main_internal (const gchar *factory_id,
2415 gboolean out_process,
2416 GType applet_type,
2417 MatePanelAppletFactoryCallback callback,
2418 gpointer user_data)
2419{
2420 MatePanelAppletFactory* factory;
2421 GClosure* closure;
2422
2423 g_return_val_if_fail(factory_id != NULL, 1)do { if ((factory_id != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "factory_id != NULL"
); return (1); } } while (0)
;
2424 g_return_val_if_fail(callback != NULL, 1)do { if ((callback != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "callback != NULL"
); return (1); } } while (0)
;
2425 g_assert(g_type_is_a(applet_type, PANEL_TYPE_APPLET))do { if (((applet_type) == (mate_panel_applet_get_type ()) ||
(g_type_is_a) ((applet_type), (mate_panel_applet_get_type ()
)))) ; else g_assertion_message_expr (((gchar*) 0), "mate-panel-applet.c"
, 2425, ((const char*) (__func__)), "g_type_is_a(applet_type, PANEL_TYPE_APPLET)"
); } while (0)
;
2426
2427#ifdef HAVE_X111
2428 if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gdk_display_get_default ())); GType __t = ((gdk_x11_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
) {
2429 /*Use this both in and out of process as the tray applet always uses GtkSocket
2430 *to handle GtkStatusIcons whether the tray itself is built in or out of process
2431 */
2432 _mate_panel_applet_setup_x_error_handler();
2433 } else
2434#endif
2435 { /* not using X11 */
2436 if (out_process) {
2437 g_warning("Requested out-of-process applet, which is only supported on X11");
2438 return 1;
2439 }
2440 }
2441
2442 closure = g_cclosure_new(G_CALLBACK(callback)((GCallback) (callback)), user_data, NULL((void*)0));
2443 factory = mate_panel_applet_factory_new(factory_id, out_process, applet_type, closure);
2444 g_closure_unref(closure);
2445
2446 if (mate_panel_applet_factory_register_service(factory))
2447 {
2448 if (out_process)
2449 {
2450 g_object_weak_ref(G_OBJECT(factory)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((factory)), (((GType) ((20) << (2))))))))
, mate_panel_applet_factory_main_finalized, NULL((void*)0));
2451 gtk_main();
2452 }
2453
2454 return 0;
2455 }
2456
2457 g_object_unref (factory);
2458
2459 return 1;
2460}
2461
2462/**
2463 * mate_panel_applet_factory_main:
2464 * @out_process: boolean, dummy to support applets sending it
2465 * @factory_id: Factory ID.
2466 * @applet_type: GType of the applet this factory creates.
2467 * @callback: (scope call): Callback to be called when a new applet is to be created.
2468 * @data: (closure): Callback data.
2469 *
2470 * Returns: 0 on success, 1 if there is an error.
2471 */
2472int
2473mate_panel_applet_factory_main (const gchar *factory_id,
2474 gboolean out_process, /*Dummy to support applets w issues with this */
2475 GType applet_type,
2476 MatePanelAppletFactoryCallback callback,
2477 gpointer user_data)
2478{
2479 return _mate_panel_applet_factory_main_internal (factory_id, TRUE(!(0)), applet_type,
2480 callback, user_data);
2481}
2482
2483/**
2484 * mate_panel_applet_factory_setup_in_process: (skip)
2485 * @factory_id: Factory ID.
2486 * @applet_type: GType of the applet this factory creates.
2487 * @callback: (scope call): Callback to be called when a new applet is to be created.
2488 * @data: (closure): Callback data.
2489 *
2490 * Returns: 0 on success, 1 if there is an error.
2491 */
2492int
2493mate_panel_applet_factory_setup_in_process (const gchar *factory_id,
2494 GType applet_type,
2495 MatePanelAppletFactoryCallback callback,
2496 gpointer user_data)
2497{
2498 return _mate_panel_applet_factory_main_internal (factory_id, FALSE(0), applet_type,
2499 callback, user_data);
2500}
2501
2502/**
2503 * mate_panel_applet_set_background_widget:
2504 * @applet: a #PanelApplet.
2505 * @widget: a #GtkWidget.
2506 *
2507 * Configure #PanelApplet to automatically draw the background of the applet on
2508 * @widget. It is generally enough to call this function with @applet as
2509 * @widget.
2510 *
2511 * Deprecated: 3.20: Do not use this API. Since 3.20 this function does nothing.
2512 **/
2513
2514void
2515mate_panel_applet_set_background_widget (MatePanelApplet *applet,
2516 GtkWidget *widget)
2517{
2518}
2519
2520guint32
2521mate_panel_applet_get_xid (MatePanelApplet *applet,
2522 GdkScreen *screen)
2523{
2524 MatePanelAppletPrivate *priv;
2525
2526 priv = mate_panel_applet_get_instance_private (applet);
2527
2528 /* out_of_process should only be true on X11, so an extra runtime Wayland check is not needed */
2529 if (priv->out_of_process == FALSE(0))
2530 return 0;
2531
2532#ifdef HAVE_X111
2533 gtk_window_set_screen (GTK_WINDOW (priv->plug)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->plug)), ((gtk_window_get_type ()))))))
, screen);
2534 gtk_widget_show (priv->plug);
2535
2536 return gtk_plug_get_id (GTK_PLUG (priv->plug)((((GtkPlug*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->plug)), ((gtk_plug_get_type ()))))))
);
2537#else
2538 return 0;
2539#endif
2540}
2541
2542const gchar *
2543mate_panel_applet_get_object_path (MatePanelApplet *applet)
2544{
2545 MatePanelAppletPrivate *priv;
2546
2547 priv = mate_panel_applet_get_instance_private (applet);
2548
2549 return priv->object_path;
2550}
2551
2552G_MODULE_EXPORT__attribute__((visibility("default"))) GtkWidget *
2553mate_panel_applet_get_applet_widget (const gchar *factory_id,
2554 guint uid)
2555{
2556 GtkWidget *widget;
2557
2558 widget = mate_panel_applet_factory_get_applet_widget (factory_id, uid);
2559 if (!widget) {
2560 return NULL((void*)0);
2561 }
2562
2563 mate_panel_applet_setup (MATE_PANEL_APPLET (widget));
2564
2565 return widget;
2566}
diff --git a/2024-06-18-172109-13286-1@e182420b844f_master/report-b8f564.html b/2024-06-18-172109-13286-1@e182420b844f_master/report-b8f564.html new file mode 100644 index 00000000..f10e2dd6 --- /dev/null +++ b/2024-06-18-172109-13286-1@e182420b844f_master/report-b8f564.html @@ -0,0 +1,2089 @@ + + + +eggsmclient-xsmp.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:mate-panel/mate-submodules/libegg/eggsmclient-xsmp.c
Warning:line 1199, column 18
Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name eggsmclient-xsmp.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/mate-panel/mate-submodules/libegg -fcoverage-compilation-dir=/rootdir/mate-panel/mate-submodules/libegg -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I ../../.. -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/uuid -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/gio-unix-2.0 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -D EGG_SM_CLIENT_BACKEND_XSMP -D G_LOG_DOMAIN="EggSMClient" -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/uuid -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/gio-unix-2.0 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -D PIC -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-18-172109-13286-1 -x c eggsmclient-xsmp.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * Copyright (C) 2007 Novell, Inc.
3 *
4 * Inspired by various other pieces of code including GsmClient (C)
5 * 2001 Havoc Pennington, MateClient (C) 1998 Carsten Schaar, and twm
6 * session code (C) 1998 The Open Group.
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
17 *
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the
20 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22 */
23
24#include "config.h"
25
26#include "eggsmclient.h"
27#include "eggsmclient-private.h"
28
29#include "eggdesktopfile.h"
30
31#include <errno(*__errno_location ()).h>
32#include <fcntl.h>
33#include <stdlib.h>
34#include <string.h>
35#include <unistd.h>
36#include <X11/SM/SMlib.h>
37
38#include <gtk/gtk.h>
39#include <gdk/gdk.h>
40
41#if defined(GDK_WINDOWING_X11) || defined(HAVE_X111)
42#include <gdk/gdkx.h>
43#endif
44
45#define EGG_TYPE_SM_CLIENT_XSMP(egg_sm_client_xsmp_get_type ()) (egg_sm_client_xsmp_get_type ())
46#define EGG_SM_CLIENT_XSMP(obj)((((EggSMClientXSMP*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((obj)), ((egg_sm_client_xsmp_get_type ()))))))
(G_TYPE_CHECK_INSTANCE_CAST ((obj), EGG_TYPE_SM_CLIENT_XSMP, EggSMClientXSMP)(((EggSMClientXSMP*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((obj)), ((egg_sm_client_xsmp_get_type ())))))
)
47#define EGG_SM_CLIENT_XSMP_CLASS(klass)((((EggSMClientXSMPClass*) (void *) g_type_check_class_cast (
(GTypeClass*) ((klass)), ((egg_sm_client_xsmp_get_type ()))))
))
(G_TYPE_CHECK_CLASS_CAST ((klass), EGG_TYPE_SM_CLIENT_XSMP, EggSMClientXSMPClass)(((EggSMClientXSMPClass*) (void *) g_type_check_class_cast ((
GTypeClass*) ((klass)), ((egg_sm_client_xsmp_get_type ())))))
)
48#define EGG_IS_SM_CLIENT_XSMP(obj)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(obj)); GType __t = ((egg_sm_client_xsmp_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_TYPE_CHECK_INSTANCE_TYPE ((obj), EGG_TYPE_SM_CLIENT_XSMP)((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(obj)); GType __t = ((egg_sm_client_xsmp_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; })))
)
49#define EGG_IS_SM_CLIENT_XSMP_CLASS(klass)(((__extension__ ({ GTypeClass *__class = (GTypeClass*) ((klass
)); GType __t = ((egg_sm_client_xsmp_get_type ())); gboolean __r
; if (!__class) __r = (0); else if (__class->g_type == __t
) __r = (!(0)); else __r = g_type_check_class_is_a (__class, __t
); __r; }))))
(G_TYPE_CHECK_CLASS_TYPE ((klass), EGG_TYPE_SM_CLIENT_XSMP)((__extension__ ({ GTypeClass *__class = (GTypeClass*) ((klass
)); GType __t = ((egg_sm_client_xsmp_get_type ())); gboolean __r
; if (!__class) __r = (0); else if (__class->g_type == __t
) __r = (!(0)); else __r = g_type_check_class_is_a (__class, __t
); __r; })))
)
50#define EGG_SM_CLIENT_XSMP_GET_CLASS(obj)((((EggSMClientXSMPClass*) (((GTypeInstance*) ((obj)))->g_class
))))
(G_TYPE_INSTANCE_GET_CLASS ((obj), EGG_TYPE_SM_CLIENT_XSMP, EggSMClientXSMPClass)(((EggSMClientXSMPClass*) (((GTypeInstance*) ((obj)))->g_class
)))
)
51
52typedef struct _EggSMClientXSMP EggSMClientXSMP;
53typedef struct _EggSMClientXSMPClass EggSMClientXSMPClass;
54
55/* These mostly correspond to the similarly-named states in section
56 * 9.1 of the XSMP spec. Some of the states there aren't represented
57 * here, because we don't need them. SHUTDOWN_CANCELLED is slightly
58 * different from the spec; we use it when the client is IDLE after a
59 * ShutdownCancelled message, but the application is still interacting
60 * and doesn't know the shutdown has been cancelled yet.
61 */
62typedef enum
63{
64 XSMP_STATE_IDLE,
65 XSMP_STATE_SAVE_YOURSELF,
66 XSMP_STATE_INTERACT_REQUEST,
67 XSMP_STATE_INTERACT,
68 XSMP_STATE_SAVE_YOURSELF_DONE,
69 XSMP_STATE_SHUTDOWN_CANCELLED,
70 XSMP_STATE_CONNECTION_CLOSED
71} EggSMClientXSMPState;
72
73static const char *state_names[] =
74{
75 "idle",
76 "save-yourself",
77 "interact-request",
78 "interact",
79 "save-yourself-done",
80 "shutdown-cancelled",
81 "connection-closed"
82};
83
84#define EGG_SM_CLIENT_XSMP_STATE(xsmp)(state_names[(xsmp)->state]) (state_names[(xsmp)->state])
85
86struct _EggSMClientXSMP
87{
88 EggSMClient parent;
89
90 SmcConn connection;
91 char *client_id;
92
93 EggSMClientXSMPState state;
94 char **restart_command;
95 gboolean set_restart_command;
96 int restart_style;
97 char **discard_command;
98 gboolean set_discard_command;
99
100 guint idle;
101
102 /* Current SaveYourself state */
103 guint expecting_initial_save_yourself : 1;
104 guint need_save_state : 1;
105 guint need_quit_requested : 1;
106 guint interact_errors : 1;
107 guint shutting_down : 1;
108
109 /* Todo list */
110 guint waiting_to_set_initial_properties : 1;
111 guint waiting_to_emit_quit : 1;
112 guint waiting_to_emit_quit_cancelled : 1;
113 guint waiting_to_save_myself : 1;
114
115};
116
117struct _EggSMClientXSMPClass
118{
119 EggSMClientClass parent_class;
120
121};
122
123static void sm_client_xsmp_startup (EggSMClient *client,
124 const char *client_id);
125static void sm_client_xsmp_set_restart_command (EggSMClient *client,
126 int argc,
127 const char **argv);
128static void sm_client_xsmp_set_discard_command (EggSMClient *client,
129 int argc,
130 const char **argv);
131static void sm_client_xsmp_will_quit (EggSMClient *client,
132 gboolean will_quit);
133static gboolean sm_client_xsmp_end_session (EggSMClient *client,
134 EggSMClientEndStyle style,
135 gboolean request_confirmation);
136
137static void xsmp_save_yourself (SmcConn smc_conn,
138 SmPointer client_data,
139 int save_style,
140 Boolint shutdown,
141 int interact_style,
142 Boolint fast);
143static void xsmp_die (SmcConn smc_conn,
144 SmPointer client_data);
145static void xsmp_save_complete (SmcConn smc_conn,
146 SmPointer client_data);
147static void xsmp_shutdown_cancelled (SmcConn smc_conn,
148 SmPointer client_data);
149static void xsmp_interact (SmcConn smc_conn,
150 SmPointer client_data);
151
152static SmProp *array_prop (const char *name,
153 ...);
154static SmProp *ptrarray_prop (const char *name,
155 GPtrArray *values);
156static SmProp *string_prop (const char *name,
157 const char *value);
158static SmProp *card8_prop (const char *name,
159 unsigned char value);
160
161static void set_properties (EggSMClientXSMP *xsmp, ...);
162static void delete_properties (EggSMClientXSMP *xsmp, ...);
163
164static GPtrArray *generate_command (char **restart_command,
165 const char *client_id,
166 const char *state_file);
167
168static void save_state (EggSMClientXSMP *xsmp);
169static void do_save_yourself (EggSMClientXSMP *xsmp);
170static void update_pending_events (EggSMClientXSMP *xsmp);
171
172static void ice_init (void);
173static gboolean process_ice_messages (IceConn ice_conn);
174static void smc_error_handler (SmcConn smc_conn,
175 Boolint swap,
176 int offending_minor_opcode,
177 unsigned long offending_sequence,
178 int error_class,
179 int severity,
180 SmPointer values);
181
182G_DEFINE_TYPE (EggSMClientXSMP, egg_sm_client_xsmp, EGG_TYPE_SM_CLIENT)static void egg_sm_client_xsmp_init (EggSMClientXSMP *self); static
void egg_sm_client_xsmp_class_init (EggSMClientXSMPClass *klass
); static GType egg_sm_client_xsmp_get_type_once (void); static
gpointer egg_sm_client_xsmp_parent_class = ((void*)0); static
gint EggSMClientXSMP_private_offset; static void egg_sm_client_xsmp_class_intern_init
(gpointer klass) { egg_sm_client_xsmp_parent_class = g_type_class_peek_parent
(klass); if (EggSMClientXSMP_private_offset != 0) g_type_class_adjust_private_offset
(klass, &EggSMClientXSMP_private_offset); egg_sm_client_xsmp_class_init
((EggSMClientXSMPClass*) klass); } __attribute__ ((__unused__
)) static inline gpointer egg_sm_client_xsmp_get_instance_private
(EggSMClientXSMP *self) { return (((gpointer) ((guint8*) (self
) + (glong) (EggSMClientXSMP_private_offset)))); } GType egg_sm_client_xsmp_get_type
(void) { static GType static_g_define_type_id = 0; if ((__extension__
({ _Static_assert (sizeof *(&static_g_define_type_id) ==
sizeof (gpointer), "Expression evaluates to false"); (void) (
0 ? (gpointer) * (&static_g_define_type_id) : ((void*)0))
; (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter_pointer (
&static_g_define_type_id)); })) ) { GType g_define_type_id
= egg_sm_client_xsmp_get_type_once (); (__extension__ ({ _Static_assert
(sizeof *(&static_g_define_type_id) == sizeof (gpointer)
, "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id
) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer
((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id
)); })) ; } return static_g_define_type_id; } __attribute__ (
(__noinline__)) static GType egg_sm_client_xsmp_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
((egg_sm_client_get_type ()), g_intern_static_string ("EggSMClientXSMP"
), sizeof (EggSMClientXSMPClass), (GClassInitFunc)(void (*)(void
)) egg_sm_client_xsmp_class_intern_init, sizeof (EggSMClientXSMP
), (GInstanceInitFunc)(void (*)(void)) egg_sm_client_xsmp_init
, (GTypeFlags) 0); { {{};} } return g_define_type_id; }
183
184static void
185egg_sm_client_xsmp_init (EggSMClientXSMP *xsmp)
186{
187 xsmp->state = XSMP_STATE_CONNECTION_CLOSED;
188 xsmp->connection = NULL((void*)0);
189 xsmp->restart_style = SmRestartIfRunning0;
190}
191
192static void
193egg_sm_client_xsmp_class_init (EggSMClientXSMPClass *klass)
194{
195 EggSMClientClass *sm_client_class = EGG_SM_CLIENT_CLASS (klass);
196
197 sm_client_class->startup = sm_client_xsmp_startup;
198 sm_client_class->set_restart_command = sm_client_xsmp_set_restart_command;
199 sm_client_class->set_discard_command = sm_client_xsmp_set_discard_command;
200 sm_client_class->will_quit = sm_client_xsmp_will_quit;
201 sm_client_class->end_session = sm_client_xsmp_end_session;
202}
203
204EggSMClient *
205egg_sm_client_xsmp_new (void)
206{
207 if (!g_getenv ("SESSION_MANAGER"))
208 return NULL((void*)0);
209
210 return g_object_new (EGG_TYPE_SM_CLIENT_XSMP(egg_sm_client_xsmp_get_type ()), NULL((void*)0));
211}
212
213static gboolean
214sm_client_xsmp_set_initial_properties (gpointer user_data)
215{
216 EggSMClientXSMP *xsmp = user_data;
217 EggDesktopFile *desktop_file;
218 GPtrArray *clone, *restart;
219 char pid_str[64];
220
221 if (xsmp->idle)
222 {
223 g_source_remove (xsmp->idle);
224 xsmp->idle = 0;
225 }
226 xsmp->waiting_to_set_initial_properties = FALSE(0);
227
228 if (egg_sm_client_get_mode () == EGG_SM_CLIENT_MODE_NO_RESTART)
229 xsmp->restart_style = SmRestartNever3;
230
231 /* Parse info out of desktop file */
232 desktop_file = egg_get_desktop_file ();
233 if (desktop_file)
234 {
235 GError *err = NULL((void*)0);
236 char **argv;
237 int argc;
238
239 if (xsmp->restart_style == SmRestartIfRunning0)
240 {
241 if (egg_desktop_file_get_boolean (desktop_file,
242 "X-MATE-AutoRestart", NULL((void*)0)))
243 xsmp->restart_style = SmRestartImmediately2;
244 }
245
246 if (!xsmp->set_restart_command)
247 {
248 char *cmdline;
249
250 cmdline = egg_desktop_file_parse_exec (desktop_file, NULL((void*)0), &err);
251 if (cmdline && g_shell_parse_argv (cmdline, &argc, &argv, &err))
252 {
253 egg_sm_client_set_restart_command (EGG_SM_CLIENT (xsmp),
254 argc, (const char **)argv);
255 g_strfreev (argv);
256 }
257 else
258 {
259 g_warning ("Could not parse Exec line in desktop file: %s",
260 err->message);
261 g_error_free (err);
262 }
263 g_free (cmdline);
264 }
265 }
266
267 if (!xsmp->set_restart_command)
268 xsmp->restart_command = g_strsplit (g_get_prgname (), " ", -1);
269
270 clone = generate_command (xsmp->restart_command, NULL((void*)0), NULL((void*)0));
271 restart = generate_command (xsmp->restart_command, xsmp->client_id, NULL((void*)0));
272
273 g_debug ("Setting initial properties");
274
275 /* Program, CloneCommand, RestartCommand, and UserID are required.
276 * ProcessID isn't required, but the SM may be able to do something
277 * useful with it.
278 */
279 g_snprintf (pid_str, sizeof (pid_str), "%lu", (gulong) getpid ());
280 set_properties (xsmp,
281 string_prop (SmProgram"Program", g_get_prgname ()),
282 ptrarray_prop (SmCloneCommand"CloneCommand", clone),
283 ptrarray_prop (SmRestartCommand"RestartCommand", restart),
284 string_prop (SmUserID"UserID", g_get_user_name ()),
285 string_prop (SmProcessID"ProcessID", pid_str),
286 card8_prop (SmRestartStyleHint"RestartStyleHint", xsmp->restart_style),
287 NULL((void*)0));
288 g_ptr_array_free (clone, TRUE(!(0)));
289 g_ptr_array_free (restart, TRUE(!(0)));
290
291 if (desktop_file)
292 {
293 set_properties (xsmp,
294 string_prop ("_GSM_DesktopFile", egg_desktop_file_get_source (desktop_file)),
295 NULL((void*)0));
296 }
297
298 update_pending_events (xsmp);
299 return FALSE(0);
300}
301
302/* This gets called from two different places: xsmp_die() (when the
303 * server asks us to disconnect) and process_ice_messages() (when the
304 * server disconnects unexpectedly).
305 */
306static void
307sm_client_xsmp_disconnect (EggSMClientXSMP *xsmp)
308{
309 SmcConn connection;
310
311 if (!xsmp->connection)
312 return;
313
314 g_debug ("Disconnecting");
315
316 connection = xsmp->connection;
317 xsmp->connection = NULL((void*)0);
318 SmcCloseConnection (connection, 0, NULL((void*)0));
319 xsmp->state = XSMP_STATE_CONNECTION_CLOSED;
320
321 xsmp->waiting_to_save_myself = FALSE(0);
322 update_pending_events (xsmp);
323}
324
325static void
326sm_client_xsmp_startup (EggSMClient *client,
327 const char *client_id)
328{
329 EggSMClientXSMP *xsmp = (EggSMClientXSMP *)client;
330 SmcCallbacks callbacks;
331 char *ret_client_id;
332 char error_string_ret[256];
333
334 xsmp->client_id = g_strdup (client_id)g_strdup_inline (client_id);
335
336 ice_init ();
337 SmcSetErrorHandler (smc_error_handler);
338
339 callbacks.save_yourself.callback = xsmp_save_yourself;
340 callbacks.die.callback = xsmp_die;
341 callbacks.save_complete.callback = xsmp_save_complete;
342 callbacks.shutdown_cancelled.callback = xsmp_shutdown_cancelled;
343
344 callbacks.save_yourself.client_data = xsmp;
345 callbacks.die.client_data = xsmp;
346 callbacks.save_complete.client_data = xsmp;
347 callbacks.shutdown_cancelled.client_data = xsmp;
348
349 client_id = NULL((void*)0);
350 error_string_ret[0] = '\0';
351 xsmp->connection =
352 SmcOpenConnection (NULL((void*)0), xsmp, SmProtoMajor1, SmProtoMinor0,
353 SmcSaveYourselfProcMask(1L << 0) | SmcDieProcMask(1L << 1) |
354 SmcSaveCompleteProcMask(1L << 2) |
355 SmcShutdownCancelledProcMask(1L << 3),
356 &callbacks,
357 xsmp->client_id, &ret_client_id,
358 sizeof (error_string_ret), error_string_ret);
359
360 if (!xsmp->connection)
361 {
362 g_warning ("Failed to connect to the session manager: %s\n",
363 error_string_ret[0] ?
364 error_string_ret : "no error message given");
365 xsmp->state = XSMP_STATE_CONNECTION_CLOSED;
366 return;
367 }
368
369 /* We expect a pointless initial SaveYourself if either (a) we
370 * didn't have an initial client ID, or (b) we DID have an initial
371 * client ID, but the server rejected it and gave us a new one.
372 */
373 if (!xsmp->client_id ||
374 (ret_client_id && strcmp (xsmp->client_id, ret_client_id) != 0))
375 xsmp->expecting_initial_save_yourself = TRUE(!(0));
376
377 if (ret_client_id)
378 {
379 g_free (xsmp->client_id);
380 xsmp->client_id = g_strdup (ret_client_id)g_strdup_inline (ret_client_id);
381 free (ret_client_id);
382
383#if defined(GDK_WINDOWING_X11) || defined(HAVE_X111)
384 if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gdk_display_get_default ())); GType __t = ((gdk_x11_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
)
385 gdk_x11_set_sm_client_id (xsmp->client_id);
386#endif
387
388 g_debug ("Got client ID \"%s\"", xsmp->client_id);
389 }
390
391 xsmp->state = XSMP_STATE_IDLE;
392
393 /* Do not set the initial properties until we reach the main loop,
394 * so that the application has a chance to call
395 * egg_set_desktop_file(). (This may also help the session manager
396 * have a better idea of when the application is fully up and
397 * running.)
398 */
399 xsmp->waiting_to_set_initial_properties = TRUE(!(0));
400 xsmp->idle = g_idle_add (sm_client_xsmp_set_initial_properties, client);
401}
402
403static void
404sm_client_xsmp_set_restart_command (EggSMClient *client,
405 int argc,
406 const char **argv)
407{
408 EggSMClientXSMP *xsmp = (EggSMClientXSMP *)client;
409 int i;
410
411 g_strfreev (xsmp->restart_command);
412
413 xsmp->restart_command = g_new (char *, argc + 1)((char * *) g_malloc_n ((argc + 1), sizeof (char *)));
414 for (i = 0; i < argc; i++)
415 xsmp->restart_command[i] = g_strdup (argv[i])g_strdup_inline (argv[i]);
416 xsmp->restart_command[i] = NULL((void*)0);
417
418 xsmp->set_restart_command = TRUE(!(0));
419}
420
421static void
422sm_client_xsmp_set_discard_command (EggSMClient *client,
423 int argc,
424 const char **argv)
425{
426 EggSMClientXSMP *xsmp = (EggSMClientXSMP *)client;
427 int i;
428
429 g_strfreev (xsmp->discard_command);
430
431 xsmp->discard_command = g_new (char *, argc + 1)((char * *) g_malloc_n ((argc + 1), sizeof (char *)));
432 for (i = 0; i < argc; i++)
433 xsmp->discard_command[i] = g_strdup (argv[i])g_strdup_inline (argv[i]);
434 xsmp->discard_command[i] = NULL((void*)0);
435
436 xsmp->set_discard_command = TRUE(!(0));
437}
438
439static void
440sm_client_xsmp_will_quit (EggSMClient *client,
441 gboolean will_quit)
442{
443 EggSMClientXSMP *xsmp = (EggSMClientXSMP *)client;
444
445 if (xsmp->state == XSMP_STATE_CONNECTION_CLOSED)
446 {
447 /* The session manager has already exited! Schedule a quit
448 * signal.
449 */
450 xsmp->waiting_to_emit_quit = TRUE(!(0));
451 update_pending_events (xsmp);
452 return;
453 }
454 else if (xsmp->state == XSMP_STATE_SHUTDOWN_CANCELLED)
455 {
456 /* We received a ShutdownCancelled message while the application
457 * was interacting; Schedule a quit_cancelled signal.
458 */
459 xsmp->waiting_to_emit_quit_cancelled = TRUE(!(0));
460 update_pending_events (xsmp);
461 return;
462 }
463
464 g_return_if_fail (xsmp->state == XSMP_STATE_INTERACT)do { if ((xsmp->state == XSMP_STATE_INTERACT)) { } else { g_return_if_fail_warning
("EggSMClient", ((const char*) (__func__)), "xsmp->state == XSMP_STATE_INTERACT"
); return; } } while (0)
;
465
466 g_debug ("Sending InteractDone(%s)", will_quit ? "False" : "True");
467 SmcInteractDone (xsmp->connection, !will_quit);
468
469 if (will_quit && xsmp->need_save_state)
470 save_state (xsmp);
471
472 g_debug ("Sending SaveYourselfDone(%s)", will_quit ? "True" : "False");
473 SmcSaveYourselfDone (xsmp->connection, will_quit);
474 xsmp->state = XSMP_STATE_SAVE_YOURSELF_DONE;
475}
476
477static gboolean
478sm_client_xsmp_end_session (EggSMClient *client,
479 EggSMClientEndStyle style,
480 gboolean request_confirmation)
481{
482 EggSMClientXSMP *xsmp = (EggSMClientXSMP *)client;
483 int save_type;
484
485 /* To end the session via XSMP, we have to send a
486 * SaveYourselfRequest. We aren't allowed to do that if anything
487 * else is going on, but we don't want to expose this fact to the
488 * application. So we do our best to patch things up here...
489 *
490 * In the worst case, this method might block for some length of
491 * time in process_ice_messages, but the only time that code path is
492 * honestly likely to get hit is if the application tries to end the
493 * session as the very first thing it does, in which case it
494 * probably won't actually block anyway. It's not worth gunking up
495 * the API to try to deal nicely with the other 0.01% of cases where
496 * this happens.
497 */
498
499 while (xsmp->state != XSMP_STATE_IDLE ||
500 xsmp->expecting_initial_save_yourself)
501 {
502 /* If we're already shutting down, we don't need to do anything. */
503 if (xsmp->shutting_down)
504 return TRUE(!(0));
505
506 switch (xsmp->state)
507 {
508 case XSMP_STATE_CONNECTION_CLOSED:
509 return FALSE(0);
510
511 case XSMP_STATE_SAVE_YOURSELF:
512 /* Trying to log out from the save_state callback? Whatever.
513 * Abort the save_state.
514 */
515 SmcSaveYourselfDone (xsmp->connection, FALSE(0));
516 xsmp->state = XSMP_STATE_SAVE_YOURSELF_DONE;
517 break;
518
519 case XSMP_STATE_INTERACT_REQUEST:
520 case XSMP_STATE_INTERACT:
521 case XSMP_STATE_SHUTDOWN_CANCELLED:
522 /* Already in a shutdown-related state, just ignore
523 * the new shutdown request...
524 */
525 return TRUE(!(0));
526
527 case XSMP_STATE_IDLE:
528 if (xsmp->waiting_to_set_initial_properties)
529 sm_client_xsmp_set_initial_properties (xsmp);
530
531 if (!xsmp->expecting_initial_save_yourself)
532 break;
533 /* else fall through */
534
535 case XSMP_STATE_SAVE_YOURSELF_DONE:
536 /* We need to wait for some response from the server.*/
537 process_ice_messages (SmcGetIceConnection (xsmp->connection));
538 break;
539
540 default:
541 /* Hm... shouldn't happen */
542 return FALSE(0);
543 }
544 }
545
546 /* xfce4-session will do the wrong thing if we pass SmSaveGlobal and
547 * the user chooses to save the session. But mate-session will do
548 * the wrong thing if we pass SmSaveBoth and the user chooses NOT to
549 * save the session... Sigh.
550 */
551 if (!strcmp (SmcVendor (xsmp->connection), "xfce4-session"))
552 save_type = SmSaveBoth2;
553 else
554 save_type = SmSaveGlobal0;
555
556 g_debug ("Sending SaveYourselfRequest(SmSaveGlobal, Shutdown, SmInteractStyleAny, %sFast)", request_confirmation ? "!" : "");
557 SmcRequestSaveYourself (xsmp->connection,
558 save_type,
559 True1, /* shutdown */
560 SmInteractStyleAny2,
561 !request_confirmation, /* fast */
562 True1 /* global */);
563 return TRUE(!(0));
564}
565
566static gboolean
567idle_do_pending_events (gpointer data)
568{
569 EggSMClientXSMP *xsmp = data;
570 EggSMClient *client = data;
571
572 xsmp->idle = 0;
573
574 if (xsmp->waiting_to_emit_quit)
575 {
576 xsmp->waiting_to_emit_quit = FALSE(0);
577 egg_sm_client_quit (client);
578 goto out;
579 }
580
581 if (xsmp->waiting_to_emit_quit_cancelled)
582 {
583 xsmp->waiting_to_emit_quit_cancelled = FALSE(0);
584 egg_sm_client_quit_cancelled (client);
585 xsmp->state = XSMP_STATE_IDLE;
586 }
587
588 if (xsmp->waiting_to_save_myself)
589 {
590 xsmp->waiting_to_save_myself = FALSE(0);
591 do_save_yourself (xsmp);
592 }
593
594out:
595 return FALSE(0);
596}
597
598static void
599update_pending_events (EggSMClientXSMP *xsmp)
600{
601 gboolean want_idle =
602 xsmp->waiting_to_emit_quit ||
603 xsmp->waiting_to_emit_quit_cancelled ||
604 xsmp->waiting_to_save_myself;
605
606 if (want_idle)
607 {
608 if (xsmp->idle == 0)
609 xsmp->idle = g_idle_add (idle_do_pending_events, xsmp);
610 }
611 else
612 {
613 if (xsmp->idle != 0)
614 g_source_remove (xsmp->idle);
615 xsmp->idle = 0;
616 }
617}
618
619static void
620fix_broken_state (EggSMClientXSMP *xsmp, const char *message,
621 gboolean send_interact_done,
622 gboolean send_save_yourself_done)
623{
624 g_warning ("Received XSMP %s message in state %s: client or server error",
625 message, EGG_SM_CLIENT_XSMP_STATE (xsmp)(state_names[(xsmp)->state]));
626
627 /* Forget any pending SaveYourself plans we had */
628 xsmp->waiting_to_save_myself = FALSE(0);
629 update_pending_events (xsmp);
630
631 if (send_interact_done)
632 SmcInteractDone (xsmp->connection, False0);
633 if (send_save_yourself_done)
634 SmcSaveYourselfDone (xsmp->connection, True1);
635
636 xsmp->state = send_save_yourself_done ? XSMP_STATE_SAVE_YOURSELF_DONE : XSMP_STATE_IDLE;
637}
638
639/* SM callbacks */
640
641static void
642xsmp_save_yourself (SmcConn smc_conn,
643 SmPointer client_data,
644 int save_type,
645 Boolint shutdown,
646 int interact_style,
647 Boolint fast)
648{
649 EggSMClientXSMP *xsmp = client_data;
650 gboolean wants_quit_requested;
651
652 g_debug ("Received SaveYourself(%s, %s, %s, %s) in state %s",
653 save_type == SmSaveLocal1 ? "SmSaveLocal" :
654 save_type == SmSaveGlobal0 ? "SmSaveGlobal" : "SmSaveBoth",
655 shutdown ? "Shutdown" : "!Shutdown",
656 interact_style == SmInteractStyleAny2 ? "SmInteractStyleAny" :
657 interact_style == SmInteractStyleErrors1 ? "SmInteractStyleErrors" :
658 "SmInteractStyleNone", fast ? "Fast" : "!Fast",
659 EGG_SM_CLIENT_XSMP_STATE (xsmp)(state_names[(xsmp)->state]));
660
661 if (xsmp->state != XSMP_STATE_IDLE &&
662 xsmp->state != XSMP_STATE_SHUTDOWN_CANCELLED)
663 {
664 fix_broken_state (xsmp, "SaveYourself", FALSE(0), TRUE(!(0)));
665 return;
666 }
667
668 if (xsmp->waiting_to_set_initial_properties)
669 sm_client_xsmp_set_initial_properties (xsmp);
670
671 /* If this is the initial SaveYourself, ignore it; we've already set
672 * properties and there's no reason to actually save state too.
673 */
674 if (xsmp->expecting_initial_save_yourself)
675 {
676 xsmp->expecting_initial_save_yourself = FALSE(0);
677
678 if (save_type == SmSaveLocal1 &&
679 interact_style == SmInteractStyleNone0 &&
680 !shutdown && !fast)
681 {
682 g_debug ("Sending SaveYourselfDone(True) for initial SaveYourself");
683 SmcSaveYourselfDone (xsmp->connection, True1);
684 /* As explained in the comment at the end of
685 * do_save_yourself(), SAVE_YOURSELF_DONE is the correct
686 * state here, not IDLE.
687 */
688 xsmp->state = XSMP_STATE_SAVE_YOURSELF_DONE;
689 return;
690 }
691 else
692 g_warning ("First SaveYourself was not the expected one!");
693 }
694
695 /* Even ignoring the "fast" flag completely, there are still 18
696 * different combinations of save_type, shutdown and interact_style.
697 * We interpret them as follows:
698 *
699 * Type Shutdown Interact Interpretation
700 * G F A/E/N do nothing (1)
701 * G T N do nothing (1)*
702 * G T A/E quit_requested (2)
703 * L/B F A/E/N save_state (3)
704 * L/B T N save_state (3)*
705 * L/B T A/E quit_requested, then save_state (4)
706 *
707 * 1. Do nothing, because the SM asked us to do something
708 * uninteresting (save open files, but then don't quit
709 * afterward) or rude (save open files without asking the user
710 * for confirmation).
711 *
712 * 2. Request interaction and then emit ::quit_requested. This
713 * perhaps isn't quite correct for the SmInteractStyleErrors
714 * case, but we don't care.
715 *
716 * 3. Emit ::save_state. The SmSaveBoth SaveYourselfs in these
717 * rows essentially get demoted to SmSaveLocal, because their
718 * Global halves correspond to "do nothing".
719 *
720 * 4. Request interaction, emit ::quit_requested, and then emit
721 * ::save_state after interacting. This is the SmSaveBoth
722 * equivalent of #2, but we also promote SmSaveLocal shutdown
723 * SaveYourselfs to SmSaveBoth here, because we want to give
724 * the user a chance to save open files before quitting.
725 *
726 * (* It would be nice if we could do something useful when the
727 * session manager sends a SaveYourself with shutdown True and
728 * SmInteractStyleNone. But we can't, so we just pretend it didn't
729 * even tell us it was shutting down. The docs for ::quit mention
730 * that it might not always be preceded by ::quit_requested.)
731 */
732
733 /* As an optimization, we don't actually request interaction and
734 * emit ::quit_requested if the application isn't listening to the
735 * signal.
736 */
737 wants_quit_requested = g_signal_has_handler_pending (xsmp, g_signal_lookup ("quit_requested", EGG_TYPE_SM_CLIENT(egg_sm_client_get_type ())), 0, FALSE(0));
738
739 xsmp->need_save_state = (save_type != SmSaveGlobal0);
740 xsmp->need_quit_requested = (shutdown && wants_quit_requested &&
741 interact_style != SmInteractStyleNone0);
742 xsmp->interact_errors = (interact_style == SmInteractStyleErrors1);
743
744 xsmp->shutting_down = shutdown;
745
746 do_save_yourself (xsmp);
747}
748
749static void
750do_save_yourself (EggSMClientXSMP *xsmp)
751{
752 if (xsmp->state == XSMP_STATE_SHUTDOWN_CANCELLED)
753 {
754 /* The SM cancelled a previous SaveYourself, but we haven't yet
755 * had a chance to tell the application, so we can't start
756 * processing this SaveYourself yet.
757 */
758 xsmp->waiting_to_save_myself = TRUE(!(0));
759 update_pending_events (xsmp);
760 return;
761 }
762
763 if (xsmp->need_quit_requested)
764 {
765 xsmp->state = XSMP_STATE_INTERACT_REQUEST;
766
767 g_debug ("Sending InteractRequest(%s)",
768 xsmp->interact_errors ? "Error" : "Normal");
769 SmcInteractRequest (xsmp->connection,
770 xsmp->interact_errors ? SmDialogError0 : SmDialogNormal1,
771 xsmp_interact,
772 xsmp);
773 return;
774 }
775
776 if (xsmp->need_save_state)
777 {
778 save_state (xsmp);
779
780 /* Though unlikely, the client could have been disconnected
781 * while the application was saving its state.
782 */
783 if (!xsmp->connection)
784 return;
785 }
786
787 g_debug ("Sending SaveYourselfDone(True)");
788 SmcSaveYourselfDone (xsmp->connection, True1);
789
790 /* The client state diagram in the XSMP spec says that after a
791 * non-shutdown SaveYourself, we go directly back to "idle". But
792 * everything else in both the XSMP spec and the libSM docs
793 * disagrees.
794 */
795 xsmp->state = XSMP_STATE_SAVE_YOURSELF_DONE;
796}
797
798static void
799save_state (EggSMClientXSMP *xsmp)
800{
801 GKeyFile *state_file;
802 char *state_file_path, *data;
803 EggDesktopFile *desktop_file;
804 GPtrArray *restart, *discard;
805 int offset, fd;
806
807 /* We set xsmp->state before emitting save_state, but our caller is
808 * responsible for setting it back afterward.
809 */
810 xsmp->state = XSMP_STATE_SAVE_YOURSELF;
811
812 state_file = egg_sm_client_save_state ((EggSMClient *)xsmp);
813 if (!state_file)
814 {
815 restart = generate_command (xsmp->restart_command, xsmp->client_id, NULL((void*)0));
816 set_properties (xsmp,
817 ptrarray_prop (SmRestartCommand"RestartCommand", restart),
818 NULL((void*)0));
819 g_ptr_array_free (restart, TRUE(!(0)));
820
821 if (xsmp->set_discard_command)
822 {
823 discard = generate_command (xsmp->discard_command, NULL((void*)0), NULL((void*)0));
824 set_properties (xsmp,
825 ptrarray_prop (SmDiscardCommand"DiscardCommand", discard),
826 NULL((void*)0));
827 g_ptr_array_free (discard, TRUE(!(0)));
828 }
829 else
830 delete_properties (xsmp, SmDiscardCommand"DiscardCommand", NULL((void*)0));
831
832 return;
833 }
834
835 desktop_file = egg_get_desktop_file ();
836 if (desktop_file)
837 {
838 GKeyFile *merged_file;
839 char *desktop_file_path;
840
841 merged_file = g_key_file_new ();
842 desktop_file_path =
843 g_filename_from_uri (egg_desktop_file_get_source (desktop_file),
844 NULL((void*)0), NULL((void*)0));
845 if (desktop_file_path &&
846 g_key_file_load_from_file (merged_file, desktop_file_path,
847 G_KEY_FILE_KEEP_COMMENTS |
848 G_KEY_FILE_KEEP_TRANSLATIONS, NULL((void*)0)))
849 {
850 guint g, k, i;
851 char **groups, **keys, *value, *exec;
852
853 groups = g_key_file_get_groups (state_file, NULL((void*)0));
854 for (g = 0; groups[g]; g++)
855 {
856 keys = g_key_file_get_keys (state_file, groups[g], NULL((void*)0), NULL((void*)0));
857 for (k = 0; keys[k]; k++)
858 {
859 value = g_key_file_get_value (state_file, groups[g],
860 keys[k], NULL((void*)0));
861 if (value)
862 {
863 g_key_file_set_value (merged_file, groups[g],
864 keys[k], value);
865 g_free (value);
866 }
867 }
868 g_strfreev (keys);
869 }
870 g_strfreev (groups);
871
872 g_key_file_free (state_file);
873 state_file = merged_file;
874
875 /* Update Exec key using "--sm-client-state-file %k" */
876 restart = generate_command (xsmp->restart_command,
877 NULL((void*)0), "%k");
878 for (i = 0; i < restart->len; i++)
879 restart->pdata[i] = g_shell_quote (restart->pdata[i]);
880 g_ptr_array_add (restart, NULL((void*)0));
881 exec = g_strjoinv (" ", (char **)restart->pdata);
882 g_strfreev ((char **)restart->pdata);
883 g_ptr_array_free (restart, FALSE(0));
884
885 g_key_file_set_string (state_file, EGG_DESKTOP_FILE_GROUP"Desktop Entry",
886 EGG_DESKTOP_FILE_KEY_EXEC"Exec",
887 exec);
888 g_free (exec);
889 }
890 else
891 desktop_file = NULL((void*)0);
892
893 g_free (desktop_file_path);
894 }
895
896 /* Now write state_file to disk. (We can't use mktemp(), because
897 * that requires the filename to end with "XXXXXX", and we want
898 * it to end with ".desktop".)
899 */
900
901 data = g_key_file_to_data (state_file, NULL((void*)0), NULL((void*)0));
902 g_key_file_free (state_file);
903
904 offset = 0;
905 while (1)
906 {
907 state_file_path = g_strdup_printf ("%s%csession-state%c%s-%ld.%s",
908 g_get_user_config_dir (),
909 G_DIR_SEPARATOR'/', G_DIR_SEPARATOR'/',
910 g_get_prgname (),
911 (long)time (NULL((void*)0)) + offset,
912 desktop_file ? "desktop" : "state");
913
914 fd = open (state_file_path, O_WRONLY01 | O_CREAT0100 | O_EXCL0200, 0644);
915 if (fd == -1)
916 {
917 if (errno(*__errno_location ()) == EEXIST17)
918 {
919 offset++;
920 g_free (state_file_path);
921 continue;
922 }
923 else if (errno(*__errno_location ()) == ENOTDIR20 || errno(*__errno_location ()) == ENOENT2)
924 {
925 char *sep = strrchr (state_file_path, G_DIR_SEPARATOR'/');
926
927 *sep = '\0';
928 if (g_mkdir_with_parents (state_file_path, 0755) != 0)
929 {
930 g_warning ("Could not create directory '%s'",
931 state_file_path);
932 g_free (state_file_path);
933 state_file_path = NULL((void*)0);
934 break;
935 }
936
937 continue;
938 }
939
940 g_warning ("Could not create file '%s': %s",
941 state_file_path, g_strerror (errno(*__errno_location ())));
942 g_free (state_file_path);
943 state_file_path = NULL((void*)0);
944 break;
945 }
946
947 close (fd);
948 g_file_set_contents (state_file_path, data, -1, NULL((void*)0));
949 break;
950 }
951 g_free (data);
952
953 restart = generate_command (xsmp->restart_command, xsmp->client_id,
954 state_file_path);
955 set_properties (xsmp,
956 ptrarray_prop (SmRestartCommand"RestartCommand", restart),
957 NULL((void*)0));
958 g_ptr_array_free (restart, TRUE(!(0)));
959
960 if (state_file_path)
961 {
962 set_properties (xsmp,
963 array_prop (SmDiscardCommand"DiscardCommand",
964 "/bin/rm", "-rf", state_file_path,
965 NULL((void*)0)),
966 NULL((void*)0));
967 g_free (state_file_path);
968 }
969}
970
971static void
972xsmp_interact (SmcConn smc_conn,
973 SmPointer client_data)
974{
975 EggSMClientXSMP *xsmp = client_data;
976 EggSMClient *client = client_data;
977
978 g_debug ("Received Interact message in state %s",
979 EGG_SM_CLIENT_XSMP_STATE (xsmp)(state_names[(xsmp)->state]));
980
981 if (xsmp->state != XSMP_STATE_INTERACT_REQUEST)
982 {
983 fix_broken_state (xsmp, "Interact", TRUE(!(0)), TRUE(!(0)));
984 return;
985 }
986
987 xsmp->state = XSMP_STATE_INTERACT;
988 egg_sm_client_quit_requested (client);
989}
990
991static void
992xsmp_die (SmcConn smc_conn,
993 SmPointer client_data)
994{
995 EggSMClientXSMP *xsmp = client_data;
996 EggSMClient *client = client_data;
997
998 g_debug ("Received Die message in state %s",
999 EGG_SM_CLIENT_XSMP_STATE (xsmp)(state_names[(xsmp)->state]));
1000
1001 sm_client_xsmp_disconnect (xsmp);
1002 egg_sm_client_quit (client);
1003}
1004
1005static void
1006xsmp_save_complete (SmcConn smc_conn,
1007 SmPointer client_data)
1008{
1009 EggSMClientXSMP *xsmp = client_data;
1010
1011 g_debug ("Received SaveComplete message in state %s",
1012 EGG_SM_CLIENT_XSMP_STATE (xsmp)(state_names[(xsmp)->state]));
1013
1014 if (xsmp->state == XSMP_STATE_SAVE_YOURSELF_DONE)
1015 xsmp->state = XSMP_STATE_IDLE;
1016 else
1017 fix_broken_state (xsmp, "SaveComplete", FALSE(0), FALSE(0));
1018}
1019
1020static void
1021xsmp_shutdown_cancelled (SmcConn smc_conn,
1022 SmPointer client_data)
1023{
1024 EggSMClientXSMP *xsmp = client_data;
1025 EggSMClient *client = client_data;
1026
1027 g_debug ("Received ShutdownCancelled message in state %s",
1028 EGG_SM_CLIENT_XSMP_STATE (xsmp)(state_names[(xsmp)->state]));
1029
1030 xsmp->shutting_down = FALSE(0);
1031
1032 if (xsmp->state == XSMP_STATE_SAVE_YOURSELF_DONE)
1033 {
1034 /* We've finished interacting and now the SM has agreed to
1035 * cancel the shutdown.
1036 */
1037 xsmp->state = XSMP_STATE_IDLE;
1038 egg_sm_client_quit_cancelled (client);
1039 }
1040 else if (xsmp->state == XSMP_STATE_SHUTDOWN_CANCELLED)
1041 {
1042 /* Hm... ok, so we got a shutdown SaveYourself, which got
1043 * cancelled, but the application was still interacting, so we
1044 * didn't tell it yet, and then *another* SaveYourself arrived,
1045 * which we must still be waiting to tell the app about, except
1046 * that now that SaveYourself has been cancelled too! Dizzy yet?
1047 */
1048 xsmp->waiting_to_save_myself = FALSE(0);
1049 update_pending_events (xsmp);
1050 }
1051 else
1052 {
1053 g_debug ("Sending SaveYourselfDone(False)");
1054 SmcSaveYourselfDone (xsmp->connection, False0);
1055
1056 if (xsmp->state == XSMP_STATE_INTERACT)
1057 {
1058 /* The application is currently interacting, so we can't
1059 * tell it about the cancellation yet; we will wait until
1060 * after it calls egg_sm_client_will_quit().
1061 */
1062 xsmp->state = XSMP_STATE_SHUTDOWN_CANCELLED;
1063 }
1064 else
1065 {
1066 /* The shutdown was cancelled before the application got a
1067 * chance to interact.
1068 */
1069 xsmp->state = XSMP_STATE_IDLE;
1070 }
1071 }
1072}
1073
1074/* Utilities */
1075
1076/* Create a restart/clone/Exec command based on @restart_command.
1077 * If @client_id is non-%NULL, add "--sm-client-id @client_id".
1078 * If @state_file is non-%NULL, add "--sm-client-state-file @state_file".
1079 *
1080 * None of the input strings are g_strdup()ed; the caller must keep
1081 * them around until it is done with the returned GPtrArray, and must
1082 * then free the array, but not its contents.
1083 */
1084static GPtrArray *
1085generate_command (char **restart_command, const char *client_id,
1086 const char *state_file)
1087{
1088 GPtrArray *cmd;
1089 int i;
1090
1091 cmd = g_ptr_array_new ();
1092 g_ptr_array_add (cmd, restart_command[0]);
1093
1094 if (client_id)
1095 {
1096 g_ptr_array_add (cmd, (char *)"--sm-client-id");
1097 g_ptr_array_add (cmd, (char *)client_id);
1098 }
1099
1100 if (state_file)
1101 {
1102 g_ptr_array_add (cmd, (char *)"--sm-client-state-file");
1103 g_ptr_array_add (cmd, (char *)state_file);
1104 }
1105
1106 for (i = 1; restart_command[i]; i++)
1107 g_ptr_array_add (cmd, restart_command[i]);
1108
1109 return cmd;
1110}
1111
1112/* Takes a NULL-terminated list of SmProp * values, created by
1113 * array_prop, ptrarray_prop, string_prop, card8_prop, sets them, and
1114 * frees them.
1115 */
1116static void
1117set_properties (EggSMClientXSMP *xsmp, ...)
1118{
1119 GPtrArray *props;
1120 SmProp *prop;
1121 va_list ap;
1122 guint i;
1123
1124 props = g_ptr_array_new ();
1125
1126 va_start (ap, xsmp)__builtin_va_start(ap, xsmp);
1127 while ((prop = va_arg (ap, SmProp *)__builtin_va_arg(ap, SmProp *)))
1128 g_ptr_array_add (props, prop);
1129 va_end (ap)__builtin_va_end(ap);
1130
1131 if (xsmp->connection)
1132 {
1133 SmcSetProperties (xsmp->connection, props->len,
1134 (SmProp **)props->pdata);
1135 }
1136
1137 for (i = 0; i < props->len; i++)
1138 {
1139 prop = props->pdata[i];
1140 g_free (prop->vals);
1141 g_free (prop);
1142 }
1143 g_ptr_array_free (props, TRUE(!(0)));
1144}
1145
1146/* Takes a NULL-terminated list of property names and deletes them. */
1147static void
1148delete_properties (EggSMClientXSMP *xsmp, ...)
1149{
1150 GPtrArray *props;
1151 char *prop;
1152 va_list ap;
1153
1154 if (!xsmp->connection)
1155 return;
1156
1157 props = g_ptr_array_new ();
1158
1159 va_start (ap, xsmp)__builtin_va_start(ap, xsmp);
1160 while ((prop = va_arg (ap, char *)__builtin_va_arg(ap, char *)))
1161 g_ptr_array_add (props, prop);
1162 va_end (ap)__builtin_va_end(ap);
1163
1164 SmcDeleteProperties (xsmp->connection, props->len,
1165 (char **)props->pdata);
1166
1167 g_ptr_array_free (props, TRUE(!(0)));
1168}
1169
1170/* Takes an array of strings and creates a LISTofARRAY8 property. The
1171 * strings are neither dupped nor freed; they need to remain valid
1172 * until you're done with the SmProp.
1173 */
1174static SmProp *
1175array_prop (const char *name, ...)
1176{
1177 SmProp *prop;
1178 SmPropValue pv;
1179 GArray *vals;
1180 char *value;
1181 va_list ap;
1182
1183 prop = g_new (SmProp, 1)((SmProp *) g_malloc_n ((1), sizeof (SmProp)));
1184 prop->name = (char *)name;
1185 prop->type = (char *)SmLISTofARRAY8"LISTofARRAY8";
1186
1187 vals = g_array_new (FALSE(0), FALSE(0), sizeof (SmPropValue));
1188
1189 va_start (ap, name)__builtin_va_start(ap, name);
1190 while ((value = va_arg (ap, char *)__builtin_va_arg(ap, char *)))
1191 {
1192 pv.length = strlen (value);
1193 pv.value = value;
1194 g_array_append_val (vals, pv)g_array_append_vals (vals, &(pv), 1);
1195 }
1196 va_end (ap)__builtin_va_end(ap);
1197
1198 prop->num_vals = vals->len;
1199 prop->vals = (SmPropValue *)vals->data;
Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption
1200
1201 g_array_free (vals, FALSE(0));
1202
1203 return prop;
1204}
1205
1206/* Takes a GPtrArray of strings and creates a LISTofARRAY8 property.
1207 * The array contents are neither dupped nor freed; they need to
1208 * remain valid until you're done with the SmProp.
1209 */
1210static SmProp *
1211ptrarray_prop (const char *name, GPtrArray *values)
1212{
1213 SmProp *prop;
1214 SmPropValue pv;
1215 GArray *vals;
1216 guint i;
1217
1218 prop = g_new (SmProp, 1)((SmProp *) g_malloc_n ((1), sizeof (SmProp)));
1219 prop->name = (char *)name;
1220 prop->type = (char *)SmLISTofARRAY8"LISTofARRAY8";
1221
1222 vals = g_array_new (FALSE(0), FALSE(0), sizeof (SmPropValue));
1223
1224 for (i = 0; i < values->len; i++)
1225 {
1226 pv.length = strlen (values->pdata[i]);
1227 pv.value = values->pdata[i];
1228 g_array_append_val (vals, pv)g_array_append_vals (vals, &(pv), 1);
1229 }
1230
1231 prop->num_vals = vals->len;
1232 prop->vals = (SmPropValue *)vals->data;
1233
1234 g_array_free (vals, FALSE(0));
1235
1236 return prop;
1237}
1238
1239/* Takes a string and creates an ARRAY8 property. The string is
1240 * neither dupped nor freed; it needs to remain valid until you're
1241 * done with the SmProp.
1242 */
1243static SmProp *
1244string_prop (const char *name, const char *value)
1245{
1246 SmProp *prop;
1247
1248 prop = g_new (SmProp, 1)((SmProp *) g_malloc_n ((1), sizeof (SmProp)));
1249 prop->name = (char *)name;
1250 prop->type = (char *)SmARRAY8"ARRAY8";
1251
1252 prop->num_vals = 1;
1253 prop->vals = g_new (SmPropValue, 1)((SmPropValue *) g_malloc_n ((1), sizeof (SmPropValue)));
1254
1255 prop->vals[0].length = strlen (value);
1256 prop->vals[0].value = (char *)value;
1257
1258 return prop;
1259}
1260
1261/* Takes a char and creates a CARD8 property. */
1262static SmProp *
1263card8_prop (const char *name, unsigned char value)
1264{
1265 SmProp *prop;
1266 char *card8val;
1267
1268 /* To avoid having to allocate and free prop->vals[0], we cheat and
1269 * make vals a 2-element-long array and then use the second element
1270 * to store value.
1271 */
1272
1273 prop = g_new (SmProp, 1)((SmProp *) g_malloc_n ((1), sizeof (SmProp)));
1274 prop->name = (char *)name;
1275 prop->type = (char *)SmCARD8"CARD8";
1276
1277 prop->num_vals = 1;
1278 prop->vals = g_new (SmPropValue, 2)((SmPropValue *) g_malloc_n ((2), sizeof (SmPropValue)));
1279 card8val = (char *)(&prop->vals[1]);
1280 card8val[0] = value;
1281
1282 prop->vals[0].length = 1;
1283 prop->vals[0].value = card8val;
1284
1285 return prop;
1286}
1287
1288/* ICE code. This makes no effort to play nice with anyone else trying
1289 * to use libICE. Fortunately, no one uses libICE for anything other
1290 * than SM. (DCOP uses ICE, but it has its own private copy of
1291 * libICE.)
1292 *
1293 * When this moves to gtk, it will need to be cleverer, to avoid
1294 * tripping over old apps that use MateClient or that use libSM
1295 * directly.
1296 */
1297
1298#include <X11/ICE/ICElib.h>
1299#include <fcntl.h>
1300
1301static void ice_error_handler (IceConn ice_conn,
1302 Boolint swap,
1303 int offending_minor_opcode,
1304 unsigned long offending_sequence,
1305 int error_class,
1306 int severity,
1307 IcePointer values);
1308static void ice_io_error_handler (IceConn ice_conn);
1309static void ice_connection_watch (IceConn ice_conn,
1310 IcePointer client_data,
1311 Boolint opening,
1312 IcePointer *watch_data);
1313
1314static void
1315ice_init (void)
1316{
1317 IceSetIOErrorHandler (ice_io_error_handler);
1318 IceSetErrorHandler (ice_error_handler);
1319 IceAddConnectionWatch (ice_connection_watch, NULL((void*)0));
1320}
1321
1322static gboolean
1323process_ice_messages (IceConn ice_conn)
1324{
1325 IceProcessMessagesStatus status;
1326 status = IceProcessMessages (ice_conn, NULL((void*)0), NULL((void*)0));
1327
1328 switch (status)
1329 {
1330 case IceProcessMessagesSuccess:
1331 return TRUE(!(0));
1332
1333 case IceProcessMessagesIOError:
1334 sm_client_xsmp_disconnect (IceGetConnectionContext (ice_conn));
1335 return FALSE(0);
1336
1337 case IceProcessMessagesConnectionClosed:
1338 return FALSE(0);
1339
1340 default:
1341 g_assert_not_reached ()do { g_assertion_message_expr ("EggSMClient", "eggsmclient-xsmp.c"
, 1341, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1342 }
1343}
1344
1345static gboolean
1346ice_iochannel_watch (GIOChannel *channel,
1347 GIOCondition condition,
1348 gpointer client_data)
1349{
1350 return process_ice_messages (client_data);
1351}
1352
1353static void
1354ice_connection_watch (IceConn ice_conn,
1355 IcePointer client_data,
1356 Boolint opening,
1357 IcePointer *watch_data)
1358{
1359 guint watch_id;
1360
1361 if (opening)
1362 {
1363 GIOChannel *channel;
1364 int fd = IceConnectionNumber (ice_conn);
1365
1366 fcntl (fd, F_SETFD2, fcntl (fd, F_GETFD1, 0) | FD_CLOEXEC1);
1367 channel = g_io_channel_unix_new (fd);
1368 watch_id = g_io_add_watch (channel, G_IO_IN | G_IO_ERR,
1369 ice_iochannel_watch, ice_conn);
1370 g_io_channel_unref (channel);
1371
1372 *watch_data = GUINT_TO_POINTER (watch_id)((gpointer) (gulong) (watch_id));
1373 }
1374 else
1375 {
1376 watch_id = GPOINTER_TO_UINT (*watch_data)((guint) (gulong) (*watch_data));
1377 g_source_remove (watch_id);
1378 }
1379}
1380
1381static void
1382ice_error_handler (IceConn ice_conn,
1383 Boolint swap,
1384 int offending_minor_opcode,
1385 unsigned long offending_sequence,
1386 int error_class,
1387 int severity,
1388 IcePointer values)
1389{
1390 /* Do nothing */
1391}
1392
1393static void
1394ice_io_error_handler (IceConn ice_conn)
1395{
1396 /* Do nothing */
1397}
1398
1399static void
1400smc_error_handler (SmcConn smc_conn,
1401 Boolint swap,
1402 int offending_minor_opcode,
1403 unsigned long offending_sequence,
1404 int error_class,
1405 int severity,
1406 SmPointer values)
1407{
1408 /* Do nothing */
1409}
diff --git a/2024-06-18-172109-13286-1@e182420b844f_master/report-cf3974.html b/2024-06-18-172109-13286-1@e182420b844f_master/report-cf3974.html new file mode 100644 index 00000000..697f2503 --- /dev/null +++ b/2024-06-18-172109-13286-1@e182420b844f_master/report-cf3974.html @@ -0,0 +1,2089 @@ + + + +eggsmclient-xsmp.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:mate-panel/mate-submodules/libegg/eggsmclient-xsmp.c
Warning:line 1232, column 18
Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name eggsmclient-xsmp.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/mate-panel/mate-submodules/libegg -fcoverage-compilation-dir=/rootdir/mate-panel/mate-submodules/libegg -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I ../../.. -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/uuid -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/gio-unix-2.0 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -D EGG_SM_CLIENT_BACKEND_XSMP -D G_LOG_DOMAIN="EggSMClient" -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/uuid -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/gio-unix-2.0 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -D PIC -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-18-172109-13286-1 -x c eggsmclient-xsmp.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * Copyright (C) 2007 Novell, Inc.
3 *
4 * Inspired by various other pieces of code including GsmClient (C)
5 * 2001 Havoc Pennington, MateClient (C) 1998 Carsten Schaar, and twm
6 * session code (C) 1998 The Open Group.
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
17 *
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the
20 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22 */
23
24#include "config.h"
25
26#include "eggsmclient.h"
27#include "eggsmclient-private.h"
28
29#include "eggdesktopfile.h"
30
31#include <errno(*__errno_location ()).h>
32#include <fcntl.h>
33#include <stdlib.h>
34#include <string.h>
35#include <unistd.h>
36#include <X11/SM/SMlib.h>
37
38#include <gtk/gtk.h>
39#include <gdk/gdk.h>
40
41#if defined(GDK_WINDOWING_X11) || defined(HAVE_X111)
42#include <gdk/gdkx.h>
43#endif
44
45#define EGG_TYPE_SM_CLIENT_XSMP(egg_sm_client_xsmp_get_type ()) (egg_sm_client_xsmp_get_type ())
46#define EGG_SM_CLIENT_XSMP(obj)((((EggSMClientXSMP*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((obj)), ((egg_sm_client_xsmp_get_type ()))))))
(G_TYPE_CHECK_INSTANCE_CAST ((obj), EGG_TYPE_SM_CLIENT_XSMP, EggSMClientXSMP)(((EggSMClientXSMP*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((obj)), ((egg_sm_client_xsmp_get_type ())))))
)
47#define EGG_SM_CLIENT_XSMP_CLASS(klass)((((EggSMClientXSMPClass*) (void *) g_type_check_class_cast (
(GTypeClass*) ((klass)), ((egg_sm_client_xsmp_get_type ()))))
))
(G_TYPE_CHECK_CLASS_CAST ((klass), EGG_TYPE_SM_CLIENT_XSMP, EggSMClientXSMPClass)(((EggSMClientXSMPClass*) (void *) g_type_check_class_cast ((
GTypeClass*) ((klass)), ((egg_sm_client_xsmp_get_type ())))))
)
48#define EGG_IS_SM_CLIENT_XSMP(obj)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(obj)); GType __t = ((egg_sm_client_xsmp_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_TYPE_CHECK_INSTANCE_TYPE ((obj), EGG_TYPE_SM_CLIENT_XSMP)((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(obj)); GType __t = ((egg_sm_client_xsmp_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; })))
)
49#define EGG_IS_SM_CLIENT_XSMP_CLASS(klass)(((__extension__ ({ GTypeClass *__class = (GTypeClass*) ((klass
)); GType __t = ((egg_sm_client_xsmp_get_type ())); gboolean __r
; if (!__class) __r = (0); else if (__class->g_type == __t
) __r = (!(0)); else __r = g_type_check_class_is_a (__class, __t
); __r; }))))
(G_TYPE_CHECK_CLASS_TYPE ((klass), EGG_TYPE_SM_CLIENT_XSMP)((__extension__ ({ GTypeClass *__class = (GTypeClass*) ((klass
)); GType __t = ((egg_sm_client_xsmp_get_type ())); gboolean __r
; if (!__class) __r = (0); else if (__class->g_type == __t
) __r = (!(0)); else __r = g_type_check_class_is_a (__class, __t
); __r; })))
)
50#define EGG_SM_CLIENT_XSMP_GET_CLASS(obj)((((EggSMClientXSMPClass*) (((GTypeInstance*) ((obj)))->g_class
))))
(G_TYPE_INSTANCE_GET_CLASS ((obj), EGG_TYPE_SM_CLIENT_XSMP, EggSMClientXSMPClass)(((EggSMClientXSMPClass*) (((GTypeInstance*) ((obj)))->g_class
)))
)
51
52typedef struct _EggSMClientXSMP EggSMClientXSMP;
53typedef struct _EggSMClientXSMPClass EggSMClientXSMPClass;
54
55/* These mostly correspond to the similarly-named states in section
56 * 9.1 of the XSMP spec. Some of the states there aren't represented
57 * here, because we don't need them. SHUTDOWN_CANCELLED is slightly
58 * different from the spec; we use it when the client is IDLE after a
59 * ShutdownCancelled message, but the application is still interacting
60 * and doesn't know the shutdown has been cancelled yet.
61 */
62typedef enum
63{
64 XSMP_STATE_IDLE,
65 XSMP_STATE_SAVE_YOURSELF,
66 XSMP_STATE_INTERACT_REQUEST,
67 XSMP_STATE_INTERACT,
68 XSMP_STATE_SAVE_YOURSELF_DONE,
69 XSMP_STATE_SHUTDOWN_CANCELLED,
70 XSMP_STATE_CONNECTION_CLOSED
71} EggSMClientXSMPState;
72
73static const char *state_names[] =
74{
75 "idle",
76 "save-yourself",
77 "interact-request",
78 "interact",
79 "save-yourself-done",
80 "shutdown-cancelled",
81 "connection-closed"
82};
83
84#define EGG_SM_CLIENT_XSMP_STATE(xsmp)(state_names[(xsmp)->state]) (state_names[(xsmp)->state])
85
86struct _EggSMClientXSMP
87{
88 EggSMClient parent;
89
90 SmcConn connection;
91 char *client_id;
92
93 EggSMClientXSMPState state;
94 char **restart_command;
95 gboolean set_restart_command;
96 int restart_style;
97 char **discard_command;
98 gboolean set_discard_command;
99
100 guint idle;
101
102 /* Current SaveYourself state */
103 guint expecting_initial_save_yourself : 1;
104 guint need_save_state : 1;
105 guint need_quit_requested : 1;
106 guint interact_errors : 1;
107 guint shutting_down : 1;
108
109 /* Todo list */
110 guint waiting_to_set_initial_properties : 1;
111 guint waiting_to_emit_quit : 1;
112 guint waiting_to_emit_quit_cancelled : 1;
113 guint waiting_to_save_myself : 1;
114
115};
116
117struct _EggSMClientXSMPClass
118{
119 EggSMClientClass parent_class;
120
121};
122
123static void sm_client_xsmp_startup (EggSMClient *client,
124 const char *client_id);
125static void sm_client_xsmp_set_restart_command (EggSMClient *client,
126 int argc,
127 const char **argv);
128static void sm_client_xsmp_set_discard_command (EggSMClient *client,
129 int argc,
130 const char **argv);
131static void sm_client_xsmp_will_quit (EggSMClient *client,
132 gboolean will_quit);
133static gboolean sm_client_xsmp_end_session (EggSMClient *client,
134 EggSMClientEndStyle style,
135 gboolean request_confirmation);
136
137static void xsmp_save_yourself (SmcConn smc_conn,
138 SmPointer client_data,
139 int save_style,
140 Boolint shutdown,
141 int interact_style,
142 Boolint fast);
143static void xsmp_die (SmcConn smc_conn,
144 SmPointer client_data);
145static void xsmp_save_complete (SmcConn smc_conn,
146 SmPointer client_data);
147static void xsmp_shutdown_cancelled (SmcConn smc_conn,
148 SmPointer client_data);
149static void xsmp_interact (SmcConn smc_conn,
150 SmPointer client_data);
151
152static SmProp *array_prop (const char *name,
153 ...);
154static SmProp *ptrarray_prop (const char *name,
155 GPtrArray *values);
156static SmProp *string_prop (const char *name,
157 const char *value);
158static SmProp *card8_prop (const char *name,
159 unsigned char value);
160
161static void set_properties (EggSMClientXSMP *xsmp, ...);
162static void delete_properties (EggSMClientXSMP *xsmp, ...);
163
164static GPtrArray *generate_command (char **restart_command,
165 const char *client_id,
166 const char *state_file);
167
168static void save_state (EggSMClientXSMP *xsmp);
169static void do_save_yourself (EggSMClientXSMP *xsmp);
170static void update_pending_events (EggSMClientXSMP *xsmp);
171
172static void ice_init (void);
173static gboolean process_ice_messages (IceConn ice_conn);
174static void smc_error_handler (SmcConn smc_conn,
175 Boolint swap,
176 int offending_minor_opcode,
177 unsigned long offending_sequence,
178 int error_class,
179 int severity,
180 SmPointer values);
181
182G_DEFINE_TYPE (EggSMClientXSMP, egg_sm_client_xsmp, EGG_TYPE_SM_CLIENT)static void egg_sm_client_xsmp_init (EggSMClientXSMP *self); static
void egg_sm_client_xsmp_class_init (EggSMClientXSMPClass *klass
); static GType egg_sm_client_xsmp_get_type_once (void); static
gpointer egg_sm_client_xsmp_parent_class = ((void*)0); static
gint EggSMClientXSMP_private_offset; static void egg_sm_client_xsmp_class_intern_init
(gpointer klass) { egg_sm_client_xsmp_parent_class = g_type_class_peek_parent
(klass); if (EggSMClientXSMP_private_offset != 0) g_type_class_adjust_private_offset
(klass, &EggSMClientXSMP_private_offset); egg_sm_client_xsmp_class_init
((EggSMClientXSMPClass*) klass); } __attribute__ ((__unused__
)) static inline gpointer egg_sm_client_xsmp_get_instance_private
(EggSMClientXSMP *self) { return (((gpointer) ((guint8*) (self
) + (glong) (EggSMClientXSMP_private_offset)))); } GType egg_sm_client_xsmp_get_type
(void) { static GType static_g_define_type_id = 0; if ((__extension__
({ _Static_assert (sizeof *(&static_g_define_type_id) ==
sizeof (gpointer), "Expression evaluates to false"); (void) (
0 ? (gpointer) * (&static_g_define_type_id) : ((void*)0))
; (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter_pointer (
&static_g_define_type_id)); })) ) { GType g_define_type_id
= egg_sm_client_xsmp_get_type_once (); (__extension__ ({ _Static_assert
(sizeof *(&static_g_define_type_id) == sizeof (gpointer)
, "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id
) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer
((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id
)); })) ; } return static_g_define_type_id; } __attribute__ (
(__noinline__)) static GType egg_sm_client_xsmp_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
((egg_sm_client_get_type ()), g_intern_static_string ("EggSMClientXSMP"
), sizeof (EggSMClientXSMPClass), (GClassInitFunc)(void (*)(void
)) egg_sm_client_xsmp_class_intern_init, sizeof (EggSMClientXSMP
), (GInstanceInitFunc)(void (*)(void)) egg_sm_client_xsmp_init
, (GTypeFlags) 0); { {{};} } return g_define_type_id; }
183
184static void
185egg_sm_client_xsmp_init (EggSMClientXSMP *xsmp)
186{
187 xsmp->state = XSMP_STATE_CONNECTION_CLOSED;
188 xsmp->connection = NULL((void*)0);
189 xsmp->restart_style = SmRestartIfRunning0;
190}
191
192static void
193egg_sm_client_xsmp_class_init (EggSMClientXSMPClass *klass)
194{
195 EggSMClientClass *sm_client_class = EGG_SM_CLIENT_CLASS (klass);
196
197 sm_client_class->startup = sm_client_xsmp_startup;
198 sm_client_class->set_restart_command = sm_client_xsmp_set_restart_command;
199 sm_client_class->set_discard_command = sm_client_xsmp_set_discard_command;
200 sm_client_class->will_quit = sm_client_xsmp_will_quit;
201 sm_client_class->end_session = sm_client_xsmp_end_session;
202}
203
204EggSMClient *
205egg_sm_client_xsmp_new (void)
206{
207 if (!g_getenv ("SESSION_MANAGER"))
208 return NULL((void*)0);
209
210 return g_object_new (EGG_TYPE_SM_CLIENT_XSMP(egg_sm_client_xsmp_get_type ()), NULL((void*)0));
211}
212
213static gboolean
214sm_client_xsmp_set_initial_properties (gpointer user_data)
215{
216 EggSMClientXSMP *xsmp = user_data;
217 EggDesktopFile *desktop_file;
218 GPtrArray *clone, *restart;
219 char pid_str[64];
220
221 if (xsmp->idle)
222 {
223 g_source_remove (xsmp->idle);
224 xsmp->idle = 0;
225 }
226 xsmp->waiting_to_set_initial_properties = FALSE(0);
227
228 if (egg_sm_client_get_mode () == EGG_SM_CLIENT_MODE_NO_RESTART)
229 xsmp->restart_style = SmRestartNever3;
230
231 /* Parse info out of desktop file */
232 desktop_file = egg_get_desktop_file ();
233 if (desktop_file)
234 {
235 GError *err = NULL((void*)0);
236 char **argv;
237 int argc;
238
239 if (xsmp->restart_style == SmRestartIfRunning0)
240 {
241 if (egg_desktop_file_get_boolean (desktop_file,
242 "X-MATE-AutoRestart", NULL((void*)0)))
243 xsmp->restart_style = SmRestartImmediately2;
244 }
245
246 if (!xsmp->set_restart_command)
247 {
248 char *cmdline;
249
250 cmdline = egg_desktop_file_parse_exec (desktop_file, NULL((void*)0), &err);
251 if (cmdline && g_shell_parse_argv (cmdline, &argc, &argv, &err))
252 {
253 egg_sm_client_set_restart_command (EGG_SM_CLIENT (xsmp),
254 argc, (const char **)argv);
255 g_strfreev (argv);
256 }
257 else
258 {
259 g_warning ("Could not parse Exec line in desktop file: %s",
260 err->message);
261 g_error_free (err);
262 }
263 g_free (cmdline);
264 }
265 }
266
267 if (!xsmp->set_restart_command)
268 xsmp->restart_command = g_strsplit (g_get_prgname (), " ", -1);
269
270 clone = generate_command (xsmp->restart_command, NULL((void*)0), NULL((void*)0));
271 restart = generate_command (xsmp->restart_command, xsmp->client_id, NULL((void*)0));
272
273 g_debug ("Setting initial properties");
274
275 /* Program, CloneCommand, RestartCommand, and UserID are required.
276 * ProcessID isn't required, but the SM may be able to do something
277 * useful with it.
278 */
279 g_snprintf (pid_str, sizeof (pid_str), "%lu", (gulong) getpid ());
280 set_properties (xsmp,
281 string_prop (SmProgram"Program", g_get_prgname ()),
282 ptrarray_prop (SmCloneCommand"CloneCommand", clone),
283 ptrarray_prop (SmRestartCommand"RestartCommand", restart),
284 string_prop (SmUserID"UserID", g_get_user_name ()),
285 string_prop (SmProcessID"ProcessID", pid_str),
286 card8_prop (SmRestartStyleHint"RestartStyleHint", xsmp->restart_style),
287 NULL((void*)0));
288 g_ptr_array_free (clone, TRUE(!(0)));
289 g_ptr_array_free (restart, TRUE(!(0)));
290
291 if (desktop_file)
292 {
293 set_properties (xsmp,
294 string_prop ("_GSM_DesktopFile", egg_desktop_file_get_source (desktop_file)),
295 NULL((void*)0));
296 }
297
298 update_pending_events (xsmp);
299 return FALSE(0);
300}
301
302/* This gets called from two different places: xsmp_die() (when the
303 * server asks us to disconnect) and process_ice_messages() (when the
304 * server disconnects unexpectedly).
305 */
306static void
307sm_client_xsmp_disconnect (EggSMClientXSMP *xsmp)
308{
309 SmcConn connection;
310
311 if (!xsmp->connection)
312 return;
313
314 g_debug ("Disconnecting");
315
316 connection = xsmp->connection;
317 xsmp->connection = NULL((void*)0);
318 SmcCloseConnection (connection, 0, NULL((void*)0));
319 xsmp->state = XSMP_STATE_CONNECTION_CLOSED;
320
321 xsmp->waiting_to_save_myself = FALSE(0);
322 update_pending_events (xsmp);
323}
324
325static void
326sm_client_xsmp_startup (EggSMClient *client,
327 const char *client_id)
328{
329 EggSMClientXSMP *xsmp = (EggSMClientXSMP *)client;
330 SmcCallbacks callbacks;
331 char *ret_client_id;
332 char error_string_ret[256];
333
334 xsmp->client_id = g_strdup (client_id)g_strdup_inline (client_id);
335
336 ice_init ();
337 SmcSetErrorHandler (smc_error_handler);
338
339 callbacks.save_yourself.callback = xsmp_save_yourself;
340 callbacks.die.callback = xsmp_die;
341 callbacks.save_complete.callback = xsmp_save_complete;
342 callbacks.shutdown_cancelled.callback = xsmp_shutdown_cancelled;
343
344 callbacks.save_yourself.client_data = xsmp;
345 callbacks.die.client_data = xsmp;
346 callbacks.save_complete.client_data = xsmp;
347 callbacks.shutdown_cancelled.client_data = xsmp;
348
349 client_id = NULL((void*)0);
350 error_string_ret[0] = '\0';
351 xsmp->connection =
352 SmcOpenConnection (NULL((void*)0), xsmp, SmProtoMajor1, SmProtoMinor0,
353 SmcSaveYourselfProcMask(1L << 0) | SmcDieProcMask(1L << 1) |
354 SmcSaveCompleteProcMask(1L << 2) |
355 SmcShutdownCancelledProcMask(1L << 3),
356 &callbacks,
357 xsmp->client_id, &ret_client_id,
358 sizeof (error_string_ret), error_string_ret);
359
360 if (!xsmp->connection)
361 {
362 g_warning ("Failed to connect to the session manager: %s\n",
363 error_string_ret[0] ?
364 error_string_ret : "no error message given");
365 xsmp->state = XSMP_STATE_CONNECTION_CLOSED;
366 return;
367 }
368
369 /* We expect a pointless initial SaveYourself if either (a) we
370 * didn't have an initial client ID, or (b) we DID have an initial
371 * client ID, but the server rejected it and gave us a new one.
372 */
373 if (!xsmp->client_id ||
374 (ret_client_id && strcmp (xsmp->client_id, ret_client_id) != 0))
375 xsmp->expecting_initial_save_yourself = TRUE(!(0));
376
377 if (ret_client_id)
378 {
379 g_free (xsmp->client_id);
380 xsmp->client_id = g_strdup (ret_client_id)g_strdup_inline (ret_client_id);
381 free (ret_client_id);
382
383#if defined(GDK_WINDOWING_X11) || defined(HAVE_X111)
384 if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gdk_display_get_default ())); GType __t = ((gdk_x11_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
)
385 gdk_x11_set_sm_client_id (xsmp->client_id);
386#endif
387
388 g_debug ("Got client ID \"%s\"", xsmp->client_id);
389 }
390
391 xsmp->state = XSMP_STATE_IDLE;
392
393 /* Do not set the initial properties until we reach the main loop,
394 * so that the application has a chance to call
395 * egg_set_desktop_file(). (This may also help the session manager
396 * have a better idea of when the application is fully up and
397 * running.)
398 */
399 xsmp->waiting_to_set_initial_properties = TRUE(!(0));
400 xsmp->idle = g_idle_add (sm_client_xsmp_set_initial_properties, client);
401}
402
403static void
404sm_client_xsmp_set_restart_command (EggSMClient *client,
405 int argc,
406 const char **argv)
407{
408 EggSMClientXSMP *xsmp = (EggSMClientXSMP *)client;
409 int i;
410
411 g_strfreev (xsmp->restart_command);
412
413 xsmp->restart_command = g_new (char *, argc + 1)((char * *) g_malloc_n ((argc + 1), sizeof (char *)));
414 for (i = 0; i < argc; i++)
415 xsmp->restart_command[i] = g_strdup (argv[i])g_strdup_inline (argv[i]);
416 xsmp->restart_command[i] = NULL((void*)0);
417
418 xsmp->set_restart_command = TRUE(!(0));
419}
420
421static void
422sm_client_xsmp_set_discard_command (EggSMClient *client,
423 int argc,
424 const char **argv)
425{
426 EggSMClientXSMP *xsmp = (EggSMClientXSMP *)client;
427 int i;
428
429 g_strfreev (xsmp->discard_command);
430
431 xsmp->discard_command = g_new (char *, argc + 1)((char * *) g_malloc_n ((argc + 1), sizeof (char *)));
432 for (i = 0; i < argc; i++)
433 xsmp->discard_command[i] = g_strdup (argv[i])g_strdup_inline (argv[i]);
434 xsmp->discard_command[i] = NULL((void*)0);
435
436 xsmp->set_discard_command = TRUE(!(0));
437}
438
439static void
440sm_client_xsmp_will_quit (EggSMClient *client,
441 gboolean will_quit)
442{
443 EggSMClientXSMP *xsmp = (EggSMClientXSMP *)client;
444
445 if (xsmp->state == XSMP_STATE_CONNECTION_CLOSED)
446 {
447 /* The session manager has already exited! Schedule a quit
448 * signal.
449 */
450 xsmp->waiting_to_emit_quit = TRUE(!(0));
451 update_pending_events (xsmp);
452 return;
453 }
454 else if (xsmp->state == XSMP_STATE_SHUTDOWN_CANCELLED)
455 {
456 /* We received a ShutdownCancelled message while the application
457 * was interacting; Schedule a quit_cancelled signal.
458 */
459 xsmp->waiting_to_emit_quit_cancelled = TRUE(!(0));
460 update_pending_events (xsmp);
461 return;
462 }
463
464 g_return_if_fail (xsmp->state == XSMP_STATE_INTERACT)do { if ((xsmp->state == XSMP_STATE_INTERACT)) { } else { g_return_if_fail_warning
("EggSMClient", ((const char*) (__func__)), "xsmp->state == XSMP_STATE_INTERACT"
); return; } } while (0)
;
465
466 g_debug ("Sending InteractDone(%s)", will_quit ? "False" : "True");
467 SmcInteractDone (xsmp->connection, !will_quit);
468
469 if (will_quit && xsmp->need_save_state)
470 save_state (xsmp);
471
472 g_debug ("Sending SaveYourselfDone(%s)", will_quit ? "True" : "False");
473 SmcSaveYourselfDone (xsmp->connection, will_quit);
474 xsmp->state = XSMP_STATE_SAVE_YOURSELF_DONE;
475}
476
477static gboolean
478sm_client_xsmp_end_session (EggSMClient *client,
479 EggSMClientEndStyle style,
480 gboolean request_confirmation)
481{
482 EggSMClientXSMP *xsmp = (EggSMClientXSMP *)client;
483 int save_type;
484
485 /* To end the session via XSMP, we have to send a
486 * SaveYourselfRequest. We aren't allowed to do that if anything
487 * else is going on, but we don't want to expose this fact to the
488 * application. So we do our best to patch things up here...
489 *
490 * In the worst case, this method might block for some length of
491 * time in process_ice_messages, but the only time that code path is
492 * honestly likely to get hit is if the application tries to end the
493 * session as the very first thing it does, in which case it
494 * probably won't actually block anyway. It's not worth gunking up
495 * the API to try to deal nicely with the other 0.01% of cases where
496 * this happens.
497 */
498
499 while (xsmp->state != XSMP_STATE_IDLE ||
500 xsmp->expecting_initial_save_yourself)
501 {
502 /* If we're already shutting down, we don't need to do anything. */
503 if (xsmp->shutting_down)
504 return TRUE(!(0));
505
506 switch (xsmp->state)
507 {
508 case XSMP_STATE_CONNECTION_CLOSED:
509 return FALSE(0);
510
511 case XSMP_STATE_SAVE_YOURSELF:
512 /* Trying to log out from the save_state callback? Whatever.
513 * Abort the save_state.
514 */
515 SmcSaveYourselfDone (xsmp->connection, FALSE(0));
516 xsmp->state = XSMP_STATE_SAVE_YOURSELF_DONE;
517 break;
518
519 case XSMP_STATE_INTERACT_REQUEST:
520 case XSMP_STATE_INTERACT:
521 case XSMP_STATE_SHUTDOWN_CANCELLED:
522 /* Already in a shutdown-related state, just ignore
523 * the new shutdown request...
524 */
525 return TRUE(!(0));
526
527 case XSMP_STATE_IDLE:
528 if (xsmp->waiting_to_set_initial_properties)
529 sm_client_xsmp_set_initial_properties (xsmp);
530
531 if (!xsmp->expecting_initial_save_yourself)
532 break;
533 /* else fall through */
534
535 case XSMP_STATE_SAVE_YOURSELF_DONE:
536 /* We need to wait for some response from the server.*/
537 process_ice_messages (SmcGetIceConnection (xsmp->connection));
538 break;
539
540 default:
541 /* Hm... shouldn't happen */
542 return FALSE(0);
543 }
544 }
545
546 /* xfce4-session will do the wrong thing if we pass SmSaveGlobal and
547 * the user chooses to save the session. But mate-session will do
548 * the wrong thing if we pass SmSaveBoth and the user chooses NOT to
549 * save the session... Sigh.
550 */
551 if (!strcmp (SmcVendor (xsmp->connection), "xfce4-session"))
552 save_type = SmSaveBoth2;
553 else
554 save_type = SmSaveGlobal0;
555
556 g_debug ("Sending SaveYourselfRequest(SmSaveGlobal, Shutdown, SmInteractStyleAny, %sFast)", request_confirmation ? "!" : "");
557 SmcRequestSaveYourself (xsmp->connection,
558 save_type,
559 True1, /* shutdown */
560 SmInteractStyleAny2,
561 !request_confirmation, /* fast */
562 True1 /* global */);
563 return TRUE(!(0));
564}
565
566static gboolean
567idle_do_pending_events (gpointer data)
568{
569 EggSMClientXSMP *xsmp = data;
570 EggSMClient *client = data;
571
572 xsmp->idle = 0;
573
574 if (xsmp->waiting_to_emit_quit)
575 {
576 xsmp->waiting_to_emit_quit = FALSE(0);
577 egg_sm_client_quit (client);
578 goto out;
579 }
580
581 if (xsmp->waiting_to_emit_quit_cancelled)
582 {
583 xsmp->waiting_to_emit_quit_cancelled = FALSE(0);
584 egg_sm_client_quit_cancelled (client);
585 xsmp->state = XSMP_STATE_IDLE;
586 }
587
588 if (xsmp->waiting_to_save_myself)
589 {
590 xsmp->waiting_to_save_myself = FALSE(0);
591 do_save_yourself (xsmp);
592 }
593
594out:
595 return FALSE(0);
596}
597
598static void
599update_pending_events (EggSMClientXSMP *xsmp)
600{
601 gboolean want_idle =
602 xsmp->waiting_to_emit_quit ||
603 xsmp->waiting_to_emit_quit_cancelled ||
604 xsmp->waiting_to_save_myself;
605
606 if (want_idle)
607 {
608 if (xsmp->idle == 0)
609 xsmp->idle = g_idle_add (idle_do_pending_events, xsmp);
610 }
611 else
612 {
613 if (xsmp->idle != 0)
614 g_source_remove (xsmp->idle);
615 xsmp->idle = 0;
616 }
617}
618
619static void
620fix_broken_state (EggSMClientXSMP *xsmp, const char *message,
621 gboolean send_interact_done,
622 gboolean send_save_yourself_done)
623{
624 g_warning ("Received XSMP %s message in state %s: client or server error",
625 message, EGG_SM_CLIENT_XSMP_STATE (xsmp)(state_names[(xsmp)->state]));
626
627 /* Forget any pending SaveYourself plans we had */
628 xsmp->waiting_to_save_myself = FALSE(0);
629 update_pending_events (xsmp);
630
631 if (send_interact_done)
632 SmcInteractDone (xsmp->connection, False0);
633 if (send_save_yourself_done)
634 SmcSaveYourselfDone (xsmp->connection, True1);
635
636 xsmp->state = send_save_yourself_done ? XSMP_STATE_SAVE_YOURSELF_DONE : XSMP_STATE_IDLE;
637}
638
639/* SM callbacks */
640
641static void
642xsmp_save_yourself (SmcConn smc_conn,
643 SmPointer client_data,
644 int save_type,
645 Boolint shutdown,
646 int interact_style,
647 Boolint fast)
648{
649 EggSMClientXSMP *xsmp = client_data;
650 gboolean wants_quit_requested;
651
652 g_debug ("Received SaveYourself(%s, %s, %s, %s) in state %s",
653 save_type == SmSaveLocal1 ? "SmSaveLocal" :
654 save_type == SmSaveGlobal0 ? "SmSaveGlobal" : "SmSaveBoth",
655 shutdown ? "Shutdown" : "!Shutdown",
656 interact_style == SmInteractStyleAny2 ? "SmInteractStyleAny" :
657 interact_style == SmInteractStyleErrors1 ? "SmInteractStyleErrors" :
658 "SmInteractStyleNone", fast ? "Fast" : "!Fast",
659 EGG_SM_CLIENT_XSMP_STATE (xsmp)(state_names[(xsmp)->state]));
660
661 if (xsmp->state != XSMP_STATE_IDLE &&
662 xsmp->state != XSMP_STATE_SHUTDOWN_CANCELLED)
663 {
664 fix_broken_state (xsmp, "SaveYourself", FALSE(0), TRUE(!(0)));
665 return;
666 }
667
668 if (xsmp->waiting_to_set_initial_properties)
669 sm_client_xsmp_set_initial_properties (xsmp);
670
671 /* If this is the initial SaveYourself, ignore it; we've already set
672 * properties and there's no reason to actually save state too.
673 */
674 if (xsmp->expecting_initial_save_yourself)
675 {
676 xsmp->expecting_initial_save_yourself = FALSE(0);
677
678 if (save_type == SmSaveLocal1 &&
679 interact_style == SmInteractStyleNone0 &&
680 !shutdown && !fast)
681 {
682 g_debug ("Sending SaveYourselfDone(True) for initial SaveYourself");
683 SmcSaveYourselfDone (xsmp->connection, True1);
684 /* As explained in the comment at the end of
685 * do_save_yourself(), SAVE_YOURSELF_DONE is the correct
686 * state here, not IDLE.
687 */
688 xsmp->state = XSMP_STATE_SAVE_YOURSELF_DONE;
689 return;
690 }
691 else
692 g_warning ("First SaveYourself was not the expected one!");
693 }
694
695 /* Even ignoring the "fast" flag completely, there are still 18
696 * different combinations of save_type, shutdown and interact_style.
697 * We interpret them as follows:
698 *
699 * Type Shutdown Interact Interpretation
700 * G F A/E/N do nothing (1)
701 * G T N do nothing (1)*
702 * G T A/E quit_requested (2)
703 * L/B F A/E/N save_state (3)
704 * L/B T N save_state (3)*
705 * L/B T A/E quit_requested, then save_state (4)
706 *
707 * 1. Do nothing, because the SM asked us to do something
708 * uninteresting (save open files, but then don't quit
709 * afterward) or rude (save open files without asking the user
710 * for confirmation).
711 *
712 * 2. Request interaction and then emit ::quit_requested. This
713 * perhaps isn't quite correct for the SmInteractStyleErrors
714 * case, but we don't care.
715 *
716 * 3. Emit ::save_state. The SmSaveBoth SaveYourselfs in these
717 * rows essentially get demoted to SmSaveLocal, because their
718 * Global halves correspond to "do nothing".
719 *
720 * 4. Request interaction, emit ::quit_requested, and then emit
721 * ::save_state after interacting. This is the SmSaveBoth
722 * equivalent of #2, but we also promote SmSaveLocal shutdown
723 * SaveYourselfs to SmSaveBoth here, because we want to give
724 * the user a chance to save open files before quitting.
725 *
726 * (* It would be nice if we could do something useful when the
727 * session manager sends a SaveYourself with shutdown True and
728 * SmInteractStyleNone. But we can't, so we just pretend it didn't
729 * even tell us it was shutting down. The docs for ::quit mention
730 * that it might not always be preceded by ::quit_requested.)
731 */
732
733 /* As an optimization, we don't actually request interaction and
734 * emit ::quit_requested if the application isn't listening to the
735 * signal.
736 */
737 wants_quit_requested = g_signal_has_handler_pending (xsmp, g_signal_lookup ("quit_requested", EGG_TYPE_SM_CLIENT(egg_sm_client_get_type ())), 0, FALSE(0));
738
739 xsmp->need_save_state = (save_type != SmSaveGlobal0);
740 xsmp->need_quit_requested = (shutdown && wants_quit_requested &&
741 interact_style != SmInteractStyleNone0);
742 xsmp->interact_errors = (interact_style == SmInteractStyleErrors1);
743
744 xsmp->shutting_down = shutdown;
745
746 do_save_yourself (xsmp);
747}
748
749static void
750do_save_yourself (EggSMClientXSMP *xsmp)
751{
752 if (xsmp->state == XSMP_STATE_SHUTDOWN_CANCELLED)
753 {
754 /* The SM cancelled a previous SaveYourself, but we haven't yet
755 * had a chance to tell the application, so we can't start
756 * processing this SaveYourself yet.
757 */
758 xsmp->waiting_to_save_myself = TRUE(!(0));
759 update_pending_events (xsmp);
760 return;
761 }
762
763 if (xsmp->need_quit_requested)
764 {
765 xsmp->state = XSMP_STATE_INTERACT_REQUEST;
766
767 g_debug ("Sending InteractRequest(%s)",
768 xsmp->interact_errors ? "Error" : "Normal");
769 SmcInteractRequest (xsmp->connection,
770 xsmp->interact_errors ? SmDialogError0 : SmDialogNormal1,
771 xsmp_interact,
772 xsmp);
773 return;
774 }
775
776 if (xsmp->need_save_state)
777 {
778 save_state (xsmp);
779
780 /* Though unlikely, the client could have been disconnected
781 * while the application was saving its state.
782 */
783 if (!xsmp->connection)
784 return;
785 }
786
787 g_debug ("Sending SaveYourselfDone(True)");
788 SmcSaveYourselfDone (xsmp->connection, True1);
789
790 /* The client state diagram in the XSMP spec says that after a
791 * non-shutdown SaveYourself, we go directly back to "idle". But
792 * everything else in both the XSMP spec and the libSM docs
793 * disagrees.
794 */
795 xsmp->state = XSMP_STATE_SAVE_YOURSELF_DONE;
796}
797
798static void
799save_state (EggSMClientXSMP *xsmp)
800{
801 GKeyFile *state_file;
802 char *state_file_path, *data;
803 EggDesktopFile *desktop_file;
804 GPtrArray *restart, *discard;
805 int offset, fd;
806
807 /* We set xsmp->state before emitting save_state, but our caller is
808 * responsible for setting it back afterward.
809 */
810 xsmp->state = XSMP_STATE_SAVE_YOURSELF;
811
812 state_file = egg_sm_client_save_state ((EggSMClient *)xsmp);
813 if (!state_file)
814 {
815 restart = generate_command (xsmp->restart_command, xsmp->client_id, NULL((void*)0));
816 set_properties (xsmp,
817 ptrarray_prop (SmRestartCommand"RestartCommand", restart),
818 NULL((void*)0));
819 g_ptr_array_free (restart, TRUE(!(0)));
820
821 if (xsmp->set_discard_command)
822 {
823 discard = generate_command (xsmp->discard_command, NULL((void*)0), NULL((void*)0));
824 set_properties (xsmp,
825 ptrarray_prop (SmDiscardCommand"DiscardCommand", discard),
826 NULL((void*)0));
827 g_ptr_array_free (discard, TRUE(!(0)));
828 }
829 else
830 delete_properties (xsmp, SmDiscardCommand"DiscardCommand", NULL((void*)0));
831
832 return;
833 }
834
835 desktop_file = egg_get_desktop_file ();
836 if (desktop_file)
837 {
838 GKeyFile *merged_file;
839 char *desktop_file_path;
840
841 merged_file = g_key_file_new ();
842 desktop_file_path =
843 g_filename_from_uri (egg_desktop_file_get_source (desktop_file),
844 NULL((void*)0), NULL((void*)0));
845 if (desktop_file_path &&
846 g_key_file_load_from_file (merged_file, desktop_file_path,
847 G_KEY_FILE_KEEP_COMMENTS |
848 G_KEY_FILE_KEEP_TRANSLATIONS, NULL((void*)0)))
849 {
850 guint g, k, i;
851 char **groups, **keys, *value, *exec;
852
853 groups = g_key_file_get_groups (state_file, NULL((void*)0));
854 for (g = 0; groups[g]; g++)
855 {
856 keys = g_key_file_get_keys (state_file, groups[g], NULL((void*)0), NULL((void*)0));
857 for (k = 0; keys[k]; k++)
858 {
859 value = g_key_file_get_value (state_file, groups[g],
860 keys[k], NULL((void*)0));
861 if (value)
862 {
863 g_key_file_set_value (merged_file, groups[g],
864 keys[k], value);
865 g_free (value);
866 }
867 }
868 g_strfreev (keys);
869 }
870 g_strfreev (groups);
871
872 g_key_file_free (state_file);
873 state_file = merged_file;
874
875 /* Update Exec key using "--sm-client-state-file %k" */
876 restart = generate_command (xsmp->restart_command,
877 NULL((void*)0), "%k");
878 for (i = 0; i < restart->len; i++)
879 restart->pdata[i] = g_shell_quote (restart->pdata[i]);
880 g_ptr_array_add (restart, NULL((void*)0));
881 exec = g_strjoinv (" ", (char **)restart->pdata);
882 g_strfreev ((char **)restart->pdata);
883 g_ptr_array_free (restart, FALSE(0));
884
885 g_key_file_set_string (state_file, EGG_DESKTOP_FILE_GROUP"Desktop Entry",
886 EGG_DESKTOP_FILE_KEY_EXEC"Exec",
887 exec);
888 g_free (exec);
889 }
890 else
891 desktop_file = NULL((void*)0);
892
893 g_free (desktop_file_path);
894 }
895
896 /* Now write state_file to disk. (We can't use mktemp(), because
897 * that requires the filename to end with "XXXXXX", and we want
898 * it to end with ".desktop".)
899 */
900
901 data = g_key_file_to_data (state_file, NULL((void*)0), NULL((void*)0));
902 g_key_file_free (state_file);
903
904 offset = 0;
905 while (1)
906 {
907 state_file_path = g_strdup_printf ("%s%csession-state%c%s-%ld.%s",
908 g_get_user_config_dir (),
909 G_DIR_SEPARATOR'/', G_DIR_SEPARATOR'/',
910 g_get_prgname (),
911 (long)time (NULL((void*)0)) + offset,
912 desktop_file ? "desktop" : "state");
913
914 fd = open (state_file_path, O_WRONLY01 | O_CREAT0100 | O_EXCL0200, 0644);
915 if (fd == -1)
916 {
917 if (errno(*__errno_location ()) == EEXIST17)
918 {
919 offset++;
920 g_free (state_file_path);
921 continue;
922 }
923 else if (errno(*__errno_location ()) == ENOTDIR20 || errno(*__errno_location ()) == ENOENT2)
924 {
925 char *sep = strrchr (state_file_path, G_DIR_SEPARATOR'/');
926
927 *sep = '\0';
928 if (g_mkdir_with_parents (state_file_path, 0755) != 0)
929 {
930 g_warning ("Could not create directory '%s'",
931 state_file_path);
932 g_free (state_file_path);
933 state_file_path = NULL((void*)0);
934 break;
935 }
936
937 continue;
938 }
939
940 g_warning ("Could not create file '%s': %s",
941 state_file_path, g_strerror (errno(*__errno_location ())));
942 g_free (state_file_path);
943 state_file_path = NULL((void*)0);
944 break;
945 }
946
947 close (fd);
948 g_file_set_contents (state_file_path, data, -1, NULL((void*)0));
949 break;
950 }
951 g_free (data);
952
953 restart = generate_command (xsmp->restart_command, xsmp->client_id,
954 state_file_path);
955 set_properties (xsmp,
956 ptrarray_prop (SmRestartCommand"RestartCommand", restart),
957 NULL((void*)0));
958 g_ptr_array_free (restart, TRUE(!(0)));
959
960 if (state_file_path)
961 {
962 set_properties (xsmp,
963 array_prop (SmDiscardCommand"DiscardCommand",
964 "/bin/rm", "-rf", state_file_path,
965 NULL((void*)0)),
966 NULL((void*)0));
967 g_free (state_file_path);
968 }
969}
970
971static void
972xsmp_interact (SmcConn smc_conn,
973 SmPointer client_data)
974{
975 EggSMClientXSMP *xsmp = client_data;
976 EggSMClient *client = client_data;
977
978 g_debug ("Received Interact message in state %s",
979 EGG_SM_CLIENT_XSMP_STATE (xsmp)(state_names[(xsmp)->state]));
980
981 if (xsmp->state != XSMP_STATE_INTERACT_REQUEST)
982 {
983 fix_broken_state (xsmp, "Interact", TRUE(!(0)), TRUE(!(0)));
984 return;
985 }
986
987 xsmp->state = XSMP_STATE_INTERACT;
988 egg_sm_client_quit_requested (client);
989}
990
991static void
992xsmp_die (SmcConn smc_conn,
993 SmPointer client_data)
994{
995 EggSMClientXSMP *xsmp = client_data;
996 EggSMClient *client = client_data;
997
998 g_debug ("Received Die message in state %s",
999 EGG_SM_CLIENT_XSMP_STATE (xsmp)(state_names[(xsmp)->state]));
1000
1001 sm_client_xsmp_disconnect (xsmp);
1002 egg_sm_client_quit (client);
1003}
1004
1005static void
1006xsmp_save_complete (SmcConn smc_conn,
1007 SmPointer client_data)
1008{
1009 EggSMClientXSMP *xsmp = client_data;
1010
1011 g_debug ("Received SaveComplete message in state %s",
1012 EGG_SM_CLIENT_XSMP_STATE (xsmp)(state_names[(xsmp)->state]));
1013
1014 if (xsmp->state == XSMP_STATE_SAVE_YOURSELF_DONE)
1015 xsmp->state = XSMP_STATE_IDLE;
1016 else
1017 fix_broken_state (xsmp, "SaveComplete", FALSE(0), FALSE(0));
1018}
1019
1020static void
1021xsmp_shutdown_cancelled (SmcConn smc_conn,
1022 SmPointer client_data)
1023{
1024 EggSMClientXSMP *xsmp = client_data;
1025 EggSMClient *client = client_data;
1026
1027 g_debug ("Received ShutdownCancelled message in state %s",
1028 EGG_SM_CLIENT_XSMP_STATE (xsmp)(state_names[(xsmp)->state]));
1029
1030 xsmp->shutting_down = FALSE(0);
1031
1032 if (xsmp->state == XSMP_STATE_SAVE_YOURSELF_DONE)
1033 {
1034 /* We've finished interacting and now the SM has agreed to
1035 * cancel the shutdown.
1036 */
1037 xsmp->state = XSMP_STATE_IDLE;
1038 egg_sm_client_quit_cancelled (client);
1039 }
1040 else if (xsmp->state == XSMP_STATE_SHUTDOWN_CANCELLED)
1041 {
1042 /* Hm... ok, so we got a shutdown SaveYourself, which got
1043 * cancelled, but the application was still interacting, so we
1044 * didn't tell it yet, and then *another* SaveYourself arrived,
1045 * which we must still be waiting to tell the app about, except
1046 * that now that SaveYourself has been cancelled too! Dizzy yet?
1047 */
1048 xsmp->waiting_to_save_myself = FALSE(0);
1049 update_pending_events (xsmp);
1050 }
1051 else
1052 {
1053 g_debug ("Sending SaveYourselfDone(False)");
1054 SmcSaveYourselfDone (xsmp->connection, False0);
1055
1056 if (xsmp->state == XSMP_STATE_INTERACT)
1057 {
1058 /* The application is currently interacting, so we can't
1059 * tell it about the cancellation yet; we will wait until
1060 * after it calls egg_sm_client_will_quit().
1061 */
1062 xsmp->state = XSMP_STATE_SHUTDOWN_CANCELLED;
1063 }
1064 else
1065 {
1066 /* The shutdown was cancelled before the application got a
1067 * chance to interact.
1068 */
1069 xsmp->state = XSMP_STATE_IDLE;
1070 }
1071 }
1072}
1073
1074/* Utilities */
1075
1076/* Create a restart/clone/Exec command based on @restart_command.
1077 * If @client_id is non-%NULL, add "--sm-client-id @client_id".
1078 * If @state_file is non-%NULL, add "--sm-client-state-file @state_file".
1079 *
1080 * None of the input strings are g_strdup()ed; the caller must keep
1081 * them around until it is done with the returned GPtrArray, and must
1082 * then free the array, but not its contents.
1083 */
1084static GPtrArray *
1085generate_command (char **restart_command, const char *client_id,
1086 const char *state_file)
1087{
1088 GPtrArray *cmd;
1089 int i;
1090
1091 cmd = g_ptr_array_new ();
1092 g_ptr_array_add (cmd, restart_command[0]);
1093
1094 if (client_id)
1095 {
1096 g_ptr_array_add (cmd, (char *)"--sm-client-id");
1097 g_ptr_array_add (cmd, (char *)client_id);
1098 }
1099
1100 if (state_file)
1101 {
1102 g_ptr_array_add (cmd, (char *)"--sm-client-state-file");
1103 g_ptr_array_add (cmd, (char *)state_file);
1104 }
1105
1106 for (i = 1; restart_command[i]; i++)
1107 g_ptr_array_add (cmd, restart_command[i]);
1108
1109 return cmd;
1110}
1111
1112/* Takes a NULL-terminated list of SmProp * values, created by
1113 * array_prop, ptrarray_prop, string_prop, card8_prop, sets them, and
1114 * frees them.
1115 */
1116static void
1117set_properties (EggSMClientXSMP *xsmp, ...)
1118{
1119 GPtrArray *props;
1120 SmProp *prop;
1121 va_list ap;
1122 guint i;
1123
1124 props = g_ptr_array_new ();
1125
1126 va_start (ap, xsmp)__builtin_va_start(ap, xsmp);
1127 while ((prop = va_arg (ap, SmProp *)__builtin_va_arg(ap, SmProp *)))
1128 g_ptr_array_add (props, prop);
1129 va_end (ap)__builtin_va_end(ap);
1130
1131 if (xsmp->connection)
1132 {
1133 SmcSetProperties (xsmp->connection, props->len,
1134 (SmProp **)props->pdata);
1135 }
1136
1137 for (i = 0; i < props->len; i++)
1138 {
1139 prop = props->pdata[i];
1140 g_free (prop->vals);
1141 g_free (prop);
1142 }
1143 g_ptr_array_free (props, TRUE(!(0)));
1144}
1145
1146/* Takes a NULL-terminated list of property names and deletes them. */
1147static void
1148delete_properties (EggSMClientXSMP *xsmp, ...)
1149{
1150 GPtrArray *props;
1151 char *prop;
1152 va_list ap;
1153
1154 if (!xsmp->connection)
1155 return;
1156
1157 props = g_ptr_array_new ();
1158
1159 va_start (ap, xsmp)__builtin_va_start(ap, xsmp);
1160 while ((prop = va_arg (ap, char *)__builtin_va_arg(ap, char *)))
1161 g_ptr_array_add (props, prop);
1162 va_end (ap)__builtin_va_end(ap);
1163
1164 SmcDeleteProperties (xsmp->connection, props->len,
1165 (char **)props->pdata);
1166
1167 g_ptr_array_free (props, TRUE(!(0)));
1168}
1169
1170/* Takes an array of strings and creates a LISTofARRAY8 property. The
1171 * strings are neither dupped nor freed; they need to remain valid
1172 * until you're done with the SmProp.
1173 */
1174static SmProp *
1175array_prop (const char *name, ...)
1176{
1177 SmProp *prop;
1178 SmPropValue pv;
1179 GArray *vals;
1180 char *value;
1181 va_list ap;
1182
1183 prop = g_new (SmProp, 1)((SmProp *) g_malloc_n ((1), sizeof (SmProp)));
1184 prop->name = (char *)name;
1185 prop->type = (char *)SmLISTofARRAY8"LISTofARRAY8";
1186
1187 vals = g_array_new (FALSE(0), FALSE(0), sizeof (SmPropValue));
1188
1189 va_start (ap, name)__builtin_va_start(ap, name);
1190 while ((value = va_arg (ap, char *)__builtin_va_arg(ap, char *)))
1191 {
1192 pv.length = strlen (value);
1193 pv.value = value;
1194 g_array_append_val (vals, pv)g_array_append_vals (vals, &(pv), 1);
1195 }
1196 va_end (ap)__builtin_va_end(ap);
1197
1198 prop->num_vals = vals->len;
1199 prop->vals = (SmPropValue *)vals->data;
1200
1201 g_array_free (vals, FALSE(0));
1202
1203 return prop;
1204}
1205
1206/* Takes a GPtrArray of strings and creates a LISTofARRAY8 property.
1207 * The array contents are neither dupped nor freed; they need to
1208 * remain valid until you're done with the SmProp.
1209 */
1210static SmProp *
1211ptrarray_prop (const char *name, GPtrArray *values)
1212{
1213 SmProp *prop;
1214 SmPropValue pv;
1215 GArray *vals;
1216 guint i;
1217
1218 prop = g_new (SmProp, 1)((SmProp *) g_malloc_n ((1), sizeof (SmProp)));
1219 prop->name = (char *)name;
1220 prop->type = (char *)SmLISTofARRAY8"LISTofARRAY8";
1221
1222 vals = g_array_new (FALSE(0), FALSE(0), sizeof (SmPropValue));
1223
1224 for (i = 0; i < values->len; i++)
1225 {
1226 pv.length = strlen (values->pdata[i]);
1227 pv.value = values->pdata[i];
1228 g_array_append_val (vals, pv)g_array_append_vals (vals, &(pv), 1);
1229 }
1230
1231 prop->num_vals = vals->len;
1232 prop->vals = (SmPropValue *)vals->data;
Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption
1233
1234 g_array_free (vals, FALSE(0));
1235
1236 return prop;
1237}
1238
1239/* Takes a string and creates an ARRAY8 property. The string is
1240 * neither dupped nor freed; it needs to remain valid until you're
1241 * done with the SmProp.
1242 */
1243static SmProp *
1244string_prop (const char *name, const char *value)
1245{
1246 SmProp *prop;
1247
1248 prop = g_new (SmProp, 1)((SmProp *) g_malloc_n ((1), sizeof (SmProp)));
1249 prop->name = (char *)name;
1250 prop->type = (char *)SmARRAY8"ARRAY8";
1251
1252 prop->num_vals = 1;
1253 prop->vals = g_new (SmPropValue, 1)((SmPropValue *) g_malloc_n ((1), sizeof (SmPropValue)));
1254
1255 prop->vals[0].length = strlen (value);
1256 prop->vals[0].value = (char *)value;
1257
1258 return prop;
1259}
1260
1261/* Takes a char and creates a CARD8 property. */
1262static SmProp *
1263card8_prop (const char *name, unsigned char value)
1264{
1265 SmProp *prop;
1266 char *card8val;
1267
1268 /* To avoid having to allocate and free prop->vals[0], we cheat and
1269 * make vals a 2-element-long array and then use the second element
1270 * to store value.
1271 */
1272
1273 prop = g_new (SmProp, 1)((SmProp *) g_malloc_n ((1), sizeof (SmProp)));
1274 prop->name = (char *)name;
1275 prop->type = (char *)SmCARD8"CARD8";
1276
1277 prop->num_vals = 1;
1278 prop->vals = g_new (SmPropValue, 2)((SmPropValue *) g_malloc_n ((2), sizeof (SmPropValue)));
1279 card8val = (char *)(&prop->vals[1]);
1280 card8val[0] = value;
1281
1282 prop->vals[0].length = 1;
1283 prop->vals[0].value = card8val;
1284
1285 return prop;
1286}
1287
1288/* ICE code. This makes no effort to play nice with anyone else trying
1289 * to use libICE. Fortunately, no one uses libICE for anything other
1290 * than SM. (DCOP uses ICE, but it has its own private copy of
1291 * libICE.)
1292 *
1293 * When this moves to gtk, it will need to be cleverer, to avoid
1294 * tripping over old apps that use MateClient or that use libSM
1295 * directly.
1296 */
1297
1298#include <X11/ICE/ICElib.h>
1299#include <fcntl.h>
1300
1301static void ice_error_handler (IceConn ice_conn,
1302 Boolint swap,
1303 int offending_minor_opcode,
1304 unsigned long offending_sequence,
1305 int error_class,
1306 int severity,
1307 IcePointer values);
1308static void ice_io_error_handler (IceConn ice_conn);
1309static void ice_connection_watch (IceConn ice_conn,
1310 IcePointer client_data,
1311 Boolint opening,
1312 IcePointer *watch_data);
1313
1314static void
1315ice_init (void)
1316{
1317 IceSetIOErrorHandler (ice_io_error_handler);
1318 IceSetErrorHandler (ice_error_handler);
1319 IceAddConnectionWatch (ice_connection_watch, NULL((void*)0));
1320}
1321
1322static gboolean
1323process_ice_messages (IceConn ice_conn)
1324{
1325 IceProcessMessagesStatus status;
1326 status = IceProcessMessages (ice_conn, NULL((void*)0), NULL((void*)0));
1327
1328 switch (status)
1329 {
1330 case IceProcessMessagesSuccess:
1331 return TRUE(!(0));
1332
1333 case IceProcessMessagesIOError:
1334 sm_client_xsmp_disconnect (IceGetConnectionContext (ice_conn));
1335 return FALSE(0);
1336
1337 case IceProcessMessagesConnectionClosed:
1338 return FALSE(0);
1339
1340 default:
1341 g_assert_not_reached ()do { g_assertion_message_expr ("EggSMClient", "eggsmclient-xsmp.c"
, 1341, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1342 }
1343}
1344
1345static gboolean
1346ice_iochannel_watch (GIOChannel *channel,
1347 GIOCondition condition,
1348 gpointer client_data)
1349{
1350 return process_ice_messages (client_data);
1351}
1352
1353static void
1354ice_connection_watch (IceConn ice_conn,
1355 IcePointer client_data,
1356 Boolint opening,
1357 IcePointer *watch_data)
1358{
1359 guint watch_id;
1360
1361 if (opening)
1362 {
1363 GIOChannel *channel;
1364 int fd = IceConnectionNumber (ice_conn);
1365
1366 fcntl (fd, F_SETFD2, fcntl (fd, F_GETFD1, 0) | FD_CLOEXEC1);
1367 channel = g_io_channel_unix_new (fd);
1368 watch_id = g_io_add_watch (channel, G_IO_IN | G_IO_ERR,
1369 ice_iochannel_watch, ice_conn);
1370 g_io_channel_unref (channel);
1371
1372 *watch_data = GUINT_TO_POINTER (watch_id)((gpointer) (gulong) (watch_id));
1373 }
1374 else
1375 {
1376 watch_id = GPOINTER_TO_UINT (*watch_data)((guint) (gulong) (*watch_data));
1377 g_source_remove (watch_id);
1378 }
1379}
1380
1381static void
1382ice_error_handler (IceConn ice_conn,
1383 Boolint swap,
1384 int offending_minor_opcode,
1385 unsigned long offending_sequence,
1386 int error_class,
1387 int severity,
1388 IcePointer values)
1389{
1390 /* Do nothing */
1391}
1392
1393static void
1394ice_io_error_handler (IceConn ice_conn)
1395{
1396 /* Do nothing */
1397}
1398
1399static void
1400smc_error_handler (SmcConn smc_conn,
1401 Boolint swap,
1402 int offending_minor_opcode,
1403 unsigned long offending_sequence,
1404 int error_class,
1405 int severity,
1406 SmPointer values)
1407{
1408 /* Do nothing */
1409}
diff --git a/2024-06-18-172109-13286-1@e182420b844f_master/report-cfdb46.html b/2024-06-18-172109-13286-1@e182420b844f_master/report-cfdb46.html new file mode 100644 index 00000000..54da2071 --- /dev/null +++ b/2024-06-18-172109-13286-1@e182420b844f_master/report-cfdb46.html @@ -0,0 +1,2588 @@ + + + +fish.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:applets/fish/fish.c
Warning:line 1578, column 3
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name fish.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/applets/fish -fcoverage-compilation-dir=/rootdir/applets/fish -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I ../.. -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/gio-unix-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/startup-notification-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/gio-unix-2.0 -I /usr/include/dconf -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I . -I ./../../libmate-panel-applet -I ../../libmate-panel-applet -D MATELOCALEDIR="/usr/local/share/locale" -D FISH_ICONDIR="/usr/local/share/mate-panel/fish" -D PIC -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-18-172109-13286-1 -x c fish.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* fish.c:
2 *
3 * Copyright (C) 1998-2002 Free Software Foundation, Inc.
4 * Copyright (C) 2002-2005 Vincent Untz
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
20 *
21 * Authors:
22 * George Lebl <jirka@5z.com>
23 * Mark McLoughlin <mark@skynet.ie>
24 * Vincent Untz <vuntz@gnome.org>
25 * Stefano Karapetsas <stefano@karapetsas.com>
26 */
27
28#include <config.h>
29
30#include <string.h>
31#include <time.h>
32
33#include <cairo.h>
34
35#include <glib/gi18n.h>
36#include <glib-object.h>
37#include <gtk/gtk.h>
38#include <gdk/gdkkeysyms.h>
39#include <gio/gio.h>
40
41#include <mate-panel-applet.h>
42#include <mate-panel-applet-gsettings.h>
43
44#define FISH_APPLET(o)((((FishApplet*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((o)), (fish_applet_get_type())))))
\
45 (G_TYPE_CHECK_INSTANCE_CAST((o), fish_applet_get_type(), FishApplet)(((FishApplet*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((o)), (fish_applet_get_type()))))
)
46#define FISH_IS_APPLET(o)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(o)); GType __t = (FISH_TYPE_APPLET); 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; }))))
\
47 (G_TYPE_CHECK_INSTANCE_TYPE((o), FISH_TYPE_APPLET)((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(o)); GType __t = (FISH_TYPE_APPLET); 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; })))
)
48
49#define FISH_ICON"mate-panel-fish" "mate-panel-fish"
50#define FISH_RESOURCE_PATH"/org/mate/panel/applet/fish/" "/org/mate/panel/applet/fish/"
51
52#define FISH_SCHEMA"org.mate.panel.applet.fish" "org.mate.panel.applet.fish"
53#define FISH_NAME_KEY"name" "name"
54#define FISH_IMAGE_KEY"image" "image"
55#define FISH_COMMAND_KEY"command" "command"
56#define FISH_FRAMES_KEY"frames" "frames"
57#define FISH_SPEED_KEY"speed" "speed"
58#define FISH_ROTATE_KEY"rotate" "rotate"
59
60#define LOCKDOWN_SCHEMA"org.mate.lockdown" "org.mate.lockdown"
61#define LOCKDOWN_DISABLE_COMMAND_LINE_KEY"disable-command-line" "disable-command-line"
62
63typedef struct {
64 MatePanelApplet applet;
65
66 GSettings *settings;
67 GSettings *lockdown_settings;
68
69 char *name;
70 char *image;
71 char *command;
72 int n_frames;
73 gdouble speed;
74 gboolean rotate;
75
76 MatePanelAppletOrient orientation;
77
78 GtkWidget *frame;
79 GtkWidget *drawing_area;
80 GtkRequisition requisition;
81 GdkRectangle prev_allocation;
82 cairo_surface_t *surface;
83 gint surface_width;
84 gint surface_height;
85
86 guint timeout;
87 int current_frame;
88 gboolean in_applet;
89
90 GdkPixbuf *pixbuf;
91
92 GtkWidget *preferences_dialog;
93 GtkWidget *name_entry;
94 GtkWidget *command_label;
95 GtkWidget *command_entry;
96 GtkWidget *preview_image;
97 GtkWidget *image_chooser;
98 GtkWidget *frames_spin;
99 GtkWidget *speed_spin;
100 GtkWidget *rotate_toggle;
101
102 GtkWidget *fortune_dialog;
103 GtkWidget *fortune_view;
104 GtkWidget *fortune_label;
105 GtkWidget *fortune_cmd_label;
106 GtkTextBuffer *fortune_buffer;
107
108 unsigned int source_id;
109 GIOChannel *io_channel;
110
111 gboolean april_fools;
112} FishApplet;
113
114typedef struct {
115 MatePanelAppletClass klass;
116} FishAppletClass;
117
118static gboolean load_fish_image (FishApplet *fish);
119static void update_pixmap (FishApplet *fish);
120static void something_fishy_going_on (FishApplet *fish, const char *message);
121static void display_fortune_dialog (FishApplet *fish);
122static void set_tooltip (FishApplet *fish);
123
124static GType fish_applet_get_type (void);
125
126static GObjectClass *parent_class;
127
128static int fools_day = 0;
129static int fools_month = 0;
130static int fools_hour_start = 0;
131static int fools_hour_end = 0;
132
133static char* get_image_path(FishApplet* fish)
134{
135 char *path;
136
137 if (g_path_is_absolute (fish->image))
138 path = g_strdup (fish->image)g_strdup_inline (fish->image);
139 else
140 path = g_strdup_printf ("%s/%s", FISH_ICONDIR"/usr/local/share/mate-panel/fish", fish->image);
141
142 return path;
143}
144
145static void show_help(FishApplet* fish, const char* link_id)
146{
147 GError *error = NULL((void*)0);
148 char *uri;
149#define FISH_HELP_DOC"mate-fish" "mate-fish"
150
151 if (link_id)
152 uri = g_strdup_printf ("help:%s/%s", FISH_HELP_DOC"mate-fish", link_id);
153 else
154 uri = g_strdup_printf ("help:%s", FISH_HELP_DOC"mate-fish");
155
156 gtk_show_uri_on_window (NULL((void*)0), uri,
157 gtk_get_current_event_time (), &error);
158 g_free (uri);
159
160 if (error &&
161 g_error_matches (error, G_IO_ERRORg_io_error_quark(), G_IO_ERROR_CANCELLED))
162 g_error_free (error);
163 else if (error) {
164 GtkWidget *dialog;
165 char *primary;
166
167 primary = g_markup_printf_escaped (
168 _("Could not display help document '%s'")gettext ("Could not display help document '%s'"),
169 FISH_HELP_DOC"mate-fish");
170 dialog = gtk_message_dialog_new (
171 NULL((void*)0),
172 GTK_DIALOG_DESTROY_WITH_PARENT,
173 GTK_MESSAGE_ERROR,
174 GTK_BUTTONS_CLOSE,
175 "%s", primary);
176
177 gtk_message_dialog_format_secondary_text (
178 GTK_MESSAGE_DIALOG (dialog)((((GtkMessageDialog*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((dialog)), ((gtk_message_dialog_get_type ())
)))))
,
179 "%s", error->message);
180
181 g_error_free (error);
182 g_free (primary);
183
184 g_signal_connect (dialog, "response",g_signal_connect_data ((dialog), ("response"), (((GCallback) (
gtk_widget_destroy))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
185 G_CALLBACK (gtk_widget_destroy),g_signal_connect_data ((dialog), ("response"), (((GCallback) (
gtk_widget_destroy))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
186 NULL)g_signal_connect_data ((dialog), ("response"), (((GCallback) (
gtk_widget_destroy))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
187
188 gtk_window_set_icon_name (GTK_WINDOW (dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_window_get_type ()))))))
, FISH_ICON"mate-panel-fish");
189 gtk_window_set_screen (GTK_WINDOW (dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_window_get_type ()))))))
,
190 gtk_widget_get_screen (GTK_WIDGET (fish)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish)), ((gtk_widget_get_type ()))))))
));
191 /* we have no parent window */
192 gtk_window_set_skip_taskbar_hint (GTK_WINDOW (dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_window_get_type ()))))))
, FALSE(0));
193 gtk_window_set_title (GTK_WINDOW (dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_window_get_type ()))))))
,
194 _("Error displaying help document")gettext ("Error displaying help document"));
195
196 gtk_widget_show (dialog);
197 }
198}
199
200static void name_value_changed(GtkEntry* entry, FishApplet* fish)
201{
202 const char *text;
203
204 text = gtk_entry_get_text (entry);
205
206 if (!text || !text [0])
207 return;
208
209 g_settings_set_string (fish->settings, FISH_NAME_KEY"name", text);
210}
211
212static void image_value_changed(GtkFileChooser* chooser, FishApplet* fish)
213{
214 char *path;
215 char *image;
216 char *path_gsettings;
217
218 path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser)((((GtkFileChooser*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((chooser)), ((gtk_file_chooser_get_type ()))))))
);
219
220 if (!path || !path[0]) {
221 g_free (path);
222 return;
223 }
224
225 path_gsettings = get_image_path (fish);
226 if (!strcmp (path, path_gsettings)) {
227 g_free (path);
228 g_free (path_gsettings);
229 return;
230 }
231 g_free (path_gsettings);
232
233 if (!strncmp (path, FISH_ICONDIR"/usr/local/share/mate-panel/fish", strlen (FISH_ICONDIR"/usr/local/share/mate-panel/fish"))) {
234 image = path + strlen (FISH_ICONDIR"/usr/local/share/mate-panel/fish");
235 while (*image && *image == G_DIR_SEPARATOR'/')
236 image++;
237 } else
238 image = path;
239
240 g_settings_set_string (fish->settings, FISH_IMAGE_KEY"image", image);
241
242 g_free (path);
243}
244
245static void command_value_changed(GtkEntry* entry, FishApplet *fish)
246{
247 const char *text;
248
249 text = gtk_entry_get_text (entry);
250
251 if (!text || !text [0]) {
252 g_settings_set_string (fish->settings, FISH_COMMAND_KEY"command", "");
253 return;
254 }
255
256 if (!strncmp (text, "ps ", 3) ||
257 !strcmp (text, "ps") ||
258 !strncmp (text, "who ", 4) ||
259 !strcmp (text, "who") ||
260 !strcmp (text, "uptime") ||
261 !strncmp (text, "tail ", 5)) {
262 static gboolean message_given = FALSE(0);
263 const char *warning_format =
264 _("Warning: The command "gettext ("Warning: The command " "appears to be something actually useful.\n"
"Since this is a useless applet, you " "may not want to do this.\n"
"We strongly advise you against " "using %s for anything\n" "which would make the applet "
"\"practical\" or useful.")
265 "appears to be something actually useful.\n"gettext ("Warning: The command " "appears to be something actually useful.\n"
"Since this is a useless applet, you " "may not want to do this.\n"
"We strongly advise you against " "using %s for anything\n" "which would make the applet "
"\"practical\" or useful.")
266 "Since this is a useless applet, you "gettext ("Warning: The command " "appears to be something actually useful.\n"
"Since this is a useless applet, you " "may not want to do this.\n"
"We strongly advise you against " "using %s for anything\n" "which would make the applet "
"\"practical\" or useful.")
267 "may not want to do this.\n"gettext ("Warning: The command " "appears to be something actually useful.\n"
"Since this is a useless applet, you " "may not want to do this.\n"
"We strongly advise you against " "using %s for anything\n" "which would make the applet "
"\"practical\" or useful.")
268 "We strongly advise you against "gettext ("Warning: The command " "appears to be something actually useful.\n"
"Since this is a useless applet, you " "may not want to do this.\n"
"We strongly advise you against " "using %s for anything\n" "which would make the applet "
"\"practical\" or useful.")
269 "using %s for anything\n"gettext ("Warning: The command " "appears to be something actually useful.\n"
"Since this is a useless applet, you " "may not want to do this.\n"
"We strongly advise you against " "using %s for anything\n" "which would make the applet "
"\"practical\" or useful.")
270 "which would make the applet "gettext ("Warning: The command " "appears to be something actually useful.\n"
"Since this is a useless applet, you " "may not want to do this.\n"
"We strongly advise you against " "using %s for anything\n" "which would make the applet "
"\"practical\" or useful.")
271 "\"practical\" or useful.")gettext ("Warning: The command " "appears to be something actually useful.\n"
"Since this is a useless applet, you " "may not want to do this.\n"
"We strongly advise you against " "using %s for anything\n" "which would make the applet "
"\"practical\" or useful.")
;
272
273 if (!message_given) {
274 char *message = g_strdup_printf (warning_format, fish->name);
275 something_fishy_going_on (fish, message);
276 g_free (message);
277 message_given = TRUE(!(0));
278 }
279 }
280
281 g_settings_set_string (fish->settings, FISH_COMMAND_KEY"command", text);
282}
283
284static void n_frames_value_changed(GtkSpinButton* button, FishApplet* fish)
285{
286 g_settings_set_int (
287 fish->settings,
288 FISH_FRAMES_KEY"frames",
289 gtk_spin_button_get_value_as_int (button));
290}
291
292static void speed_value_changed (GtkSpinButton* button, FishApplet* fish)
293{
294 g_settings_set_double (
295 fish->settings,
296 FISH_SPEED_KEY"speed",
297 gtk_spin_button_get_value (button));
298}
299
300static void rotate_value_changed(GtkToggleButton* toggle, FishApplet* fish)
301{
302 g_settings_set_boolean (
303 fish->settings,
304 FISH_ROTATE_KEY"rotate",
305 gtk_toggle_button_get_active (toggle));
306}
307
308static gboolean delete_event(GtkWidget* widget, FishApplet* fish)
309{
310 gtk_widget_hide (widget);
311
312 return TRUE(!(0));
313}
314
315static void handle_response(GtkWidget* widget, int id, FishApplet* fish)
316{
317 if (id == GTK_RESPONSE_HELP) {
318 show_help (fish, "fish-settings");
319 return;
320 }
321
322 gtk_widget_hide (fish->preferences_dialog);
323}
324
325static void setup_sensitivity(FishApplet* fish, GtkBuilder* builder, const char* wid, const char* label, const char* label_post, const char* key)
326{
327 GtkWidget *w;
328
329 if (g_settings_is_writable (fish->settings, key)) {
330 return;
331 }
332
333 w = GTK_WIDGET (gtk_builder_get_object (builder, wid))((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, wid))), ((gtk_widget_get_type
()))))))
;
334 g_assert (w != NULL)do { if (w != ((void*)0)) ; else g_assertion_message_expr (((
gchar*) 0), "fish.c", 334, ((const char*) (__func__)), "w != NULL"
); } while (0)
;
335 gtk_widget_set_sensitive (w, FALSE(0));
336
337 if (label != NULL((void*)0)) {
338 w = GTK_WIDGET (gtk_builder_get_object (builder, label))((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, label))), ((gtk_widget_get_type
()))))))
;
339 g_assert (w != NULL)do { if (w != ((void*)0)) ; else g_assertion_message_expr (((
gchar*) 0), "fish.c", 339, ((const char*) (__func__)), "w != NULL"
); } while (0)
;
340 gtk_widget_set_sensitive (w, FALSE(0));
341 }
342 if (label_post != NULL((void*)0)) {
343 w = GTK_WIDGET (gtk_builder_get_object (builder, label_post))((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, label_post))), ((gtk_widget_get_type
()))))))
;
344 g_assert (w != NULL)do { if (w != ((void*)0)) ; else g_assertion_message_expr (((
gchar*) 0), "fish.c", 344, ((const char*) (__func__)), "w != NULL"
); } while (0)
;
345 gtk_widget_set_sensitive (w, FALSE(0));
346 }
347
348}
349
350static void chooser_preview_update(GtkFileChooser* file_chooser, gpointer data)
351{
352 GtkWidget *preview;
353 char *filename;
354 GdkPixbuf *pixbuf;
355 gboolean have_preview;
356
357 preview = GTK_WIDGET (data)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((gtk_widget_get_type ()))))))
;
358 filename = gtk_file_chooser_get_preview_filename (file_chooser);
359
360 if (filename == NULL((void*)0))
361 return;
362
363 pixbuf = gdk_pixbuf_new_from_file_at_size (filename, 128, 128, NULL((void*)0));
364 have_preview = (pixbuf != NULL((void*)0));
365 g_free (filename);
366
367 gtk_image_set_from_pixbuf (GTK_IMAGE (preview)((((GtkImage*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((preview)), ((gtk_image_get_type ()))))))
, pixbuf);
368 if (pixbuf)
369 g_object_unref (pixbuf);
370
371 gtk_file_chooser_set_preview_widget_active (file_chooser,
372 have_preview);
373}
374
375static void display_preferences_dialog(GtkAction* action, FishApplet* fish)
376{
377 GtkBuilder *builder;
378 GtkWidget *button;
379 GtkFileFilter *filter;
380 GtkWidget *chooser_preview;
381 char *path;
382
383 if (fish->preferences_dialog) {
384 gtk_window_set_screen (GTK_WINDOW (fish->preferences_dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish->preferences_dialog)), ((gtk_window_get_type ())
)))))
,
385 gtk_widget_get_screen (GTK_WIDGET (fish)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish)), ((gtk_widget_get_type ()))))))
));
386 gtk_window_present (GTK_WINDOW (fish->preferences_dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish->preferences_dialog)), ((gtk_window_get_type ())
)))))
);
387 return;
388 }
389
390 builder = gtk_builder_new ();
391 gtk_builder_set_translation_domain (builder, GETTEXT_PACKAGE"mate-panel");
392 gtk_builder_add_from_resource (builder, FISH_RESOURCE_PATH"/org/mate/panel/applet/fish/" "fish.ui", NULL((void*)0));
393
394 fish->preferences_dialog = GTK_WIDGET (gtk_builder_get_object (builder, "fish_preferences_dialog"))((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, "fish_preferences_dialog"
))), ((gtk_widget_get_type ()))))))
;
395
396 g_object_add_weak_pointer (G_OBJECT (fish->preferences_dialog)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish->preferences_dialog)), (((GType) ((20) << (
2))))))))
,
397 (void**) &fish->preferences_dialog);
398
399 gtk_window_set_icon_name (GTK_WINDOW (fish->preferences_dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish->preferences_dialog)), ((gtk_window_get_type ())
)))))
,
400 FISH_ICON"mate-panel-fish");
401 gtk_dialog_set_default_response (
402 GTK_DIALOG (fish->preferences_dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish->preferences_dialog)), ((gtk_dialog_get_type ())
)))))
, GTK_RESPONSE_OK);
403
404 fish->name_entry = GTK_WIDGET (gtk_builder_get_object (builder, "name_entry"))((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, "name_entry"))), ((gtk_widget_get_type
()))))))
;
405 gtk_entry_set_text (GTK_ENTRY (fish->name_entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish->name_entry)), ((gtk_entry_get_type ()))))))
, fish->name);
406
407 g_signal_connect (fish->name_entry, "changed",g_signal_connect_data ((fish->name_entry), ("changed"), ((
(GCallback) (name_value_changed))), (fish), ((void*)0), (GConnectFlags
) 0)
408 G_CALLBACK (name_value_changed), fish)g_signal_connect_data ((fish->name_entry), ("changed"), ((
(GCallback) (name_value_changed))), (fish), ((void*)0), (GConnectFlags
) 0)
;
409
410 setup_sensitivity (fish, builder,
411 "name_entry" /* wid */,
412 "name_label" /* label */,
413 NULL((void*)0) /* label_post */,
414 FISH_NAME_KEY"name" /* key */);
415
416 fish->preview_image = GTK_WIDGET (gtk_builder_get_object (builder, "preview_image"))((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, "preview_image"))), ((gtk_widget_get_type
()))))))
;
417 if (fish->pixbuf)
418 gtk_image_set_from_pixbuf (GTK_IMAGE (fish->preview_image)((((GtkImage*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish->preview_image)), ((gtk_image_get_type ()))))))
,
419 fish->pixbuf);
420
421 fish->image_chooser = GTK_WIDGET (gtk_builder_get_object (builder, "image_chooser"))((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, "image_chooser"))), ((gtk_widget_get_type
()))))))
;
422 filter = gtk_file_filter_new ();
423 gtk_file_filter_set_name (filter, _("Images")gettext ("Images"));
424 gtk_file_filter_add_pixbuf_formats (filter);
425 gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (fish->image_chooser)((((GtkFileChooser*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish->image_chooser)), ((gtk_file_chooser_get_type ()
))))))
,
426 filter);
427 gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (fish->image_chooser)((((GtkFileChooser*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish->image_chooser)), ((gtk_file_chooser_get_type ()
))))))
,
428 filter);
429 chooser_preview = gtk_image_new ();
430 gtk_file_chooser_set_preview_widget (GTK_FILE_CHOOSER (fish->image_chooser)((((GtkFileChooser*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish->image_chooser)), ((gtk_file_chooser_get_type ()
))))))
,
431 chooser_preview);
432 g_signal_connect (fish->image_chooser, "update-preview",g_signal_connect_data ((fish->image_chooser), ("update-preview"
), (((GCallback) (chooser_preview_update))), (chooser_preview
), ((void*)0), (GConnectFlags) 0)
433 G_CALLBACK (chooser_preview_update), chooser_preview)g_signal_connect_data ((fish->image_chooser), ("update-preview"
), (((GCallback) (chooser_preview_update))), (chooser_preview
), ((void*)0), (GConnectFlags) 0)
;
434 path = get_image_path (fish);
435 gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (fish->image_chooser)((((GtkFileChooser*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish->image_chooser)), ((gtk_file_chooser_get_type ()
))))))
,
436 path);
437 g_free (path);
438
439 g_signal_connect (fish->image_chooser, "selection-changed",g_signal_connect_data ((fish->image_chooser), ("selection-changed"
), (((GCallback) (image_value_changed))), (fish), ((void*)0),
(GConnectFlags) 0)
440 G_CALLBACK (image_value_changed), fish)g_signal_connect_data ((fish->image_chooser), ("selection-changed"
), (((GCallback) (image_value_changed))), (fish), ((void*)0),
(GConnectFlags) 0)
;
441
442 setup_sensitivity (fish, builder,
443 "image_chooser" /* wid */,
444 "image_label" /* label */,
445 NULL((void*)0) /* label_post */,
446 FISH_IMAGE_KEY"image" /* key */);
447
448 fish->command_label = GTK_WIDGET (gtk_builder_get_object (builder, "command_label"))((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, "command_label"))), ((gtk_widget_get_type
()))))))
;
449 fish->command_entry = GTK_WIDGET (gtk_builder_get_object (builder, "command_entry"))((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, "command_entry"))), ((gtk_widget_get_type
()))))))
;
450 gtk_entry_set_text (GTK_ENTRY (fish->command_entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish->command_entry)), ((gtk_entry_get_type ()))))))
, fish->command);
451
452 g_signal_connect (fish->command_entry, "changed",g_signal_connect_data ((fish->command_entry), ("changed"),
(((GCallback) (command_value_changed))), (fish), ((void*)0),
(GConnectFlags) 0)
453 G_CALLBACK (command_value_changed), fish)g_signal_connect_data ((fish->command_entry), ("changed"),
(((GCallback) (command_value_changed))), (fish), ((void*)0),
(GConnectFlags) 0)
;
454
455 setup_sensitivity (fish, builder,
456 "command_entry" /* wid */,
457 "command_label" /* label */,
458 NULL((void*)0) /* label_post */,
459 FISH_COMMAND_KEY"command" /* key */);
460
461 if (g_settings_get_boolean (fish->lockdown_settings, LOCKDOWN_DISABLE_COMMAND_LINE_KEY"disable-command-line")) {
462 gtk_widget_set_sensitive (fish->command_label, FALSE(0));
463 gtk_widget_set_sensitive (fish->command_entry, FALSE(0));
464 }
465
466 fish->frames_spin = GTK_WIDGET (gtk_builder_get_object (builder, "frames_spin"))((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, "frames_spin"))), ((gtk_widget_get_type
()))))))
;
467 gtk_spin_button_set_value (GTK_SPIN_BUTTON (fish->frames_spin)((((GtkSpinButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish->frames_spin)), ((gtk_spin_button_get_type ())))
)))
,
468 fish->n_frames);
469
470 g_signal_connect (fish->frames_spin, "value-changed",g_signal_connect_data ((fish->frames_spin), ("value-changed"
), (((GCallback) (n_frames_value_changed))), (fish), ((void*)
0), (GConnectFlags) 0)
471 G_CALLBACK (n_frames_value_changed), fish)g_signal_connect_data ((fish->frames_spin), ("value-changed"
), (((GCallback) (n_frames_value_changed))), (fish), ((void*)
0), (GConnectFlags) 0)
;
472
473 setup_sensitivity (fish, builder,
474 "frames_spin" /* wid */,
475 "frames_label" /* label */,
476 "frames_post_label" /* label_post */,
477 FISH_FRAMES_KEY"frames" /* key */);
478
479 fish->speed_spin = GTK_WIDGET (gtk_builder_get_object (builder, "speed_spin"))((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, "speed_spin"))), ((gtk_widget_get_type
()))))))
;
480 gtk_spin_button_set_value (GTK_SPIN_BUTTON (fish->speed_spin)((((GtkSpinButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish->speed_spin)), ((gtk_spin_button_get_type ()))))
))
, fish->speed);
481
482 g_signal_connect (fish->speed_spin, "value-changed",g_signal_connect_data ((fish->speed_spin), ("value-changed"
), (((GCallback) (speed_value_changed))), (fish), ((void*)0),
(GConnectFlags) 0)
483 G_CALLBACK (speed_value_changed), fish)g_signal_connect_data ((fish->speed_spin), ("value-changed"
), (((GCallback) (speed_value_changed))), (fish), ((void*)0),
(GConnectFlags) 0)
;
484
485 setup_sensitivity (fish, builder,
486 "speed_spin" /* wid */,
487 "speed_label" /* label */,
488 "speed_post_label" /* label_post */,
489 FISH_SPEED_KEY"speed" /* key */);
490
491 fish->rotate_toggle = GTK_WIDGET (gtk_builder_get_object (builder, "rotate_toggle"))((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, "rotate_toggle"))), ((gtk_widget_get_type
()))))))
;
492 gtk_toggle_button_set_active (
493 GTK_TOGGLE_BUTTON (fish->rotate_toggle)((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish->rotate_toggle)), ((gtk_toggle_button_get_type (
)))))))
, fish->rotate);
494
495 g_signal_connect (fish->rotate_toggle, "toggled",g_signal_connect_data ((fish->rotate_toggle), ("toggled"),
(((GCallback) (rotate_value_changed))), (fish), ((void*)0), (
GConnectFlags) 0)
496 G_CALLBACK (rotate_value_changed), fish)g_signal_connect_data ((fish->rotate_toggle), ("toggled"),
(((GCallback) (rotate_value_changed))), (fish), ((void*)0), (
GConnectFlags) 0)
;
497
498 setup_sensitivity (fish, builder,
499 "rotate_toggle" /* wid */,
500 NULL((void*)0) /* label */,
501 NULL((void*)0) /* label_post */,
502 FISH_ROTATE_KEY"rotate" /* key */);
503
504 g_signal_connect (fish->preferences_dialog, "delete-event",g_signal_connect_data ((fish->preferences_dialog), ("delete-event"
), (((GCallback) (delete_event))), (fish), ((void*)0), (GConnectFlags
) 0)
505 G_CALLBACK (delete_event), fish)g_signal_connect_data ((fish->preferences_dialog), ("delete-event"
), (((GCallback) (delete_event))), (fish), ((void*)0), (GConnectFlags
) 0)
;
506 g_signal_connect (fish->preferences_dialog, "response",g_signal_connect_data ((fish->preferences_dialog), ("response"
), (((GCallback) (handle_response))), (fish), ((void*)0), (GConnectFlags
) 0)
507 G_CALLBACK (handle_response), fish)g_signal_connect_data ((fish->preferences_dialog), ("response"
), (((GCallback) (handle_response))), (fish), ((void*)0), (GConnectFlags
) 0)
;
508
509 button = GTK_WIDGET (gtk_builder_get_object (builder, "done_button"))((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, "done_button"))), ((gtk_widget_get_type
()))))))
;
510 g_signal_connect_swapped (button, "clicked",g_signal_connect_data ((button), ("clicked"), ((GCallback) gtk_widget_hide
), (fish->preferences_dialog), ((void*)0), G_CONNECT_SWAPPED
)
511 (GCallback) gtk_widget_hide,g_signal_connect_data ((button), ("clicked"), ((GCallback) gtk_widget_hide
), (fish->preferences_dialog), ((void*)0), G_CONNECT_SWAPPED
)
512 fish->preferences_dialog)g_signal_connect_data ((button), ("clicked"), ((GCallback) gtk_widget_hide
), (fish->preferences_dialog), ((void*)0), G_CONNECT_SWAPPED
)
;
513
514 gtk_window_set_screen (GTK_WINDOW (fish->preferences_dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish->preferences_dialog)), ((gtk_window_get_type ())
)))))
,
515 gtk_widget_get_screen (GTK_WIDGET (fish)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish)), ((gtk_widget_get_type ()))))))
));
516 gtk_window_set_resizable (GTK_WINDOW (fish->preferences_dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish->preferences_dialog)), ((gtk_window_get_type ())
)))))
, FALSE(0));
517 gtk_window_present (GTK_WINDOW (fish->preferences_dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish->preferences_dialog)), ((gtk_window_get_type ())
)))))
);
518
519 g_object_unref (builder);
520}
521
522static void display_help_dialog(GtkAction* action, FishApplet* fish)
523{
524 show_help(fish, NULL((void*)0));
525}
526
527static void display_about_dialog(GtkAction* action, FishApplet* fish)
528{
529 const char* author_format = _("%s the Fish")gettext ("%s the Fish");
530 const char* about_format = _("%s has no use what-so-ever. "gettext ("%s has no use what-so-ever. " "It only takes up disk space and "
"compilation time, and if loaded it also " "takes up precious panel space and "
"memory. Anybody found using it should be " "promptly sent for a psychiatric "
"evaluation.")
531 "It only takes up disk space and "gettext ("%s has no use what-so-ever. " "It only takes up disk space and "
"compilation time, and if loaded it also " "takes up precious panel space and "
"memory. Anybody found using it should be " "promptly sent for a psychiatric "
"evaluation.")
532 "compilation time, and if loaded it also "gettext ("%s has no use what-so-ever. " "It only takes up disk space and "
"compilation time, and if loaded it also " "takes up precious panel space and "
"memory. Anybody found using it should be " "promptly sent for a psychiatric "
"evaluation.")
533 "takes up precious panel space and "gettext ("%s has no use what-so-ever. " "It only takes up disk space and "
"compilation time, and if loaded it also " "takes up precious panel space and "
"memory. Anybody found using it should be " "promptly sent for a psychiatric "
"evaluation.")
534 "memory. Anybody found using it should be "gettext ("%s has no use what-so-ever. " "It only takes up disk space and "
"compilation time, and if loaded it also " "takes up precious panel space and "
"memory. Anybody found using it should be " "promptly sent for a psychiatric "
"evaluation.")
535 "promptly sent for a psychiatric "gettext ("%s has no use what-so-ever. " "It only takes up disk space and "
"compilation time, and if loaded it also " "takes up precious panel space and "
"memory. Anybody found using it should be " "promptly sent for a psychiatric "
"evaluation.")
536 "evaluation.")gettext ("%s has no use what-so-ever. " "It only takes up disk space and "
"compilation time, and if loaded it also " "takes up precious panel space and "
"memory. Anybody found using it should be " "promptly sent for a psychiatric "
"evaluation.")
;
537 const char* documenters [] = {
538 "Telsa Gwynne <hobbit@aloss.ukuu.org.uk>",
539 "Sun GNOME Documentation Team <gdocteam@sun.com>",
540 NULL((void*)0)
541 };
542
543 char* authors[3];
544 char* descr;
545
546 authors[0] = g_strdup_printf(author_format, fish->name);
547 authors[1] = _("(with minor help from George)")gettext ("(with minor help from George)");
548 authors[2] = NULL((void*)0);
549
550 descr = g_strdup_printf(about_format, fish->name);
551
552 gtk_show_about_dialog(NULL((void*)0),
553 "program-name", _("Fish")gettext ("Fish"),
554 "title", _("About Fish")gettext ("About Fish"),
555 "authors", authors,
556 "comments", descr,
557 "copyright", _("Copyright \xc2\xa9 1998-2002 Free Software Foundation, Inc.\n"gettext ("Copyright \xc2\xa9 1998-2002 Free Software Foundation, Inc.\n"
"Copyright \xc2\xa9 2002-2005 Vincent Untz\n" "Copyright \xc2\xa9 2012-2021 MATE developers"
)
558 "Copyright \xc2\xa9 2002-2005 Vincent Untz\n"gettext ("Copyright \xc2\xa9 1998-2002 Free Software Foundation, Inc.\n"
"Copyright \xc2\xa9 2002-2005 Vincent Untz\n" "Copyright \xc2\xa9 2012-2021 MATE developers"
)
559 "Copyright \xc2\xa9 2012-2021 MATE developers")gettext ("Copyright \xc2\xa9 1998-2002 Free Software Foundation, Inc.\n"
"Copyright \xc2\xa9 2002-2005 Vincent Untz\n" "Copyright \xc2\xa9 2012-2021 MATE developers"
)
,
560 "documenters", documenters,
561 "logo-icon-name", FISH_ICON"mate-panel-fish",
562 "translator-credits", _("translator-credits")gettext ("translator-credits"),
563 "version", VERSION"1.29.0", /* "3.4.7.4ac19" */
564 "website", PACKAGE_URL"https://mate-desktop.org",
565 NULL((void*)0));
566
567 g_free(descr);
568 g_free(authors[0]);
569}
570
571static void set_ally_name_desc(GtkWidget* widget, FishApplet* fish)
572{
573 const char *name_format = _("%s the Fish")gettext ("%s the Fish");
574 const char *desc_format = _("%s the Fish, a contemporary oracle")gettext ("%s the Fish, a contemporary oracle");
575 AtkObject *obj;
576 char *desc, *name;
577
578 obj = gtk_widget_get_accessible (widget);
579 /* Return immediately if GAIL is not loaded */
580 if (!GTK_IS_ACCESSIBLE (obj)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(obj)); GType __t = ((gtk_accessible_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; }))))
)
581 return;
582
583 name = g_strdup_printf (name_format, fish->name);
584 atk_object_set_name (obj, name);
585 g_free (name);
586
587 desc = g_strdup_printf (desc_format, fish->name);
588 atk_object_set_description (obj, desc);
589 g_free (desc);
590}
591
592static void something_fishy_going_on(FishApplet* fish, const char* message)
593{
594 GtkWidget *dialog;
595
596 dialog = gtk_message_dialog_new (NULL((void*)0),
597 GTK_DIALOG_DESTROY_WITH_PARENT,
598 GTK_MESSAGE_ERROR,
599 GTK_BUTTONS_CLOSE,
600 "%s", message);
601
602 g_signal_connect (dialog, "response",g_signal_connect_data ((dialog), ("response"), (((GCallback) (
gtk_widget_destroy))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
603 G_CALLBACK (gtk_widget_destroy),g_signal_connect_data ((dialog), ("response"), (((GCallback) (
gtk_widget_destroy))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
604 NULL)g_signal_connect_data ((dialog), ("response"), (((GCallback) (
gtk_widget_destroy))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
605
606 gtk_window_set_icon_name (GTK_WINDOW (dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_window_get_type ()))))))
, FISH_ICON"mate-panel-fish");
607 gtk_window_set_resizable (GTK_WINDOW (dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_window_get_type ()))))))
, FALSE(0));
608 gtk_window_set_screen (GTK_WINDOW (dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_window_get_type ()))))))
,
609 gtk_widget_get_screen (GTK_WIDGET (fish)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish)), ((gtk_widget_get_type ()))))))
));
610 gtk_widget_show (dialog);
611}
612
613static gboolean locate_fortune_command (FishApplet* fish, int* argcp, char*** argvp)
614{
615 char *prog = NULL((void*)0);
616
617 if (fish->command
618 && g_shell_parse_argv (fish->command, argcp, argvp, NULL((void*)0))) {
619 prog = g_find_program_in_path ((*argvp)[0]);
620 if (prog) {
621 g_free (prog);
622 return TRUE(!(0));
623 }
624
625 g_strfreev (*argvp);
626 }
627
628 prog = g_find_program_in_path ("fortune");
629 if (prog) {
630 g_free (prog);
631 if (g_shell_parse_argv ("fortune", argcp, argvp, NULL((void*)0)))
632 return FALSE(0);
633 }
634
635 if (g_file_test ("/usr/games/fortune", G_FILE_TEST_IS_EXECUTABLE)
636 && g_shell_parse_argv ("/usr/games/fortune", argcp, argvp, NULL((void*)0)))
637 return FALSE(0);
638
639 something_fishy_going_on (fish,
640 _("Unable to locate the command to execute")gettext ("Unable to locate the command to execute"));
641 *argvp = NULL((void*)0);
642 return FALSE(0);
643}
644
645#define FISH_RESPONSE_SPEAK1 1
646static inline void fish_close_channel(FishApplet* fish)
647{
648 if (fish->io_channel) {
649 g_io_channel_shutdown (fish->io_channel, TRUE(!(0)), NULL((void*)0));
650 g_io_channel_unref (fish->io_channel);
651 }
652 fish->io_channel = NULL((void*)0);
653}
654
655static void handle_fortune_response(GtkWidget* widget, int id, FishApplet* fish)
656{
657 if (id == FISH_RESPONSE_SPEAK1)
658 display_fortune_dialog (fish);
659 else {
660 /* if there is still a pipe, close it: if we hide the widget,
661 * the * output can't be seen */
662 if (fish->source_id)
663 g_source_remove (fish->source_id);
664 fish->source_id = 0;
665 fish_close_channel (fish);
666 gtk_widget_hide (fish->fortune_dialog);
667 }
668}
669
670static void update_fortune_dialog(FishApplet* fish)
671{
672 char *label_text;
673 char *text;
674
675 if (!fish->fortune_dialog || !fish->name)
676 return;
677
678 /* xgettext:no-c-format */
679 text = g_strdup_printf (_("%s the Fish")gettext ("%s the Fish"), fish->name);
680 gtk_window_set_title (GTK_WINDOW (fish->fortune_dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish->fortune_dialog)), ((gtk_window_get_type ())))))
)
, text);
681 g_free (text);
682
683 /* xgettext:no-c-format */
684 label_text = g_strdup_printf (_("%s the Fish Says:")gettext ("%s the Fish Says:"), fish->name);
685
686 text = g_strdup_printf ("<big><big>%s</big></big>", label_text);
687 gtk_label_set_markup (GTK_LABEL (fish->fortune_label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish->fortune_label)), ((gtk_label_get_type ()))))))
, text);
688 g_free (text);
689
690 g_free (label_text);
691
692 set_ally_name_desc (fish->fortune_view, fish);
693}
694
695static void insert_fortune_text(FishApplet* fish, const char* text)
696{
697 GtkTextIter iter;
698
699 gtk_text_buffer_get_iter_at_offset (fish->fortune_buffer, &iter, -1);
700
701 gtk_text_buffer_insert_with_tags_by_name (fish->fortune_buffer, &iter,
702 text, -1, "monospace_tag",
703 NULL((void*)0));
704
705 while (gtk_events_pending ())
706 gtk_main_iteration ();
707}
708
709static void clear_fortune_text(FishApplet* fish)
710{
711 GtkTextIter begin, end;
712
713 gtk_text_buffer_get_iter_at_offset (fish->fortune_buffer, &begin, 0);
714 gtk_text_buffer_get_iter_at_offset (fish->fortune_buffer, &end, -1);
715
716 gtk_text_buffer_delete (fish->fortune_buffer, &begin, &end);
717 gtk_text_buffer_remove_tag_by_name (fish->fortune_buffer,
718 "monospace_tag", &begin, &end);
719
720 /* insert an empty line */
721 insert_fortune_text (fish, "\n");
722}
723
724static gboolean fish_read_output(GIOChannel* source, GIOCondition condition, gpointer data)
725{
726 char output[4096];
727 gsize bytes_read;
728 GError *error = NULL((void*)0);
729 GIOStatus status;
730 FishApplet *fish;
731
732 fish = (FishApplet *) data;
733
734 if (!(condition & G_IO_IN)) {
735 fish->source_id = 0;
736 fish_close_channel (fish);
737 return FALSE(0);
738 }
739
740 status = g_io_channel_read_chars (source, output, 4096, &bytes_read,
741 &error);
742
743 if (error) {
744 char *message;
745
746 message = g_strdup_printf (_("Unable to read output from command\n\nDetails: %s")gettext ("Unable to read output from command\n\nDetails: %s"),
747 error->message);
748 something_fishy_going_on (fish, message);
749 g_free (message);
750 g_error_free (error);
751 fish->source_id = 0;
752 fish_close_channel (fish);
753 return FALSE(0);
754 }
755
756 if (status == G_IO_STATUS_AGAIN)
757 return TRUE(!(0));
758
759 if (bytes_read > 0) {
760 char *utf8_output;
761
762 /* The output is not guarantied to be in UTF-8 format, most
763 * likely it's just in ASCII-7 or in the user locale
764 */
765 if (!g_utf8_validate (output, -1, NULL((void*)0)))
766 utf8_output = g_locale_to_utf8 (output, bytes_read,
767 NULL((void*)0), NULL((void*)0), NULL((void*)0));
768 else
769 utf8_output = g_strndup (output, bytes_read);
770
771 if (utf8_output)
772 insert_fortune_text (fish, utf8_output);
773
774 g_free (utf8_output);
775 }
776
777 if (status == G_IO_STATUS_EOF) {
778 fish->source_id = 0;
779 fish_close_channel (fish);
780 }
781 return (status != G_IO_STATUS_EOF);
782}
783
784/*
785 * Set the DISPLAY variable, to be use by g_spawn_async.
786 */
787static void
788set_environment (gpointer display)
789{
790 g_setenv ("DISPLAY", display, TRUE(!(0)));
791}
792
793static GtkWidget*
794panel_dialog_add_button (GtkDialog *dialog,
795 const gchar *button_text,
796 const gchar *icon_name,
797 gint response_id)
798{
799 GtkWidget *button;
800
801 button = gtk_button_new_with_mnemonic (button_text);
802 gtk_button_set_image (GTK_BUTTON (button)((((GtkButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), ((gtk_button_get_type ()))))))
, gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_BUTTON));
803
804 gtk_button_set_use_underline (GTK_BUTTON (button)((((GtkButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), ((gtk_button_get_type ()))))))
, TRUE(!(0)));
805 gtk_style_context_add_class (gtk_widget_get_style_context (button), "text-button");
806 gtk_widget_set_can_default (button, TRUE(!(0)));
807 gtk_widget_show (button);
808 gtk_dialog_add_action_widget (GTK_DIALOG (dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_dialog_get_type ()))))))
, button, response_id);
809
810 return button;
811}
812
813static void display_fortune_dialog(FishApplet* fish)
814{
815 GError *error = NULL((void*)0);
816 gboolean user_command;
817 int output;
818 const char *charset;
819 int argc;
820 char **argv;
821 GdkDisplay *display;
822 GdkScreen *screen;
823 char *display_name;
824
825 /* if there is still a pipe, close it */
826 if (fish->source_id)
827 g_source_remove (fish->source_id);
828 fish->source_id = 0;
829 fish_close_channel (fish);
830
831 user_command = locate_fortune_command (fish, &argc, &argv);
832 if (!argv)
833 return;
834
835 if (!fish->fortune_dialog) {
836 GtkWidget *scrolled;
837 GtkWidget *vbox;
838 GdkMonitor *monitor;
839 GdkRectangle monitor_geom;
840
841 fish->fortune_dialog = gtk_dialog_new ();
842 gtk_window_set_title (GTK_WINDOW (fish->fortune_dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish->fortune_dialog)), ((gtk_window_get_type ())))))
)
, "");
843
844 gtk_dialog_add_button (GTK_DIALOG (fish->fortune_dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish->fortune_dialog)), ((gtk_dialog_get_type ())))))
)
,
845 _("_Speak again")gettext ("_Speak again"),
846 FISH_RESPONSE_SPEAK1);
847
848 panel_dialog_add_button (GTK_DIALOG (fish->fortune_dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish->fortune_dialog)), ((gtk_dialog_get_type ())))))
)
,
849 _("_Close")gettext ("_Close"), "window-close",
850 GTK_RESPONSE_CLOSE);
851
852 gtk_window_set_icon_name (GTK_WINDOW (fish->fortune_dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish->fortune_dialog)), ((gtk_window_get_type ())))))
)
,
853 FISH_ICON"mate-panel-fish");
854
855 gtk_dialog_set_default_response (
856 GTK_DIALOG (fish->fortune_dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish->fortune_dialog)), ((gtk_dialog_get_type ())))))
)
, GTK_RESPONSE_CLOSE);
857
858 g_signal_connect (fish->fortune_dialog, "delete-event",g_signal_connect_data ((fish->fortune_dialog), ("delete-event"
), (((GCallback) (delete_event))), (fish), ((void*)0), (GConnectFlags
) 0)
859 G_CALLBACK (delete_event), fish)g_signal_connect_data ((fish->fortune_dialog), ("delete-event"
), (((GCallback) (delete_event))), (fish), ((void*)0), (GConnectFlags
) 0)
;
860 g_signal_connect (fish->fortune_dialog, "response",g_signal_connect_data ((fish->fortune_dialog), ("response"
), (((GCallback) (handle_fortune_response))), (fish), ((void*
)0), (GConnectFlags) 0)
861 G_CALLBACK (handle_fortune_response), fish)g_signal_connect_data ((fish->fortune_dialog), ("response"
), (((GCallback) (handle_fortune_response))), (fish), ((void*
)0), (GConnectFlags) 0)
;
862
863 monitor = gdk_display_get_monitor_at_window (gtk_widget_get_display (GTK_WIDGET (fish)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish)), ((gtk_widget_get_type ()))))))
),
864 gtk_widget_get_window (GTK_WIDGET (fish)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish)), ((gtk_widget_get_type ()))))))
));
865 gdk_monitor_get_geometry(monitor, &monitor_geom);
866 gtk_window_set_default_size (GTK_WINDOW (fish->fortune_dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish->fortune_dialog)), ((gtk_window_get_type ())))))
)
,
867 MIN (600, monitor_geom.width * 0.9)(((600) < (monitor_geom.width * 0.9)) ? (600) : (monitor_geom
.width * 0.9))
,
868 MIN (350, monitor_geom.height * 0.9)(((350) < (monitor_geom.height * 0.9)) ? (350) : (monitor_geom
.height * 0.9))
);
869
870 fish->fortune_view = gtk_text_view_new ();
871 gtk_text_view_set_editable (GTK_TEXT_VIEW (fish->fortune_view)((((GtkTextView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish->fortune_view)), ((gtk_text_view_get_type ()))))
))
, FALSE(0));
872 gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (fish->fortune_view)((((GtkTextView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish->fortune_view)), ((gtk_text_view_get_type ()))))
))
, FALSE(0));
873 gtk_text_view_set_left_margin (GTK_TEXT_VIEW (fish->fortune_view)((((GtkTextView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish->fortune_view)), ((gtk_text_view_get_type ()))))
))
, 10);
874 gtk_text_view_set_right_margin (GTK_TEXT_VIEW (fish->fortune_view)((((GtkTextView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish->fortune_view)), ((gtk_text_view_get_type ()))))
))
, 10);
875 fish->fortune_buffer =
876 gtk_text_view_get_buffer (GTK_TEXT_VIEW (fish->fortune_view)((((GtkTextView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish->fortune_view)), ((gtk_text_view_get_type ()))))
))
);
877
878 gtk_text_buffer_create_tag (GTK_TEXT_BUFFER (fish->fortune_buffer)((((GtkTextBuffer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish->fortune_buffer)), ((gtk_text_buffer_get_type ()
))))))
,
879 "monospace_tag", "family",
880 "Monospace", NULL((void*)0));
881
882 scrolled = gtk_scrolled_window_new (NULL((void*)0), NULL((void*)0));
883 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled)((((GtkScrolledWindow*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((scrolled)), ((gtk_scrolled_window_get_type
()))))))
,
884 GTK_POLICY_AUTOMATIC,
885 GTK_POLICY_AUTOMATIC);
886 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled)((((GtkScrolledWindow*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((scrolled)), ((gtk_scrolled_window_get_type
()))))))
,
887 GTK_SHADOW_IN);
888
889 gtk_container_add (GTK_CONTAINER (scrolled)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((scrolled)), ((gtk_container_get_type ()))))))
, fish->fortune_view);
890
891 fish->fortune_label = gtk_label_new ("");
892 gtk_label_set_ellipsize (GTK_LABEL (fish->fortune_label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish->fortune_label)), ((gtk_label_get_type ()))))))
,
893 PANGO_ELLIPSIZE_MIDDLE);
894 fish->fortune_cmd_label = gtk_label_new ("");
895 gtk_label_set_xalign (GTK_LABEL (fish->fortune_cmd_label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish->fortune_cmd_label)), ((gtk_label_get_type ())))
)))
, 0.0);
896 gtk_label_set_yalign (GTK_LABEL (fish->fortune_cmd_label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish->fortune_cmd_label)), ((gtk_label_get_type ())))
)))
, 0.5);
897
898 vbox = gtk_dialog_get_content_area (GTK_DIALOG (fish->fortune_dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish->fortune_dialog)), ((gtk_dialog_get_type ())))))
)
);
899 gtk_box_pack_start (GTK_BOX (vbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((vbox)), ((gtk_box_get_type ()))))))
,
900 fish->fortune_label,
901 FALSE(0), FALSE(0), 6);
902
903 gtk_box_pack_start (GTK_BOX (vbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((vbox)), ((gtk_box_get_type ()))))))
,
904 scrolled,
905 TRUE(!(0)), TRUE(!(0)), 6);
906
907 gtk_box_pack_start (GTK_BOX (vbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((vbox)), ((gtk_box_get_type ()))))))
,
908 fish->fortune_cmd_label,
909 FALSE(0), FALSE(0), 6);
910
911 update_fortune_dialog (fish);
912
913 /* We don't show_all for the dialog since fortune_cmd_label
914 * might need to be hidden
915 * The dialog will be shown with gtk_window_present later */
916 gtk_widget_show (scrolled);
917 gtk_widget_show (fish->fortune_view);
918 gtk_widget_show (fish->fortune_label);
919 }
920
921 if (!user_command) {
922 char *command;
923 char * text;
924
925 command = g_markup_printf_escaped ("<tt>%s</tt>", argv[0]);
926 text = g_strdup_printf (_("The configured command is not "gettext ("The configured command is not " "working and has been replaced by: "
"%s")
927 "working and has been replaced by: "gettext ("The configured command is not " "working and has been replaced by: "
"%s")
928 "%s")gettext ("The configured command is not " "working and has been replaced by: "
"%s")
, command);
929 gtk_label_set_markup (GTK_LABEL (fish->fortune_cmd_label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish->fortune_cmd_label)), ((gtk_label_get_type ())))
)))
,
930 text);
931 g_free (command);
932 g_free (text);
933 gtk_widget_show (fish->fortune_cmd_label);
934 } else {
935 gtk_widget_hide (fish->fortune_cmd_label);
936 }
937
938 clear_fortune_text (fish);
939
940 screen = gtk_widget_get_screen (GTK_WIDGET (fish)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish)), ((gtk_widget_get_type ()))))))
);
941 display = gdk_screen_get_display (screen);
942 display_name = g_strdup (gdk_display_get_name (display))g_strdup_inline (gdk_display_get_name (display));
943 g_spawn_async_with_pipes (NULL((void*)0), /* working directory */
944 argv,
945 NULL((void*)0), /* envp */
946 G_SPAWN_SEARCH_PATH|G_SPAWN_STDERR_TO_DEV_NULL,
947 set_environment,
948 &display_name,
949 NULL((void*)0), /* child pid */
950 NULL((void*)0), /* stdin */
951 &output,
952 NULL((void*)0), /* stderr */
953 &error);
954 g_free (display_name);
955
956 if (error) {
957 char *message;
958
959 message = g_strdup_printf (_("Unable to execute '%s'\n\nDetails: %s")gettext ("Unable to execute '%s'\n\nDetails: %s"),
960 argv[0], error->message);
961 something_fishy_going_on (fish, message);
962 g_free (message);
963 g_error_free (error);
964 g_strfreev (argv);
965 return;
966 }
967
968 fish->io_channel = g_io_channel_unix_new (output);
969 /* set the correct encoding if the locale is not using UTF-8 */
970 if (!g_get_charset (&charset))
971 g_io_channel_set_encoding(fish->io_channel, charset, &error);
972 if (error) {
973 char *message;
974
975 message = g_strdup_printf (_("Unable to read from '%s'\n\nDetails: %s")gettext ("Unable to read from '%s'\n\nDetails: %s"),
976 argv[0], error->message);
977 something_fishy_going_on (fish, message);
978 g_free (message);
979 g_error_free (error);
980 g_strfreev (argv);
981 return;
982 }
983
984 g_strfreev (argv);
985
986 fish->source_id = g_io_add_watch (fish->io_channel,
987 G_IO_IN|G_IO_ERR|G_IO_HUP|G_IO_NVAL,
988 fish_read_output, fish);
989
990 gtk_window_set_screen (GTK_WINDOW (fish->fortune_dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish->fortune_dialog)), ((gtk_window_get_type ())))))
)
,
991 gtk_widget_get_screen (GTK_WIDGET (fish)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish)), ((gtk_widget_get_type ()))))))
));
992 gtk_window_present (GTK_WINDOW (fish->fortune_dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish->fortune_dialog)), ((gtk_window_get_type ())))))
)
);
993}
994
995static void name_changed_notify(GSettings* settings, gchar* key, FishApplet* fish)
996{
997 char *value;
998
999 value = g_settings_get_string (settings, key);
1000
1001 if (!value || *value == '\0' || (fish->name && !strcmp (fish->name, value))) {
1002 g_free (value);
1003 return;
1004 }
1005
1006 g_free (fish->name);
1007 fish->name = g_strdup (value)g_strdup_inline (value);
1008
1009 update_fortune_dialog (fish);
1010 set_tooltip (fish);
1011 set_ally_name_desc (GTK_WIDGET (fish)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish)), ((gtk_widget_get_type ()))))))
, fish);
1012
1013 if (fish->name_entry &&
1014 strcmp (gtk_entry_get_text (GTK_ENTRY (fish->name_entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish->name_entry)), ((gtk_entry_get_type ()))))))
), fish->name))
1015 gtk_entry_set_text (GTK_ENTRY (fish->name_entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish->name_entry)), ((gtk_entry_get_type ()))))))
, fish->name);
1016
1017 g_free (value);
1018}
1019
1020static void image_changed_notify(GSettings* settings, gchar* key, FishApplet* fish)
1021{
1022 char *value;
1023
1024 value = g_settings_get_string (settings, key);
1025
1026 if (!value || *value == '\0' || (fish->image && !strcmp (fish->image, value))) {
1027 g_free (value);
1028 return;
1029 }
1030
1031 g_free (fish->image);
1032 fish->image = g_strdup (value)g_strdup_inline (value);
1033
1034 load_fish_image (fish);
1035 update_pixmap (fish);
1036
1037 if (fish->image_chooser) {
1038 char *path_gsettings;
1039 char *path_chooser;
1040
1041 path_gsettings = get_image_path (fish);
1042 path_chooser = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (fish->image_chooser)((((GtkFileChooser*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish->image_chooser)), ((gtk_file_chooser_get_type ()
))))))
);
1043 if (strcmp (path_gsettings, path_chooser))
1044 gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (fish->image_chooser)((((GtkFileChooser*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish->image_chooser)), ((gtk_file_chooser_get_type ()
))))))
,
1045 path_gsettings);
1046
1047 g_free (path_gsettings);
1048 g_free (path_chooser);
1049 }
1050
1051 g_free (value);
1052}
1053
1054static void command_changed_notify(GSettings* settings, gchar* key, FishApplet* fish)
1055{
1056 char *value;
1057
1058 value = g_settings_get_string (settings, key);
1059
1060 if (!value || *value == '\0' || (fish->command && !strcmp (fish->command, value))) {
1061 g_free (value);
1062 return;
1063 }
1064
1065 g_free (fish->command);
1066 fish->command = g_strdup (value)g_strdup_inline (value);
1067
1068 if (fish->command_entry &&
1069 strcmp (gtk_entry_get_text (GTK_ENTRY (fish->command_entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish->command_entry)), ((gtk_entry_get_type ()))))))
), fish->command))
1070 gtk_entry_set_text (GTK_ENTRY (fish->command_entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish->command_entry)), ((gtk_entry_get_type ()))))))
, fish->command);
1071
1072 g_free (value);
1073}
1074
1075static void n_frames_changed_notify(GSettings* settings, gchar* key, FishApplet* fish)
1076{
1077 int value;
1078
1079 value = g_settings_get_int (settings, key);
1080
1081 if (fish->n_frames == value)
1082 return;
1083
1084 fish->n_frames = value;
1085
1086 if (fish->n_frames <= 0)
1087 fish->n_frames = 1;
1088
1089 update_pixmap (fish);
1090
1091 if (fish->frames_spin &&
1092 gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (fish->frames_spin)((((GtkSpinButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish->frames_spin)), ((gtk_spin_button_get_type ())))
)))
) != fish->n_frames)
1093 gtk_spin_button_set_value (GTK_SPIN_BUTTON (fish->frames_spin)((((GtkSpinButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish->frames_spin)), ((gtk_spin_button_get_type ())))
)))
, fish->n_frames);
1094}
1095
1096static char* get_location(void)
1097{
1098 static char location [256];
1099 char *buffer;
1100 FILE *zone;
1101 int i, len, count;
1102
1103 /* Old method : works for glibc < 2.2 */
1104 zone = fopen("/etc/timezone", "r");
1105 if (zone) {
1106 count = fscanf (zone, "%255s", location);
1107 fclose (zone);
1108 /* if we could read it, we return what we got */
1109 if (count == 1)
1110 return location;
1111 }
1112
1113 /* New method : works for glibc 2.2 */
1114 /* FIXME: this is broken for many distros, see the clock code */
1115 buffer = g_file_read_link ("/etc/localtime", NULL((void*)0));
1116 if (!buffer)
1117 return NULL((void*)0);
1118
1119 len = strlen (buffer);
1120 for (i = len, count = 0; (i > 0) && (count != 2); i--)
1121 if (buffer [i] == '/')
1122 count++;
1123
1124 if (count != 2) {
1125 g_free (buffer);
1126 return NULL((void*)0);
1127 }
1128
1129 memcpy (location, &buffer [i + 2], len - i - 2);
1130 g_free (buffer);
1131
1132 return location;
1133}
1134
1135static void init_fools_day(void)
1136{
1137 const char *spanish_timezones [] = {
1138 "Europe/Madrid",
1139 "Africa/Ceuta",
1140 "Atlantic/Canary",
1141 "America/Mexico_City",
1142 "Mexico/BajaSur",
1143 "Mexico/BajaNorte",
1144 "Mexico/General",
1145 NULL((void*)0)
1146 };
1147 char *location;
1148 int i;
1149
1150 if (!(location = get_location ()))
1151 return;
1152
1153 fools_day = 1; /* 1st */
1154 fools_month = 3; /* April */
1155 fools_hour_start = 0; /* Midnight */
1156 fools_hour_end = 12; /* Apparently jokes should stop at midday */
1157
1158 for (i = 0; spanish_timezones [i]; i++)
1159 if (!g_ascii_strcasecmp (spanish_timezones [i], location)) {
1160 /* Hah!, We are in Spain or Mexico
1161 * Spanish fool's day is 28th December
1162 */
1163 fools_day = 28;
1164 fools_month = 11;
1165 return;
1166 }
1167}
1168
1169static void check_april_fools(FishApplet* fish)
1170{
1171 struct tm *tm;
1172 time_t now;
1173
1174 time (&now);
1175 tm = localtime (&now);
1176
1177 if (fish->april_fools &&
1178 (tm->tm_mon != fools_month ||
1179 tm->tm_mday != fools_day ||
1180 tm->tm_hour >= fools_hour_end)) {
1181 fish->april_fools = FALSE(0);
1182 update_pixmap (fish);
1183 } else if (tm->tm_mon == fools_month &&
1184 tm->tm_mday == fools_day &&
1185 tm->tm_hour >= fools_hour_start &&
1186 tm->tm_hour <= fools_hour_end) {
1187 fish->april_fools = TRUE(!(0));
1188 update_pixmap (fish);
1189 }
1190}
1191
1192static gboolean timeout_handler(gpointer data)
1193{
1194 FishApplet *fish = (FishApplet *) data;
1195
1196 check_april_fools (fish);
1197
1198 if (fish->april_fools)
1199 return TRUE(!(0));
1200
1201 fish->current_frame++;
1202 if (fish->current_frame >= fish->n_frames)
1203 fish->current_frame = 0;
1204
1205 gtk_widget_queue_draw (fish->drawing_area);
1206
1207 return TRUE(!(0));
1208}
1209
1210static void setup_timeout(FishApplet *fish)
1211{
1212 if (fish->timeout)
1213 g_source_remove (fish->timeout);
1214
1215 fish->timeout = g_timeout_add (fish->speed * 1000,
1216 timeout_handler,
1217 fish);
1218}
1219
1220static void speed_changed_notify(GSettings* settings, gchar* key, FishApplet* fish)
1221{
1222 gdouble value;
1223
1224 value = g_settings_get_double (settings, key);
1225
1226 if (fish->speed == value)
1227 return;
1228 fish->speed = value;
1229
1230 setup_timeout (fish);
1231
1232 if (fish->speed_spin &&
1233 gtk_spin_button_get_value (GTK_SPIN_BUTTON (fish->frames_spin)((((GtkSpinButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish->frames_spin)), ((gtk_spin_button_get_type ())))
)))
) != fish->speed)
1234 gtk_spin_button_set_value (GTK_SPIN_BUTTON (fish->speed_spin)((((GtkSpinButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish->speed_spin)), ((gtk_spin_button_get_type ()))))
))
, fish->speed);
1235}
1236
1237static void rotate_changed_notify(GSettings* settings, gchar* key, FishApplet* fish)
1238{
1239 gboolean value;
1240
1241 value = g_settings_get_boolean (settings, key);
1242
1243 if (fish->rotate == value)
1244 return;
1245 fish->rotate = value;
1246
1247 if (fish->orientation == MATE_PANEL_APPLET_ORIENT_LEFT ||
1248 fish->orientation == MATE_PANEL_APPLET_ORIENT_RIGHT)
1249 update_pixmap (fish);
1250
1251 if (fish->rotate_toggle &&
1252 gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (fish->rotate_toggle)((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish->rotate_toggle)), ((gtk_toggle_button_get_type (
)))))))
) != fish->rotate)
1253 gtk_toggle_button_set_active (
1254 GTK_TOGGLE_BUTTON (fish->rotate_toggle)((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish->rotate_toggle)), ((gtk_toggle_button_get_type (
)))))))
, fish->rotate);
1255}
1256
1257static void fish_disable_commande_line_notify(GSettings* settings, gchar* key, FishApplet* fish)
1258{
1259 gboolean locked_down;
1260
1261 locked_down = !g_settings_get_boolean (settings, key);
1262
1263 if (fish->command_label != NULL((void*)0))
1264 gtk_widget_set_sensitive (fish->command_label, locked_down);
1265 if (fish->command_entry != NULL((void*)0))
1266 gtk_widget_set_sensitive (fish->command_entry, locked_down);
1267}
1268
1269static void setup_gsettings(FishApplet* fish)
1270{
1271 MatePanelApplet *applet = (MatePanelApplet *) fish;
1272
1273 fish->settings = mate_panel_applet_settings_new (applet, FISH_SCHEMA"org.mate.panel.applet.fish");
1274 fish->lockdown_settings = g_settings_new (LOCKDOWN_SCHEMA"org.mate.lockdown");
1275
1276 g_signal_connect (fish->settings,g_signal_connect_data ((fish->settings), ("changed::" "name"
), (((GCallback) (name_changed_notify))), (fish), ((void*)0),
(GConnectFlags) 0)
1277 "changed::" FISH_NAME_KEY,g_signal_connect_data ((fish->settings), ("changed::" "name"
), (((GCallback) (name_changed_notify))), (fish), ((void*)0),
(GConnectFlags) 0)
1278 G_CALLBACK (name_changed_notify),g_signal_connect_data ((fish->settings), ("changed::" "name"
), (((GCallback) (name_changed_notify))), (fish), ((void*)0),
(GConnectFlags) 0)
1279 fish)g_signal_connect_data ((fish->settings), ("changed::" "name"
), (((GCallback) (name_changed_notify))), (fish), ((void*)0),
(GConnectFlags) 0)
;
1280 g_signal_connect (fish->settings,g_signal_connect_data ((fish->settings), ("changed::" "image"
), (((GCallback) (image_changed_notify))), (fish), ((void*)0)
, (GConnectFlags) 0)
1281 "changed::" FISH_IMAGE_KEY,g_signal_connect_data ((fish->settings), ("changed::" "image"
), (((GCallback) (image_changed_notify))), (fish), ((void*)0)
, (GConnectFlags) 0)
1282 G_CALLBACK (image_changed_notify),g_signal_connect_data ((fish->settings), ("changed::" "image"
), (((GCallback) (image_changed_notify))), (fish), ((void*)0)
, (GConnectFlags) 0)
1283 fish)g_signal_connect_data ((fish->settings), ("changed::" "image"
), (((GCallback) (image_changed_notify))), (fish), ((void*)0)
, (GConnectFlags) 0)
;
1284 g_signal_connect (fish->settings,g_signal_connect_data ((fish->settings), ("changed::" "command"
), (((GCallback) (command_changed_notify))), (fish), ((void*)
0), (GConnectFlags) 0)
1285 "changed::" FISH_COMMAND_KEY,g_signal_connect_data ((fish->settings), ("changed::" "command"
), (((GCallback) (command_changed_notify))), (fish), ((void*)
0), (GConnectFlags) 0)
1286 G_CALLBACK (command_changed_notify),g_signal_connect_data ((fish->settings), ("changed::" "command"
), (((GCallback) (command_changed_notify))), (fish), ((void*)
0), (GConnectFlags) 0)
1287 fish)g_signal_connect_data ((fish->settings), ("changed::" "command"
), (((GCallback) (command_changed_notify))), (fish), ((void*)
0), (GConnectFlags) 0)
;
1288 g_signal_connect (fish->settings,g_signal_connect_data ((fish->settings), ("changed::" "frames"
), (((GCallback) (n_frames_changed_notify))), (fish), ((void*
)0), (GConnectFlags) 0)
1289 "changed::" FISH_FRAMES_KEY,g_signal_connect_data ((fish->settings), ("changed::" "frames"
), (((GCallback) (n_frames_changed_notify))), (fish), ((void*
)0), (GConnectFlags) 0)
1290 G_CALLBACK (n_frames_changed_notify),g_signal_connect_data ((fish->settings), ("changed::" "frames"
), (((GCallback) (n_frames_changed_notify))), (fish), ((void*
)0), (GConnectFlags) 0)
1291 fish)g_signal_connect_data ((fish->settings), ("changed::" "frames"
), (((GCallback) (n_frames_changed_notify))), (fish), ((void*
)0), (GConnectFlags) 0)
;
1292 g_signal_connect (fish->settings,g_signal_connect_data ((fish->settings), ("changed::" "speed"
), (((GCallback) (speed_changed_notify))), (fish), ((void*)0)
, (GConnectFlags) 0)
1293 "changed::" FISH_SPEED_KEY,g_signal_connect_data ((fish->settings), ("changed::" "speed"
), (((GCallback) (speed_changed_notify))), (fish), ((void*)0)
, (GConnectFlags) 0)
1294 G_CALLBACK (speed_changed_notify),g_signal_connect_data ((fish->settings), ("changed::" "speed"
), (((GCallback) (speed_changed_notify))), (fish), ((void*)0)
, (GConnectFlags) 0)
1295 fish)g_signal_connect_data ((fish->settings), ("changed::" "speed"
), (((GCallback) (speed_changed_notify))), (fish), ((void*)0)
, (GConnectFlags) 0)
;
1296 g_signal_connect (fish->settings,g_signal_connect_data ((fish->settings), ("changed::" "rotate"
), (((GCallback) (rotate_changed_notify))), (fish), ((void*)0
), (GConnectFlags) 0)
1297 "changed::" FISH_ROTATE_KEY,g_signal_connect_data ((fish->settings), ("changed::" "rotate"
), (((GCallback) (rotate_changed_notify))), (fish), ((void*)0
), (GConnectFlags) 0)
1298 G_CALLBACK (rotate_changed_notify),g_signal_connect_data ((fish->settings), ("changed::" "rotate"
), (((GCallback) (rotate_changed_notify))), (fish), ((void*)0
), (GConnectFlags) 0)
1299 fish)g_signal_connect_data ((fish->settings), ("changed::" "rotate"
), (((GCallback) (rotate_changed_notify))), (fish), ((void*)0
), (GConnectFlags) 0)
;
1300 g_signal_connect (fish->lockdown_settings,g_signal_connect_data ((fish->lockdown_settings), ("changed::"
"disable-command-line"), (((GCallback) (fish_disable_commande_line_notify
))), (fish), ((void*)0), (GConnectFlags) 0)
1301 "changed::" LOCKDOWN_DISABLE_COMMAND_LINE_KEY,g_signal_connect_data ((fish->lockdown_settings), ("changed::"
"disable-command-line"), (((GCallback) (fish_disable_commande_line_notify
))), (fish), ((void*)0), (GConnectFlags) 0)
1302 G_CALLBACK (fish_disable_commande_line_notify),g_signal_connect_data ((fish->lockdown_settings), ("changed::"
"disable-command-line"), (((GCallback) (fish_disable_commande_line_notify
))), (fish), ((void*)0), (GConnectFlags) 0)
1303 fish)g_signal_connect_data ((fish->lockdown_settings), ("changed::"
"disable-command-line"), (((GCallback) (fish_disable_commande_line_notify
))), (fish), ((void*)0), (GConnectFlags) 0)
;
1304}
1305
1306static gboolean load_fish_image(FishApplet* fish)
1307{
1308 GdkPixbuf *pixbuf;
1309 GError *error = NULL((void*)0);
1310 char *path = NULL((void*)0);
1311
1312 if (!fish->image)
1313 return FALSE(0);
1314
1315 path = get_image_path (fish);
1316
1317 pixbuf = gdk_pixbuf_new_from_file (path, &error);
1318 if (error) {
1319 g_warning ("Cannot load '%s': %s", path, error->message);
1320 g_error_free (error);
1321 g_free (path);
1322 return FALSE(0);
1323 }
1324
1325 if (fish->pixbuf)
1326 g_object_unref (fish->pixbuf);
1327 fish->pixbuf = pixbuf;
1328
1329 if (fish->preview_image)
1330 gtk_image_set_from_pixbuf (GTK_IMAGE (fish->preview_image)((((GtkImage*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish->preview_image)), ((gtk_image_get_type ()))))))
,
1331 fish->pixbuf);
1332
1333 g_free (path);
1334
1335 return TRUE(!(0));
1336}
1337
1338static gboolean
1339update_pixmap_in_idle (gpointer data)
1340{
1341 update_pixmap (FISH_APPLET (data)((((FishApplet*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), (fish_applet_get_type())))))
);
1342 return FALSE(0);
1343}
1344
1345static void update_pixmap(FishApplet* fish)
1346{
1347 GtkWidget *widget = fish->drawing_area;
1348 GtkRequisition prev_requisition;
1349 GtkAllocation allocation;
1350 int width = -1;
1351 int height = -1;
1352 int pixbuf_width = -1;
1353 int pixbuf_height = -1;
1354 gboolean rotate = FALSE(0);
1355 cairo_t *cr;
1356 cairo_matrix_t matrix;
1357 cairo_pattern_t *pattern;
1358
1359 gtk_widget_get_allocation (widget, &allocation);
1360
1361 if (!gtk_widget_get_realized (widget) ||
1362 allocation.width <= 0 ||
1363 allocation.height <= 0)
1364 return;
1365
1366 if (!fish->pixbuf && !load_fish_image (fish))
1367 return;
1368
1369 if (fish->rotate &&
1370 (fish->orientation == MATE_PANEL_APPLET_ORIENT_LEFT ||
1371 fish->orientation == MATE_PANEL_APPLET_ORIENT_RIGHT))
1372 rotate = TRUE(!(0));
1373
1374 pixbuf_width = gdk_pixbuf_get_width (fish->pixbuf);
1375 pixbuf_height = gdk_pixbuf_get_height (fish->pixbuf);
1376
1377 prev_requisition = fish->requisition;
1378
1379 if (fish->orientation == MATE_PANEL_APPLET_ORIENT_UP ||
1380 fish->orientation == MATE_PANEL_APPLET_ORIENT_DOWN) {
1381 height = allocation.height;
1382 width = pixbuf_width * ((gdouble) height / pixbuf_height);
1383 fish->requisition.width = width / fish->n_frames;
1384 fish->requisition.height = height;
1385 } else {
1386 if (!rotate) {
1387 width = allocation.width * fish->n_frames;
1388 height = pixbuf_height * ((gdouble) width / pixbuf_width);
1389 fish->requisition.width = allocation.width;
1390 fish->requisition.height = height;
1391 } else {
1392 width = allocation.width;
1393 height = pixbuf_width * ((gdouble) width / pixbuf_height);
1394 fish->requisition.width = width;
1395 fish->requisition.height = height / fish->n_frames;
1396 }
1397 }
1398
1399 if (prev_requisition.width != fish->requisition.width ||
1400 prev_requisition.height != fish->requisition.height) {
1401 gtk_widget_set_size_request (widget,
1402 fish->requisition.width,
1403 fish->requisition.height);
1404 }
1405
1406 g_assert (width != -1 && height != -1)do { if (width != -1 && height != -1) ; else g_assertion_message_expr
(((gchar*) 0), "fish.c", 1406, ((const char*) (__func__)), "width != -1 && height != -1"
); } while (0)
;
1407
1408 if (width == 0 || height == 0)
1409 return;
1410
1411 if (fish->surface)
1412 cairo_surface_destroy (fish->surface);
1413 fish->surface = gdk_window_create_similar_surface (gtk_widget_get_window (widget),
1414 CAIRO_CONTENT_COLOR_ALPHA,
1415 width, height);
1416 fish->surface_width = width;
1417 fish->surface_height = height;
1418
1419 gtk_widget_queue_resize (widget);
1420
1421 g_assert (pixbuf_width != -1 && pixbuf_height != -1)do { if (pixbuf_width != -1 && pixbuf_height != -1) ;
else g_assertion_message_expr (((gchar*) 0), "fish.c", 1421,
((const char*) (__func__)), "pixbuf_width != -1 && pixbuf_height != -1"
); } while (0)
;
1422
1423 cr = cairo_create (fish->surface);
1424
1425 cairo_set_source_rgb (cr, 1, 1, 1);
1426 cairo_paint (cr);
1427
1428 gdk_cairo_set_source_pixbuf (cr, fish->pixbuf, 0, 0);
1429 pattern = cairo_get_source (cr);
1430 cairo_pattern_set_filter (pattern, CAIRO_FILTER_BEST);
1431
1432 cairo_matrix_init_identity (&matrix);
1433
1434 if (fish->april_fools) {
1435 cairo_matrix_translate (&matrix,
1436 pixbuf_width - 1, pixbuf_height - 1);
1437 cairo_matrix_rotate (&matrix, G_PI3.1415926535897932384626433832795028841971693993751);
1438 }
1439
1440 if (rotate) {
1441 if (fish->orientation == MATE_PANEL_APPLET_ORIENT_RIGHT) {
1442 cairo_matrix_translate (&matrix, pixbuf_width - 1, 0);
1443 cairo_matrix_rotate (&matrix, G_PI_21.5707963267948966192313216916397514420985846996876);
1444 } else {
1445 cairo_matrix_translate (&matrix, 0, pixbuf_height - 1);
1446 cairo_matrix_rotate (&matrix, G_PI3.1415926535897932384626433832795028841971693993751 * 1.5);
1447 }
1448 cairo_matrix_scale (&matrix,
1449 (double) (pixbuf_height - 1) / width,
1450 (double) (pixbuf_width - 1) / height);
1451 } else {
1452 cairo_matrix_scale (&matrix,
1453 (double) (pixbuf_width - 1) / width,
1454 (double) (pixbuf_height - 1) / height);
1455 }
1456
1457 cairo_pattern_set_matrix (pattern, &matrix);
1458
1459 cairo_rectangle (cr, 0, 0, width, height);
1460 cairo_fill (cr);
1461
1462 if (fish->april_fools) {
1463 cairo_set_source_rgb (cr, 1, 0.5, 0);
1464 cairo_paint_with_alpha (cr, 0.25);
1465 }
1466
1467 cairo_destroy (cr);
1468}
1469
1470static gboolean fish_applet_draw(GtkWidget* widget, cairo_t *cr, FishApplet* fish)
1471{
1472 int width, height;
1473 int src_x, src_y;
1474
1475 g_return_val_if_fail (fish->surface != NULL, FALSE)do { if ((fish->surface != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "fish->surface != NULL"
); return ((0)); } } while (0)
;
1476
1477 g_assert (fish->n_frames > 0)do { if (fish->n_frames > 0) ; else g_assertion_message_expr
(((gchar*) 0), "fish.c", 1477, ((const char*) (__func__)), "fish->n_frames > 0"
); } while (0)
;
1478
1479 width = fish->surface_width;
1480 height = fish->surface_height;
1481 src_x = 0;
1482 src_y = 0;
1483
1484 if (fish->rotate) {
1485 if (fish->orientation == MATE_PANEL_APPLET_ORIENT_RIGHT)
1486 src_y += ((height * (fish->n_frames - 1 - fish->current_frame)) / fish->n_frames);
1487 else if (fish->orientation == MATE_PANEL_APPLET_ORIENT_LEFT)
1488 src_y += ((height * fish->current_frame) / fish->n_frames);
1489 else
1490 src_x += ((width * fish->current_frame) / fish->n_frames);
1491 } else
1492 src_x += ((width * fish->current_frame) / fish->n_frames);
1493
1494 cairo_save (cr);
1495 cairo_set_source_surface (cr, fish->surface, -src_x, -src_y);
1496 cairo_paint (cr);
1497 cairo_restore (cr);
1498
1499 return FALSE(0);
1500}
1501
1502static void fish_applet_size_allocate(GtkWidget* widget, GtkAllocation* allocation, FishApplet* fish)
1503{
1504 if (allocation->width == fish->prev_allocation.width &&
1505 allocation->height == fish->prev_allocation.height)
1506 return;
1507
1508 fish->prev_allocation = *allocation;
1509 g_idle_add (update_pixmap_in_idle, fish);
1510}
1511
1512static void fish_applet_realize(GtkWidget* widget, FishApplet* fish)
1513{
1514 if (!fish->surface)
1515 update_pixmap (fish);
1516}
1517
1518static void fish_applet_unrealize(GtkWidget* widget, FishApplet* fish)
1519{
1520 if (fish->surface)
1521 cairo_surface_destroy (fish->surface);
1522 fish->surface = NULL((void*)0);
1523 fish->surface_width = 0;
1524 fish->surface_height = 0;
1525}
1526
1527static void fish_applet_change_orient(MatePanelApplet* applet, MatePanelAppletOrient orientation)
1528{
1529 FishApplet *fish = (FishApplet *) applet;
1530
1531 if (fish->orientation == orientation)
1532 return;
1533
1534 fish->orientation = orientation;
1535
1536 if (fish->surface)
1537 update_pixmap (fish);
1538}
1539
1540static void change_water(FishApplet* fish)
1541{
1542 GtkWidget *dialog;
1543
1544 dialog = gtk_message_dialog_new (
1545 NULL((void*)0), 0, GTK_MESSAGE_INFO,
1546 GTK_BUTTONS_OK,
1547 _("The water needs changing")gettext ("The water needs changing"));
1548 gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog)((((GtkMessageDialog*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((dialog)), ((gtk_message_dialog_get_type ())
)))))
,
1549 _("Look at today's date!")gettext ("Look at today's date!"));
1550 gtk_window_set_icon_name (GTK_WINDOW (dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_window_get_type ()))))))
, FISH_ICON"mate-panel-fish");
1551 gtk_window_set_screen (GTK_WINDOW (dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_window_get_type ()))))))
,
1552 gtk_widget_get_screen (GTK_WIDGET (fish)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish)), ((gtk_widget_get_type ()))))))
));
1553
1554 gtk_widget_show_all (dialog);
1555
1556 g_signal_connect (dialog, "response",g_signal_connect_data ((dialog), ("response"), (((GCallback) (
gtk_widget_destroy))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
1557 G_CALLBACK (gtk_widget_destroy), NULL)g_signal_connect_data ((dialog), ("response"), (((GCallback) (
gtk_widget_destroy))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
1558}
1559
1560static gboolean handle_keypress(GtkWidget* widget, GdkEventKey* event, FishApplet* fish)
1561{
1562 switch (event->keyval) {
1563 case GDK_KEY_space0x020:
1564 case GDK_KEY_KP_Space0xff80:
1565 case GDK_KEY_Return0xff0d:
1566 case GDK_KEY_KP_Enter0xff8d:
1567 case GDK_KEY_ISO_Enter0xfe34:
1568 case GDK_KEY_3270_Enter0xfd1e:
1569 if (fish->april_fools) {
1570 change_water (fish);
1571 return TRUE(!(0));
1572 }
1573
1574 display_fortune_dialog (fish);
1575 break;
1576 default:
1577 return FALSE(0);
1578 break;
This statement is never executed
1579 }
1580
1581 return TRUE(!(0));
1582}
1583
1584static gboolean fish_enter_notify(GtkWidget* widget, GdkEventCrossing* event)
1585{
1586 FishApplet *fish;
1587 GtkWidget *event_widget;
1588
1589 fish = FISH_APPLET (widget)((((FishApplet*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (fish_applet_get_type())))))
;
1590 event_widget = gtk_get_event_widget ((GdkEvent*) event);
1591
1592 if ((event_widget == widget) &&
1593 (event->detail != GDK_NOTIFY_INFERIOR))
1594 fish->in_applet = TRUE(!(0));
1595
1596 return FALSE(0);
1597}
1598
1599static gboolean fish_leave_notify(GtkWidget* widget, GdkEventCrossing* event)
1600{
1601 FishApplet *fish;
1602 GtkWidget *event_widget;
1603
1604 fish = FISH_APPLET (widget)((((FishApplet*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (fish_applet_get_type())))))
;
1605 event_widget = gtk_get_event_widget ((GdkEvent*) event);
1606
1607 if ((event_widget == widget) &&
1608 (event->detail != GDK_NOTIFY_INFERIOR))
1609 fish->in_applet = FALSE(0);
1610
1611 return FALSE(0);
1612}
1613
1614static gboolean handle_button_release(FishApplet* fish, GdkEventButton* event)
1615{
1616 if (!fish->in_applet || event->button != 1)
1617 return FALSE(0);
1618
1619 if (fish->april_fools) {
1620 change_water (fish);
1621 return TRUE(!(0));
1622 }
1623
1624 display_fortune_dialog (fish);
1625
1626 return TRUE(!(0));
1627}
1628
1629static void set_tooltip(FishApplet* fish)
1630{
1631 const char *desc_format = _("%s the Fish, the fortune teller")gettext ("%s the Fish, the fortune teller");
1632 char *desc;
1633
1634 desc = g_markup_printf_escaped (desc_format, fish->name);
1635 gtk_widget_set_tooltip_markup (GTK_WIDGET (fish)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish)), ((gtk_widget_get_type ()))))))
, desc);
1636 g_free (desc);
1637}
1638
1639static void setup_fish_widget(FishApplet* fish)
1640{
1641 GtkWidget *widget = (GtkWidget *) fish;
1642
1643 fish->frame = gtk_frame_new (NULL((void*)0));
1644 gtk_frame_set_shadow_type (GTK_FRAME (fish->frame)((((GtkFrame*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish->frame)), ((gtk_frame_get_type ()))))))
, GTK_SHADOW_IN);
1645 gtk_container_add (GTK_CONTAINER (widget)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_container_get_type ()))))))
, fish->frame);
1646
1647 fish->drawing_area = gtk_drawing_area_new ();
1648 gtk_container_add (GTK_CONTAINER (fish->frame)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish->frame)), ((gtk_container_get_type ()))))))
, fish->drawing_area);
1649
1650 g_signal_connect (fish->drawing_area, "realize",g_signal_connect_data ((fish->drawing_area), ("realize"), (
((GCallback) (fish_applet_realize))), (fish), ((void*)0), (GConnectFlags
) 0)
1651 G_CALLBACK (fish_applet_realize), fish)g_signal_connect_data ((fish->drawing_area), ("realize"), (
((GCallback) (fish_applet_realize))), (fish), ((void*)0), (GConnectFlags
) 0)
;
1652 g_signal_connect (fish->drawing_area, "unrealize",g_signal_connect_data ((fish->drawing_area), ("unrealize")
, (((GCallback) (fish_applet_unrealize))), (fish), ((void*)0)
, (GConnectFlags) 0)
1653 G_CALLBACK (fish_applet_unrealize), fish)g_signal_connect_data ((fish->drawing_area), ("unrealize")
, (((GCallback) (fish_applet_unrealize))), (fish), ((void*)0)
, (GConnectFlags) 0)
;
1654 g_signal_connect (fish->drawing_area, "size-allocate",g_signal_connect_data ((fish->drawing_area), ("size-allocate"
), (((GCallback) (fish_applet_size_allocate))), (fish), ((void
*)0), (GConnectFlags) 0)
1655 G_CALLBACK (fish_applet_size_allocate), fish)g_signal_connect_data ((fish->drawing_area), ("size-allocate"
), (((GCallback) (fish_applet_size_allocate))), (fish), ((void
*)0), (GConnectFlags) 0)
;
1656 g_signal_connect (fish->drawing_area, "draw",g_signal_connect_data ((fish->drawing_area), ("draw"), (((
GCallback) (fish_applet_draw))), (fish), ((void*)0), (GConnectFlags
) 0)
1657 G_CALLBACK (fish_applet_draw), fish)g_signal_connect_data ((fish->drawing_area), ("draw"), (((
GCallback) (fish_applet_draw))), (fish), ((void*)0), (GConnectFlags
) 0)
;
1658
1659 gtk_widget_add_events (widget, GDK_ENTER_NOTIFY_MASK |
1660 GDK_LEAVE_NOTIFY_MASK |
1661 GDK_BUTTON_RELEASE_MASK);
1662
1663 g_signal_connect_swapped (widget, "enter-notify-event",g_signal_connect_data ((widget), ("enter-notify-event"), (((GCallback
) (fish_enter_notify))), (fish), ((void*)0), G_CONNECT_SWAPPED
)
1664 G_CALLBACK (fish_enter_notify), fish)g_signal_connect_data ((widget), ("enter-notify-event"), (((GCallback
) (fish_enter_notify))), (fish), ((void*)0), G_CONNECT_SWAPPED
)
;
1665 g_signal_connect_swapped (widget, "leave-notify-event",g_signal_connect_data ((widget), ("leave-notify-event"), (((GCallback
) (fish_leave_notify))), (fish), ((void*)0), G_CONNECT_SWAPPED
)
1666 G_CALLBACK (fish_leave_notify), fish)g_signal_connect_data ((widget), ("leave-notify-event"), (((GCallback
) (fish_leave_notify))), (fish), ((void*)0), G_CONNECT_SWAPPED
)
;
1667 g_signal_connect_swapped (widget, "button-release-event",g_signal_connect_data ((widget), ("button-release-event"), ((
(GCallback) (handle_button_release))), (fish), ((void*)0), G_CONNECT_SWAPPED
)
1668 G_CALLBACK (handle_button_release), fish)g_signal_connect_data ((widget), ("button-release-event"), ((
(GCallback) (handle_button_release))), (fish), ((void*)0), G_CONNECT_SWAPPED
)
;
1669
1670 gtk_widget_add_events (fish->drawing_area, GDK_BUTTON_RELEASE_MASK);
1671 g_signal_connect_swapped (fish->drawing_area, "button-release-event",g_signal_connect_data ((fish->drawing_area), ("button-release-event"
), (((GCallback) (handle_button_release))), (fish), ((void*)0
), G_CONNECT_SWAPPED)
1672 G_CALLBACK (handle_button_release), fish)g_signal_connect_data ((fish->drawing_area), ("button-release-event"
), (((GCallback) (handle_button_release))), (fish), ((void*)0
), G_CONNECT_SWAPPED)
;
1673
1674 load_fish_image (fish);
1675
1676 update_pixmap (fish);
1677
1678 setup_timeout (fish);
1679
1680 set_tooltip (fish);
1681 set_ally_name_desc (GTK_WIDGET (fish)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((fish)), ((gtk_widget_get_type ()))))))
, fish);
1682
1683 g_signal_connect (fish, "key-press-event",g_signal_connect_data ((fish), ("key-press-event"), (((GCallback
) (handle_keypress))), (fish), ((void*)0), (GConnectFlags) 0)
1684 G_CALLBACK (handle_keypress), fish)g_signal_connect_data ((fish), ("key-press-event"), (((GCallback
) (handle_keypress))), (fish), ((void*)0), (GConnectFlags) 0)
;
1685
1686 gtk_widget_show_all (widget);
1687}
1688
1689static const GtkActionEntry fish_menu_verbs[] = {
1690 { "FishPreferences", "document-properties", N_("_Preferences")("_Preferences"),
1691 NULL((void*)0), NULL((void*)0),
1692 G_CALLBACK (display_preferences_dialog)((GCallback) (display_preferences_dialog)) },
1693 { "FishHelp", "help-browser", N_("_Help")("_Help"),
1694 NULL((void*)0), NULL((void*)0),
1695 G_CALLBACK (display_help_dialog)((GCallback) (display_help_dialog)) },
1696 { "FishAbout", "help-about", N_("_About")("_About"),
1697 NULL((void*)0), NULL((void*)0),
1698 G_CALLBACK (display_about_dialog)((GCallback) (display_about_dialog)) }
1699};
1700
1701static gboolean fish_applet_fill(FishApplet* fish)
1702{
1703 MatePanelApplet* applet = (MatePanelApplet*) fish;
1704 GtkActionGroup* action_group;
1705
1706 fish->orientation = mate_panel_applet_get_orient (applet);
1707
1708 setup_gsettings (fish);
1709
1710 fish->name = g_settings_get_string (fish->settings, FISH_NAME_KEY"name");
1711
1712 if (!fish->name)
1713 {
1714 fish->name = g_strdup ("Wanda")g_strdup_inline ("Wanda"); /* Fallback */
1715 }
1716
1717 fish->image = g_settings_get_string (fish->settings, FISH_IMAGE_KEY"image");
1718
1719 if (!fish->image)
1720 fish->image = g_strdup ("fishanim.png")g_strdup_inline ("fishanim.png"); /* Fallback */
1721
1722 fish->command = g_settings_get_string (fish->settings, FISH_COMMAND_KEY"command");
1723
1724 fish->n_frames = g_settings_get_int (fish->settings, FISH_FRAMES_KEY"frames");
1725
1726 if (fish->n_frames <= 0)
1727 fish->n_frames = 1;
1728
1729 fish->speed = g_settings_get_double (fish->settings, FISH_SPEED_KEY"speed");
1730
1731 fish->rotate = g_settings_get_boolean (fish->settings, FISH_ROTATE_KEY"rotate");
1732
1733 action_group = gtk_action_group_new ("Fish Applet Actions");
1734 gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE"mate-panel");
1735 gtk_action_group_add_actions (action_group,
1736 fish_menu_verbs,
1737 G_N_ELEMENTS (fish_menu_verbs)(sizeof (fish_menu_verbs) / sizeof ((fish_menu_verbs)[0])),
1738 fish);
1739 mate_panel_applet_setup_menu_from_resource (applet,
1740 FISH_RESOURCE_PATH"/org/mate/panel/applet/fish/" "fish-menu.xml",
1741 action_group);
1742
1743 if (mate_panel_applet_get_locked_down (applet)) {
1744 GtkAction *action;
1745
1746 action = gtk_action_group_get_action (action_group, "FishPreferences");
1747 gtk_action_set_visible (action, FALSE(0));
1748 }
1749 g_object_unref (action_group);
1750
1751 #ifndef FISH_INPROCESS1
1752 gtk_window_set_default_icon_name(FISH_ICON"mate-panel-fish");
1753 #endif
1754
1755 setup_fish_widget(fish);
1756
1757 return TRUE(!(0));
1758}
1759
1760static gboolean fishy_factory(MatePanelApplet* applet, const char* iid, gpointer data)
1761{
1762 gboolean retval = FALSE(0);
1763
1764 if (!strcmp(iid, "FishApplet"))
1765 {
1766 retval = fish_applet_fill(FISH_APPLET(applet)((((FishApplet*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (fish_applet_get_type())))))
);
1767 }
1768
1769 return retval;
1770}
1771
1772static void fish_applet_dispose (GObject *object)
1773{
1774 FishApplet* fish = (FishApplet*) object;
1775
1776 if (fish->settings != NULL((void*)0))
1777 g_signal_handlers_disconnect_by_data (fish->settings,g_signal_handlers_disconnect_matched ((fish->settings), G_SIGNAL_MATCH_DATA
, 0, 0, ((void*)0), ((void*)0), (fish))
1778 fish)g_signal_handlers_disconnect_matched ((fish->settings), G_SIGNAL_MATCH_DATA
, 0, 0, ((void*)0), ((void*)0), (fish))
;
1779
1780 if (fish->timeout)
1781 g_source_remove (fish->timeout);
1782 fish->timeout = 0;
1783
1784 g_clear_object (&fish->settings)do { _Static_assert (sizeof *((&fish->settings)) == sizeof
(gpointer), "Expression evaluates to false"); __typeof__ (((
&fish->settings))) _pp = ((&fish->settings)); __typeof__
(*((&fish->settings))) _ptr = *_pp; *_pp = ((void*)0)
; if (_ptr) (g_object_unref) (_ptr); } while (0)
;
1785 g_clear_object (&fish->lockdown_settings)do { _Static_assert (sizeof *((&fish->lockdown_settings
)) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(((&fish->lockdown_settings))) _pp = ((&fish->
lockdown_settings)); __typeof__ (*((&fish->lockdown_settings
))) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (g_object_unref
) (_ptr); } while (0)
;
1786 g_clear_pointer (&fish->name, g_free)do { _Static_assert (sizeof *(&fish->name) == sizeof (
gpointer), "Expression evaluates to false"); __typeof__ ((&
fish->name)) _pp = (&fish->name); __typeof__ (*(&
fish->name)) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (g_free
) (_ptr); } while (0)
;
1787 g_clear_pointer (&fish->image, g_free)do { _Static_assert (sizeof *(&fish->image) == sizeof (
gpointer), "Expression evaluates to false"); __typeof__ ((&
fish->image)) _pp = (&fish->image); __typeof__ (*(&
fish->image)) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (g_free
) (_ptr); } while (0)
;
1788 g_clear_pointer (&fish->command, g_free)do { _Static_assert (sizeof *(&fish->command) == sizeof
(gpointer), "Expression evaluates to false"); __typeof__ ((&
fish->command)) _pp = (&fish->command); __typeof__ (
*(&fish->command)) _ptr = *_pp; *_pp = ((void*)0); if (
_ptr) (g_free) (_ptr); } while (0)
;
1789
1790 if (fish->surface)
1791 cairo_surface_destroy (fish->surface);
1792 fish->surface = NULL((void*)0);
1793 fish->surface_width = 0;
1794 fish->surface_height = 0;
1795
1796 g_clear_object (&fish->pixbuf)do { _Static_assert (sizeof *((&fish->pixbuf)) == sizeof
(gpointer), "Expression evaluates to false"); __typeof__ (((
&fish->pixbuf))) _pp = ((&fish->pixbuf)); __typeof__
(*((&fish->pixbuf))) _ptr = *_pp; *_pp = ((void*)0); if
(_ptr) (g_object_unref) (_ptr); } while (0)
;
1797
1798 if (fish->preferences_dialog)
1799 gtk_widget_destroy (fish->preferences_dialog);
1800 fish->preferences_dialog = NULL((void*)0);
1801
1802 if (fish->fortune_dialog)
1803 gtk_widget_destroy (fish->fortune_dialog);
1804 fish->fortune_dialog = NULL((void*)0);
1805
1806 if (fish->source_id)
1807 g_source_remove (fish->source_id);
1808 fish->source_id = 0;
1809
1810 fish_close_channel (fish);
1811
1812 G_OBJECT_CLASS (parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((parent_class)), (((GType) ((20) << (2))))))))
->dispose (object);
1813}
1814
1815static void fish_applet_instance_init(FishApplet* fish, FishAppletClass* klass)
1816{
1817 fish->name = NULL((void*)0);
1818 fish->image = NULL((void*)0);
1819 fish->command = NULL((void*)0);
1820 fish->n_frames = 1;
1821 fish->speed = 0.0;
1822 fish->rotate = FALSE(0);
1823
1824 fish->orientation = MATE_PANEL_APPLET_ORIENT_UP;
1825
1826 fish->frame = NULL((void*)0);
1827 fish->drawing_area = NULL((void*)0);
1828 fish->surface = NULL((void*)0);
1829 fish->timeout = 0;
1830 fish->current_frame = 0;
1831 fish->in_applet = FALSE(0);
1832
1833 fish->requisition.width = -1;
1834 fish->requisition.height = -1;
1835
1836 fish->prev_allocation.x = -1;
1837 fish->prev_allocation.y = -1;
1838 fish->prev_allocation.width = -1;
1839 fish->prev_allocation.height = -1;
1840
1841 fish->pixbuf = NULL((void*)0);
1842
1843 fish->preferences_dialog = NULL((void*)0);
1844 fish->name_entry = NULL((void*)0);
1845 fish->command_label = NULL((void*)0);
1846 fish->command_entry = NULL((void*)0);
1847 fish->preview_image = NULL((void*)0);
1848 fish->image_chooser = NULL((void*)0);
1849 fish->frames_spin = NULL((void*)0);
1850 fish->speed_spin = NULL((void*)0);
1851 fish->rotate_toggle = NULL((void*)0);
1852
1853 fish->fortune_dialog = NULL((void*)0);
1854 fish->fortune_view = NULL((void*)0);
1855 fish->fortune_label = NULL((void*)0);
1856 fish->fortune_cmd_label = NULL((void*)0);
1857 fish->fortune_buffer = NULL((void*)0);
1858
1859 fish->source_id = 0;
1860 fish->io_channel = NULL((void*)0);
1861
1862 fish->april_fools = FALSE(0);
1863
1864 mate_panel_applet_set_flags (MATE_PANEL_APPLET (fish), MATE_PANEL_APPLET_EXPAND_MINOR);
1865}
1866
1867static void fish_applet_class_init(FishAppletClass* klass)
1868{
1869 MatePanelAppletClass* applet_class = (MatePanelAppletClass*) klass;
1870 GObjectClass *gobject_class = (GObjectClass *) klass;
1871
1872 parent_class = g_type_class_peek_parent(klass);
1873
1874 applet_class->change_orient = fish_applet_change_orient;
1875
1876 gobject_class->dispose = fish_applet_dispose;
1877
1878 init_fools_day();
1879}
1880
1881static GType fish_applet_get_type(void)
1882{
1883 static GType type = 0;
1884
1885 if (!type)
1886 {
1887 static const GTypeInfo info = {
1888 sizeof(MatePanelAppletClass),
1889 NULL((void*)0), NULL((void*)0),
1890 (GClassInitFunc) fish_applet_class_init,
1891 NULL((void*)0), NULL((void*)0),
1892 sizeof(FishApplet),
1893 0,
1894 (GInstanceInitFunc) fish_applet_instance_init,
1895 NULL((void*)0)
1896 };
1897
1898 type = g_type_register_static(PANEL_TYPE_APPLETmate_panel_applet_get_type (), "FishApplet", &info, 0);
1899 }
1900
1901 return type;
1902}
1903
1904#ifdef FISH_INPROCESS1
1905 MATE_PANEL_APPLET_IN_PROCESS_FACTORY("FishAppletFactory", fish_applet_get_type(), "That-stupid-fish", fishy_factory, NULL)gboolean _mate_panel_applet_shlib_factory (void); __attribute__
((visibility("default"))) gint _mate_panel_applet_shlib_factory
(void) { do { bindtextdomain ("mate-panel", "/usr/local/share/locale"
); bind_textdomain_codeset ("mate-panel", "UTF-8"); if ((0)) textdomain
("mate-panel"); } while (0); return mate_panel_applet_factory_setup_in_process
("FishAppletFactory", fish_applet_get_type(), fishy_factory,
((void*)0)); }
1906#else
1907 MATE_PANEL_APPLET_OUT_PROCESS_FACTORY("FishAppletFactory", fish_applet_get_type(), "That-stupid-fish", fishy_factory, NULL)int main(int argc, char *argv[]) { GOptionContext *context; GError
*error; int retval; do { bindtextdomain ("mate-panel", "/usr/local/share/locale"
); bind_textdomain_codeset ("mate-panel", "UTF-8"); if ((!(0)
)) textdomain ("mate-panel"); } 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 ("FishAppletFactory"
,(!(0)), fish_applet_get_type(), fishy_factory, ((void*)0)); g_option_context_free
(context); return retval; }
1908#endif
diff --git a/2024-06-18-172109-13286-1@e182420b844f_master/report-d08495.html b/2024-06-18-172109-13286-1@e182420b844f_master/report-d08495.html new file mode 100644 index 00000000..b1fbca79 --- /dev/null +++ b/2024-06-18-172109-13286-1@e182420b844f_master/report-d08495.html @@ -0,0 +1,3246 @@ + + + +mate-panel-applet.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:libmate-panel-applet/mate-panel-applet.c
Warning:line 329, column 37
Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name mate-panel-applet.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/libmate-panel-applet -fcoverage-compilation-dir=/rootdir/libmate-panel-applet -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I .. -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/gio-unix-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I ../libmate-panel-applet -D MATELOCALEDIR="/usr/local/share/locale" -D PIC -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-18-172109-13286-1 -x c mate-panel-applet.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * mate-panel-applet.c: panel applet writing library.
3 *
4 * Copyright (c) 2010 Carlos Garcia Campos <carlosgc@gnome.org>
5 * Copyright (C) 2001 Sun Microsystems, Inc.
6 * Copyright (C) 2012-2021 MATE Developers
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
17 *
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the
20 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22 *
23 * Authors:
24 * Mark McLoughlin <mark@skynet.ie>
25 */
26
27#ifdef HAVE_CONFIG_H1
28#include <config.h>
29#endif
30
31#include <unistd.h>
32#include <stdlib.h>
33#include <string.h>
34
35#include <glib/gi18n-lib.h>
36#include <cairo.h>
37#include <gdk/gdk.h>
38#include <gdk/gdkkeysyms.h>
39#include <gtk/gtk.h>
40
41#ifdef HAVE_X111
42#include <cairo-xlib.h>
43#include <gdk/gdkx.h>
44#include <gtk/gtkx.h>
45#include <X11/Xatom.h>
46#include "panel-plug-private.h"
47#endif
48
49#include "mate-panel-applet.h"
50#include "panel-applet-private.h"
51#include "mate-panel-applet-factory.h"
52#include "mate-panel-applet-marshal.h"
53#include "mate-panel-applet-enums.h"
54
55typedef struct {
56 GtkWidget *plug;
57 GDBusConnection *connection;
58
59 gboolean out_of_process;
60
61 char *id;
62 GClosure *closure;
63 char *object_path;
64 guint object_id;
65 char *prefs_path;
66
67 GtkUIManager *ui_manager;
68 GtkActionGroup *applet_action_group;
69 GtkActionGroup *panel_action_group;
70
71 MatePanelAppletFlags flags;
72 MatePanelAppletOrient orient;
73 guint size;
74 char *background;
75
76 int previous_width;
77 int previous_height;
78
79 int *size_hints;
80 int size_hints_len;
81
82 gboolean moving_focus_out;
83
84 gboolean locked;
85 gboolean locked_down;
86} MatePanelAppletPrivate;
87
88enum {
89 CHANGE_ORIENT,
90 CHANGE_SIZE,
91 CHANGE_BACKGROUND,
92 MOVE_FOCUS_OUT_OF_APPLET,
93 LAST_SIGNAL
94};
95
96static guint mate_panel_applet_signals[LAST_SIGNAL] = { 0 };
97
98enum {
99 PROP_0,
100 PROP_OUT_OF_PROCESS,
101 PROP_ID,
102 PROP_CLOSURE,
103 PROP_CONNECTION,
104 PROP_PREFS_PATH,
105 PROP_ORIENT,
106 PROP_SIZE,
107 PROP_BACKGROUND,
108 PROP_FLAGS,
109 PROP_SIZE_HINTS,
110 PROP_LOCKED,
111 PROP_LOCKED_DOWN
112};
113
114static void mate_panel_applet_handle_background (MatePanelApplet *applet);
115static GtkAction *mate_panel_applet_menu_get_action (MatePanelApplet *applet,
116 const gchar *action);
117static void mate_panel_applet_menu_update_actions (MatePanelApplet *applet);
118static void mate_panel_applet_menu_cmd_remove (GtkAction *action,
119 MatePanelApplet *applet);
120static void mate_panel_applet_menu_cmd_move (GtkAction *action,
121 MatePanelApplet *applet);
122static void mate_panel_applet_menu_cmd_lock (GtkAction *action,
123 MatePanelApplet *applet);
124static void mate_panel_applet_register_object (MatePanelApplet *applet);
125void _mate_panel_applet_apply_css (GtkWidget* widget, MatePanelAppletBackgroundType type);
126
127static const gchar panel_menu_ui[] =
128 "<ui>\n"
129 " <popup name=\"MatePanelAppletPopup\" action=\"PopupAction\">\n"
130 " <placeholder name=\"AppletItems\"/>\n"
131 " <separator/>\n"
132 " <menuitem name=\"RemoveItem\" action=\"Remove\"/>\n"
133 " <menuitem name=\"MoveItem\" action=\"Move\"/>\n"
134 " <separator/>\n"
135 " <menuitem name=\"LockItem\" action=\"Lock\"/>\n"
136 " </popup>\n"
137 "</ui>\n";
138
139static const GtkActionEntry menu_entries[] = {
140 { "Remove", "list-remove", N_("_Remove From Panel")("_Remove From Panel"),
141 NULL((void*)0), NULL((void*)0),
142 G_CALLBACK (mate_panel_applet_menu_cmd_remove)((GCallback) (mate_panel_applet_menu_cmd_remove)) },
143 { "Move", NULL((void*)0), N_("_Move")("_Move"),
144 NULL((void*)0), NULL((void*)0),
145 G_CALLBACK (mate_panel_applet_menu_cmd_move)((GCallback) (mate_panel_applet_menu_cmd_move)) }
146};
147
148static const GtkToggleActionEntry menu_toggle_entries[] = {
149 { "Lock", NULL((void*)0), N_("Loc_k To Panel")("Loc_k To Panel"),
150 NULL((void*)0), NULL((void*)0),
151 G_CALLBACK (mate_panel_applet_menu_cmd_lock)((GCallback) (mate_panel_applet_menu_cmd_lock)),
152 FALSE(0) }
153};
154
155G_DEFINE_TYPE_WITH_PRIVATE (MatePanelApplet, mate_panel_applet, GTK_TYPE_EVENT_BOX)static void mate_panel_applet_init (MatePanelApplet *self); static
void mate_panel_applet_class_init (MatePanelAppletClass *klass
); static GType mate_panel_applet_get_type_once (void); static
gpointer mate_panel_applet_parent_class = ((void*)0); static
gint MatePanelApplet_private_offset; static void mate_panel_applet_class_intern_init
(gpointer klass) { mate_panel_applet_parent_class = g_type_class_peek_parent
(klass); if (MatePanelApplet_private_offset != 0) g_type_class_adjust_private_offset
(klass, &MatePanelApplet_private_offset); mate_panel_applet_class_init
((MatePanelAppletClass*) klass); } __attribute__ ((__unused__
)) static inline gpointer mate_panel_applet_get_instance_private
(MatePanelApplet *self) { return (((gpointer) ((guint8*) (self
) + (glong) (MatePanelApplet_private_offset)))); } GType mate_panel_applet_get_type
(void) { static GType static_g_define_type_id = 0; if ((__extension__
({ _Static_assert (sizeof *(&static_g_define_type_id) ==
sizeof (gpointer), "Expression evaluates to false"); (void) (
0 ? (gpointer) * (&static_g_define_type_id) : ((void*)0))
; (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter_pointer (
&static_g_define_type_id)); })) ) { GType g_define_type_id
= mate_panel_applet_get_type_once (); (__extension__ ({ _Static_assert
(sizeof *(&static_g_define_type_id) == sizeof (gpointer)
, "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id
) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer
((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id
)); })) ; } return static_g_define_type_id; } __attribute__ (
(__noinline__)) static GType mate_panel_applet_get_type_once (
void) { GType g_define_type_id = g_type_register_static_simple
((gtk_event_box_get_type ()), g_intern_static_string ("MatePanelApplet"
), sizeof (MatePanelAppletClass), (GClassInitFunc)(void (*)(void
)) mate_panel_applet_class_intern_init, sizeof (MatePanelApplet
), (GInstanceInitFunc)(void (*)(void)) mate_panel_applet_init
, (GTypeFlags) 0); { {{ MatePanelApplet_private_offset = g_type_add_instance_private
(g_define_type_id, sizeof (MatePanelAppletPrivate)); };} } return
g_define_type_id; }
156
157#define MATE_PANEL_APPLET_INTERFACE"org.mate.panel.applet.Applet" "org.mate.panel.applet.Applet"
158#define MATE_PANEL_APPLET_OBJECT_PATH"/org/mate/panel/applet/%s/%d" "/org/mate/panel/applet/%s/%d"
159
160char *
161mate_panel_applet_get_preferences_path (MatePanelApplet *applet)
162{
163 MatePanelAppletPrivate *priv;
164
165 g_return_val_if_fail (MATE_PANEL_IS_APPLET (applet), NULL)do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return (((void*)0)); } } while (0)
;
166
167 priv = mate_panel_applet_get_instance_private (applet);
168 if (!priv->prefs_path)
169 return NULL((void*)0);
170
171 return g_strdup (priv->prefs_path)g_strdup_inline (priv->prefs_path);
172}
173
174static void
175mate_panel_applet_set_preferences_path (MatePanelApplet *applet,
176 const char *prefs_path)
177{
178 MatePanelAppletPrivate *priv;
179
180 priv = mate_panel_applet_get_instance_private (applet);
181
182 if (priv->prefs_path == prefs_path)
183 return;
184
185 if (g_strcmp0 (priv->prefs_path, prefs_path) == 0)
186 return;
187
188 if (prefs_path)
189 priv->prefs_path = g_strdup (prefs_path)g_strdup_inline (prefs_path);
190
191 g_object_notify (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
, "prefs-path");
192}
193
194MatePanelAppletFlags
195mate_panel_applet_get_flags (MatePanelApplet *applet)
196{
197 MatePanelAppletPrivate *priv;
198
199 g_return_val_if_fail (MATE_PANEL_IS_APPLET (applet), MATE_PANEL_APPLET_FLAGS_NONE)do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return (MATE_PANEL_APPLET_FLAGS_NONE); } } while (0)
;
200
201 priv = mate_panel_applet_get_instance_private (applet);
202
203 return priv->flags;
204}
205
206void
207mate_panel_applet_set_flags (MatePanelApplet *applet,
208 MatePanelAppletFlags flags)
209{
210 MatePanelAppletPrivate *priv;
211
212 g_return_if_fail (MATE_PANEL_IS_APPLET (applet))do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return; } } while (0)
;
213
214 priv = mate_panel_applet_get_instance_private (applet);
215
216 if (priv->flags == flags)
217 return;
218
219 priv->flags = flags;
220
221 g_object_notify (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
, "flags");
222
223 if (priv->connection) {
224 GVariantBuilder builder;
225 GVariantBuilder invalidated_builder;
226 GError *error = NULL((void*)0);
227
228 g_variant_builder_init (&builder, G_VARIANT_TYPE_ARRAY((const GVariantType *) "a*"));
229 g_variant_builder_init (&invalidated_builder, G_VARIANT_TYPE ("as")(g_variant_type_checked_ (("as"))));
230
231 g_variant_builder_add (&builder, "{sv}", "Flags",
232 g_variant_new_uint32 (priv->flags));
233
234 g_dbus_connection_emit_signal (priv->connection,
235 NULL((void*)0),
236 priv->object_path,
237 "org.freedesktop.DBus.Properties",
238 "PropertiesChanged",
239 g_variant_new ("(sa{sv}as)",
240 MATE_PANEL_APPLET_INTERFACE"org.mate.panel.applet.Applet",
241 &builder,
242 &invalidated_builder),
243 &error);
244 if (error) {
245 g_printerr ("Failed to send signal PropertiesChanged::Flags: %s\n",
246 error->message);
247 g_error_free (error);
248 }
249 g_variant_builder_clear (&builder);
250 g_variant_builder_clear (&invalidated_builder);
251 }
252}
253
254static void
255mate_panel_applet_size_hints_ensure (MatePanelApplet *applet,
256 int new_size)
257{
258 MatePanelAppletPrivate *priv;
259
260 priv = mate_panel_applet_get_instance_private (applet);
261 if (priv->size_hints && priv->size_hints_len < new_size) {
262 g_free (priv->size_hints);
263 priv->size_hints = g_new (gint, new_size)((gint *) g_malloc_n ((new_size), sizeof (gint)));
264 } else if (!priv->size_hints) {
265 priv->size_hints = g_new (gint, new_size)((gint *) g_malloc_n ((new_size), sizeof (gint)));
266 }
267 priv->size_hints_len = new_size;
268}
269
270static gboolean
271mate_panel_applet_size_hints_changed (MatePanelApplet *applet,
272 const int *size_hints,
273 int n_elements,
274 int base_size)
275{
276 MatePanelAppletPrivate *priv;
277 gint i;
278
279 priv = mate_panel_applet_get_instance_private (applet);
280
281 if (!priv->size_hints)
282 return TRUE(!(0));
283
284 if (priv->size_hints_len != n_elements)
285 return TRUE(!(0));
286
287 for (i = 0; i < n_elements; i++) {
288 if (size_hints[i] + base_size != priv->size_hints[i])
289 return TRUE(!(0));
290 }
291
292 return FALSE(0);
293}
294
295/**
296 * mate_panel_applet_set_size_hints:
297 * @applet: applet
298 * @size_hints: (array length=n_elements): List of integers
299 * @n_elements: Length of @size_hints
300 * @base_size: base_size
301 */
302void
303mate_panel_applet_set_size_hints (MatePanelApplet *applet,
304 const int *size_hints,
305 int n_elements,
306 int base_size)
307{
308 MatePanelAppletPrivate *priv;
309 gint i;
310
311 /* Make sure property has really changed to avoid bus traffic */
312 if (!mate_panel_applet_size_hints_changed (applet, size_hints, n_elements, base_size))
313 return;
314
315 priv = mate_panel_applet_get_instance_private (applet);
316
317 mate_panel_applet_size_hints_ensure (applet, n_elements);
318 for (i = 0; i < n_elements; i++)
319 priv->size_hints[i] = size_hints[i] + base_size;
320
321 g_object_notify (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
, "size-hints");
322
323 if (priv->connection) {
324 GVariantBuilder builder;
325 GVariantBuilder invalidated_builder;
326 GVariant **children;
327 GError *error = NULL((void*)0);
328
329 g_variant_builder_init (&builder, G_VARIANT_TYPE_ARRAY((const GVariantType *) "a*"));
Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption
330 g_variant_builder_init (&invalidated_builder, G_VARIANT_TYPE ("as")(g_variant_type_checked_ (("as"))));
331
332 children = g_new (GVariant *, priv->size_hints_len)((GVariant * *) g_malloc_n ((priv->size_hints_len), sizeof
(GVariant *)))
;
333 for (i = 0; i < n_elements; i++)
334 children[i] = g_variant_new_int32 (priv->size_hints[i]);
335 g_variant_builder_add (&builder, "{sv}", "SizeHints",
336 g_variant_new_array (G_VARIANT_TYPE_INT32((const GVariantType *) "i"),
337 children, priv->size_hints_len));
338 g_free (children);
339
340 g_dbus_connection_emit_signal (priv->connection,
341 NULL((void*)0),
342 priv->object_path,
343 "org.freedesktop.DBus.Properties",
344 "PropertiesChanged",
345 g_variant_new ("(sa{sv}as)",
346 MATE_PANEL_APPLET_INTERFACE"org.mate.panel.applet.Applet",
347 &builder,
348 &invalidated_builder),
349 &error);
350 if (error) {
351 g_printerr ("Failed to send signal PropertiesChanged::SizeHints: %s\n",
352 error->message);
353 g_error_free (error);
354 }
355 g_variant_builder_clear (&builder);
356 g_variant_builder_clear (&invalidated_builder);
357 }
358}
359
360guint
361mate_panel_applet_get_size (MatePanelApplet *applet)
362{
363 MatePanelAppletPrivate *priv;
364
365 g_return_val_if_fail (MATE_PANEL_IS_APPLET (applet), 0)do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return (0); } } while (0)
;
366
367 priv = mate_panel_applet_get_instance_private (applet);
368
369 return priv->size;
370}
371
372/* Applets cannot set their size, so API is not public. */
373static void
374mate_panel_applet_set_size (MatePanelApplet *applet,
375 guint size)
376{
377 MatePanelAppletPrivate *priv;
378
379 g_return_if_fail (MATE_PANEL_IS_APPLET (applet))do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return; } } while (0)
;
380
381 priv = mate_panel_applet_get_instance_private (applet);
382
383 if (priv->size == size)
384 return;
385
386 priv->size = size;
387 g_signal_emit (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
,
388 mate_panel_applet_signals [CHANGE_SIZE],
389 0, size);
390
391 g_object_notify (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
, "size");
392}
393
394MatePanelAppletOrient
395mate_panel_applet_get_orient (MatePanelApplet *applet)
396{
397 MatePanelAppletPrivate *priv;
398
399 g_return_val_if_fail (MATE_PANEL_IS_APPLET (applet), 0)do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return (0); } } while (0)
;
400
401 priv = mate_panel_applet_get_instance_private (applet);
402
403 return priv->orient;
404}
405
406/* Applets cannot set their orientation, so API is not public. */
407static void
408mate_panel_applet_set_orient (MatePanelApplet *applet,
409 MatePanelAppletOrient orient)
410{
411 MatePanelAppletPrivate *priv;
412
413 g_return_if_fail (MATE_PANEL_IS_APPLET (applet))do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return; } } while (0)
;
414
415 priv = mate_panel_applet_get_instance_private (applet);
416
417 if (priv->orient == orient)
418 return;
419
420 priv->orient = orient;
421 g_signal_emit (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
,
422 mate_panel_applet_signals [CHANGE_ORIENT],
423 0, orient);
424
425 g_object_notify (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
, "orient");
426}
427
428static void
429mate_panel_applet_set_locked (MatePanelApplet *applet,
430 gboolean locked)
431{
432 MatePanelAppletPrivate *priv;
433 GtkAction *action;
434
435 g_return_if_fail (MATE_PANEL_IS_APPLET (applet))do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return; } } while (0)
;
436
437 priv = mate_panel_applet_get_instance_private (applet);
438
439 if (priv->locked == locked)
440 return;
441
442 priv->locked = locked;
443
444 action = mate_panel_applet_menu_get_action (applet, "Lock");
445 g_signal_handlers_block_by_func (action,g_signal_handlers_block_matched ((action), (GSignalMatchType)
(G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0
), (mate_panel_applet_menu_cmd_lock), (applet))
446 mate_panel_applet_menu_cmd_lock,g_signal_handlers_block_matched ((action), (GSignalMatchType)
(G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0
), (mate_panel_applet_menu_cmd_lock), (applet))
447 applet)g_signal_handlers_block_matched ((action), (GSignalMatchType)
(G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0
), (mate_panel_applet_menu_cmd_lock), (applet))
;
448 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action)((((GtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((gtk_toggle_action_get_type ()))))))
, locked);
449 g_signal_handlers_unblock_by_func (action,g_signal_handlers_unblock_matched ((action), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (mate_panel_applet_menu_cmd_lock), (applet))
450 mate_panel_applet_menu_cmd_lock,g_signal_handlers_unblock_matched ((action), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (mate_panel_applet_menu_cmd_lock), (applet))
451 applet)g_signal_handlers_unblock_matched ((action), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (mate_panel_applet_menu_cmd_lock), (applet))
;
452
453 mate_panel_applet_menu_update_actions (applet);
454
455 g_object_notify (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
, "locked");
456
457 if (priv->connection) {
458 GError *error = NULL((void*)0);
459
460 g_dbus_connection_emit_signal (priv->connection,
461 NULL((void*)0),
462 priv->object_path,
463 MATE_PANEL_APPLET_INTERFACE"org.mate.panel.applet.Applet",
464 locked ? "Lock" : "Unlock",
465 NULL((void*)0), &error);
466 if (error) {
467 g_printerr ("Failed to send signal %s: %s\n",
468 locked ? "Lock" : "Unlock",
469 error->message);
470 g_error_free (error);
471 }
472 }
473}
474
475gboolean
476mate_panel_applet_get_locked_down (MatePanelApplet *applet)
477{
478 MatePanelAppletPrivate *priv;
479
480 g_return_val_if_fail (MATE_PANEL_IS_APPLET (applet), FALSE)do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return ((0)); } } while (0)
;
481
482 priv = mate_panel_applet_get_instance_private (applet);
483
484 return priv->locked_down;
485}
486
487/* Applets cannot set the lockdown state, so API is not public. */
488static void
489mate_panel_applet_set_locked_down (MatePanelApplet *applet,
490 gboolean locked_down)
491{
492 MatePanelAppletPrivate *priv;
493
494 g_return_if_fail (MATE_PANEL_IS_APPLET (applet))do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return; } } while (0)
;
495
496 priv = mate_panel_applet_get_instance_private (applet);
497
498 if (priv->locked_down == locked_down)
499 return;
500
501 priv->locked_down = locked_down;
502 mate_panel_applet_menu_update_actions (applet);
503
504 g_object_notify (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
, "locked-down");
505}
506
507#ifdef HAVE_X111
508
509static Atom _net_wm_window_type = None0L;
510static Atom _net_wm_window_type_dock = None0L;
511static Atom _net_active_window = None0L;
512
513static void
514mate_panel_applet_init_atoms (Display *xdisplay)
515{
516 if (_net_wm_window_type == None0L)
517 _net_wm_window_type = XInternAtom (xdisplay,
518 "_NET_WM_WINDOW_TYPE",
519 False0);
520
521 if (_net_wm_window_type_dock == None0L)
522 _net_wm_window_type_dock = XInternAtom (xdisplay,
523 "_NET_WM_WINDOW_TYPE_DOCK",
524 False0);
525
526 if (_net_active_window == None0L)
527 _net_active_window = XInternAtom (xdisplay,
528 "_NET_ACTIVE_WINDOW",
529 False0);
530}
531
532static Window
533mate_panel_applet_find_toplevel_dock_window (MatePanelApplet *applet,
534 Display *xdisplay)
535{
536 GtkWidget *toplevel;
537 Window xwin;
538 Window root, parent, *child;
539 int num_children;
540
541 toplevel = gtk_widget_get_toplevel (GTK_WIDGET (applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
);
542 if (!gtk_widget_get_realized (toplevel))
543 return None0L;
544
545 xwin = GDK_WINDOW_XID (gtk_widget_get_window (toplevel))(gdk_x11_window_get_xid (gtk_widget_get_window (toplevel)));
546
547 child = NULL((void*)0);
548 parent = root = None0L;
549 do {
550 Atom type_return;
551 Atom window_type;
552 int format_return;
553 gulong number_return, bytes_after_return;
554 guchar *data_return;
555
556 XGetWindowProperty (xdisplay,
557 xwin,
558 _net_wm_window_type,
559 0, 1, False0,
560 XA_ATOM((Atom) 4),
561 &type_return, &format_return,
562 &number_return,
563 &bytes_after_return,
564 &data_return);
565
566 if (type_return == XA_ATOM((Atom) 4)) {
567 window_type = *(Atom *) data_return;
568
569 XFree (data_return);
570 data_return = NULL((void*)0);
571
572 if (window_type == _net_wm_window_type_dock)
573 return xwin;
574 }
575
576 if (!XQueryTree (xdisplay,
577 xwin,
578 &root, &parent, &child,
579 (guint *) &num_children)) {
580 return None0L;
581 }
582
583 if (child && num_children > 0)
584 XFree (child);
585
586 xwin = parent;
587
588 } while (xwin != None0L && xwin != root);
589
590 return None0L;
591}
592
593#endif /* HAVE_X11 */
594
595/* This function
596 * 1) Gets the window id of the panel that contains the applet
597 * using XQueryTree and XGetWindowProperty to find an ancestor
598 * window with the _NET_WM_WINDOW_TYPE_DOCK window type.
599 * 2) Sends a _NET_ACTIVE_WINDOW message to get that panel focused
600 */
601void
602mate_panel_applet_request_focus (MatePanelApplet *applet,
603 guint32 timestamp)
604{
605#ifdef HAVE_X111
606 GdkScreen *screen;
607 GdkWindow *root;
608 GdkDisplay *display;
609 Display *xdisplay;
610 Window dock_xwindow;
611 Window xroot;
612 XEvent xev;
613
614 if (!GDK_IS_X11_DISPLAY (gdk_display_get_default ())(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gdk_display_get_default ())); GType __t = ((gdk_x11_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
)
615 return;
616
617 g_return_if_fail (MATE_PANEL_IS_APPLET (applet))do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return; } } while (0)
;
618
619 screen = gdk_screen_get_default(); /*There is only one screen since GTK 3.22*/
620 root = gdk_screen_get_root_window (screen);
621 display = gdk_screen_get_display (screen);
622
623 xdisplay = GDK_DISPLAY_XDISPLAY (display)(gdk_x11_display_get_xdisplay (display));
624 xroot = GDK_WINDOW_XID (root)(gdk_x11_window_get_xid (root));
625
626 mate_panel_applet_init_atoms (xdisplay);
627
628 dock_xwindow = mate_panel_applet_find_toplevel_dock_window (applet, xdisplay);
629 if (dock_xwindow == None0L)
630 return;
631
632 xev.xclient.type = ClientMessage33;
633 xev.xclient.serial = 0;
634 xev.xclient.send_event = True1;
635 xev.xclient.window = dock_xwindow;
636 xev.xclient.message_type = _net_active_window;
637 xev.xclient.format = 32;
638 xev.xclient.data.l[0] = 1; /* requestor type; we're an app, I guess */
639 xev.xclient.data.l[1] = timestamp;
640 xev.xclient.data.l[2] = None0L; /* "currently active window", supposedly */
641 xev.xclient.data.l[3] = 0;
642 xev.xclient.data.l[4] = 0;
643
644 XSendEvent (xdisplay,
645 xroot, False0,
646 SubstructureRedirectMask(1L<<20) | SubstructureNotifyMask(1L<<19),
647 &xev);
648#endif
649}
650
651static GtkAction *
652mate_panel_applet_menu_get_action (MatePanelApplet *applet,
653 const gchar *action)
654{
655 MatePanelAppletPrivate *priv;
656
657 priv = mate_panel_applet_get_instance_private (applet);
658
659 return gtk_action_group_get_action (priv->panel_action_group, action);
660}
661
662static void
663mate_panel_applet_menu_update_actions (MatePanelApplet *applet)
664{
665 MatePanelAppletPrivate *priv;
666
667 priv = mate_panel_applet_get_instance_private (applet);
668 g_object_set (mate_panel_applet_menu_get_action (applet, "Lock"),
669 "visible", !priv->locked_down,
670 NULL((void*)0));
671 g_object_set (mate_panel_applet_menu_get_action (applet, "Move"),
672 "sensitive", !priv->locked,
673 "visible", !priv->locked_down,
674 NULL((void*)0));
675 g_object_set (mate_panel_applet_menu_get_action (applet, "Remove"),
676 "sensitive", !priv->locked,
677 "visible", !priv->locked_down,
678 NULL((void*)0));
679}
680
681static void
682mate_panel_applet_menu_cmd_remove (GtkAction *action,
683 MatePanelApplet *applet)
684{
685 MatePanelAppletPrivate *priv;
686 GError *error = NULL((void*)0);
687
688 priv = mate_panel_applet_get_instance_private (applet);
689
690 if (!priv->connection)
691 return;
692
693 g_dbus_connection_emit_signal (priv->connection,
694 NULL((void*)0),
695 priv->object_path,
696 MATE_PANEL_APPLET_INTERFACE"org.mate.panel.applet.Applet",
697 "RemoveFromPanel",
698 NULL((void*)0), &error);
699 if (error) {
700 g_printerr ("Failed to send signal RemoveFromPanel: %s\n",
701 error->message);
702 g_error_free (error);
703 }
704}
705
706static void
707mate_panel_applet_menu_cmd_move (GtkAction *action,
708 MatePanelApplet *applet)
709{
710 MatePanelAppletPrivate *priv;
711 GError *error = NULL((void*)0);
712
713 priv = mate_panel_applet_get_instance_private (applet);
714
715 if (!priv->connection)
716 return;
717
718 g_dbus_connection_emit_signal (priv->connection,
719 NULL((void*)0),
720 priv->object_path,
721 MATE_PANEL_APPLET_INTERFACE"org.mate.panel.applet.Applet",
722 "Move",
723 NULL((void*)0), &error);
724 if (error) {
725 g_printerr ("Failed to send signal RemoveFromPanel: %s\n",
726 error->message);
727 g_error_free (error);
728 }
729}
730
731static void
732mate_panel_applet_menu_cmd_lock (GtkAction *action,
733 MatePanelApplet *applet)
734{
735 gboolean locked;
736
737 locked = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)((((GtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((gtk_toggle_action_get_type ()))))))
);
738 mate_panel_applet_set_locked (applet, locked);
739}
740
741void
742mate_panel_applet_setup_menu (MatePanelApplet *applet,
743 const gchar *xml,
744 GtkActionGroup *applet_action_group)
745{
746 MatePanelAppletPrivate *priv;
747 gchar *new_xml;
748 GError *error = NULL((void*)0);
749
750 g_return_if_fail (MATE_PANEL_IS_APPLET (applet))do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return; } } while (0)
;
751 g_return_if_fail (xml != NULL)do { if ((xml != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "xml != NULL"); return
; } } while (0)
;
752
753 priv = mate_panel_applet_get_instance_private (applet);
754
755 if (priv->applet_action_group)
756 return;
757
758 priv->applet_action_group = g_object_ref (applet_action_group)((__typeof__ (applet_action_group)) (g_object_ref) (applet_action_group
))
;
759 gtk_ui_manager_insert_action_group (priv->ui_manager,
760 applet_action_group, 0);
761
762 new_xml = g_strdup_printf ("<ui><popup name=\"MatePanelAppletPopup\" action=\"AppletItems\">"
763 "<placeholder name=\"AppletItems\">%s\n</placeholder>\n"
764 "</popup></ui>\n", xml);
765 gtk_ui_manager_add_ui_from_string (priv->ui_manager, new_xml, -1, &error);
766 g_free (new_xml);
767 gtk_ui_manager_ensure_update (priv->ui_manager);
768 if (error) {
769 g_warning ("Error merging menus: %s\n", error->message);
770 g_error_free (error);
771 }
772}
773
774void
775mate_panel_applet_setup_menu_from_file (MatePanelApplet *applet,
776 const gchar *filename,
777 GtkActionGroup *applet_action_group)
778{
779 gchar *xml = NULL((void*)0);
780 GError *error = NULL((void*)0);
781
782 if (g_file_get_contents (filename, &xml, NULL((void*)0), &error)) {
783 mate_panel_applet_setup_menu (applet, xml, applet_action_group);
784 } else {
785 g_warning ("%s", error->message);
786 g_error_free (error);
787 }
788
789 g_free (xml);
790}
791
792/**
793 * mate_panel_applet_setup_menu_from_resource:
794 * @applet: a #MatePanelApplet.
795 * @resource_path: a resource path
796 * @action_group: a #GtkActionGroup.
797 *
798 * Sets up the context menu of @applet. @filename is a resource path to a menu
799 * XML file, containing a #GtkUIManager UI definition that describes how to
800 * display the menu items. @action_group contains the various #GtkAction that
801 * are referenced in @xml.
802 *
803 * See also the <link linkend="getting-started.context-menu">Context
804 * Menu</link> section.
805 *
806 * Since: 1.20.1
807 **/
808void
809mate_panel_applet_setup_menu_from_resource (MatePanelApplet *applet,
810 const gchar *resource_path,
811 GtkActionGroup *action_group)
812{
813 GBytes *bytes;
814 GError *error = NULL((void*)0);
815
816 bytes = g_resources_lookup_data (resource_path,
817 G_RESOURCE_LOOKUP_FLAGS_NONE,
818 &error);
819
820 if (bytes) {
821 mate_panel_applet_setup_menu (applet,
822 g_bytes_get_data (bytes, NULL((void*)0)),
823 action_group);
824 } else {
825 g_warning ("%s", error->message);
826 g_error_free (error);
827 }
828
829 g_bytes_unref (bytes);
830}
831
832static void
833mate_panel_applet_finalize (GObject *object)
834{
835 MatePanelApplet *applet;
836 MatePanelAppletPrivate *priv;
837
838 applet = MATE_PANEL_APPLET (object);
839 priv = mate_panel_applet_get_instance_private (applet);
840
841 if (priv->connection) {
842 if (priv->object_id)
843 g_dbus_connection_unregister_object (priv->connection,
844 priv->object_id);
845 priv->object_id = 0;
846 g_clear_object (&priv->connection)do { _Static_assert (sizeof *((&priv->connection)) == sizeof
(gpointer), "Expression evaluates to false"); __typeof__ (((
&priv->connection))) _pp = ((&priv->connection)
); __typeof__ (*((&priv->connection))) _ptr = *_pp; *_pp
= ((void*)0); if (_ptr) (g_object_unref) (_ptr); } while (0)
;
847 }
848
849 g_clear_pointer (&priv->object_path, g_free)do { _Static_assert (sizeof *(&priv->object_path) == sizeof
(gpointer), "Expression evaluates to false"); __typeof__ ((&
priv->object_path)) _pp = (&priv->object_path); __typeof__
(*(&priv->object_path)) _ptr = *_pp; *_pp = ((void*)0
); if (_ptr) (g_free) (_ptr); } while (0)
;
850
851 mate_panel_applet_set_preferences_path (applet, NULL((void*)0));
852
853 g_clear_object (&priv->applet_action_group)do { _Static_assert (sizeof *((&priv->applet_action_group
)) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(((&priv->applet_action_group))) _pp = ((&priv->
applet_action_group)); __typeof__ (*((&priv->applet_action_group
))) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (g_object_unref
) (_ptr); } while (0)
;
854 g_clear_object (&priv->panel_action_group)do { _Static_assert (sizeof *((&priv->panel_action_group
)) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(((&priv->panel_action_group))) _pp = ((&priv->
panel_action_group)); __typeof__ (*((&priv->panel_action_group
))) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (g_object_unref
) (_ptr); } while (0)
;
855 g_clear_object (&priv->ui_manager)do { _Static_assert (sizeof *((&priv->ui_manager)) == sizeof
(gpointer), "Expression evaluates to false"); __typeof__ (((
&priv->ui_manager))) _pp = ((&priv->ui_manager)
); __typeof__ (*((&priv->ui_manager))) _ptr = *_pp; *_pp
= ((void*)0); if (_ptr) (g_object_unref) (_ptr); } while (0)
;
856
857 g_clear_pointer (&priv->size_hints, g_free)do { _Static_assert (sizeof *(&priv->size_hints) == sizeof
(gpointer), "Expression evaluates to false"); __typeof__ ((&
priv->size_hints)) _pp = (&priv->size_hints); __typeof__
(*(&priv->size_hints)) _ptr = *_pp; *_pp = ((void*)0)
; if (_ptr) (g_free) (_ptr); } while (0)
;
858 g_clear_pointer (&priv->prefs_path, g_free)do { _Static_assert (sizeof *(&priv->prefs_path) == sizeof
(gpointer), "Expression evaluates to false"); __typeof__ ((&
priv->prefs_path)) _pp = (&priv->prefs_path); __typeof__
(*(&priv->prefs_path)) _ptr = *_pp; *_pp = ((void*)0)
; if (_ptr) (g_free) (_ptr); } while (0)
;
859 g_clear_pointer (&priv->background, g_free)do { _Static_assert (sizeof *(&priv->background) == sizeof
(gpointer), "Expression evaluates to false"); __typeof__ ((&
priv->background)) _pp = (&priv->background); __typeof__
(*(&priv->background)) _ptr = *_pp; *_pp = ((void*)0)
; if (_ptr) (g_free) (_ptr); } while (0)
;
860 g_clear_pointer (&priv->id, g_free)do { _Static_assert (sizeof *(&priv->id) == sizeof (gpointer
), "Expression evaluates to false"); __typeof__ ((&priv->
id)) _pp = (&priv->id); __typeof__ (*(&priv->id
)) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (g_free) (_ptr);
} while (0)
;
861
862 /* closure is owned by the factory */
863 priv->closure = NULL((void*)0);
864
865 G_OBJECT_CLASS (mate_panel_applet_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((mate_panel_applet_parent_class)), (((GType) ((20) <<
(2))))))))
->finalize (object);
866}
867
868static gboolean
869container_has_focusable_child (GtkContainer *container)
870{
871 GList *list;
872 GList *t;
873 gboolean retval = FALSE(0);
874
875 list = gtk_container_get_children (container);
876
877 for (t = list; t; t = t->next) {
878 GtkWidget *child = GTK_WIDGET (t->data)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((t->data)), ((gtk_widget_get_type ()))))))
;
879 if (gtk_widget_get_can_focus (child)) {
880 retval = TRUE(!(0));
881 break;
882 } else if (GTK_IS_CONTAINER (child)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(child)); GType __t = ((gtk_container_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; }))))
) {
883 retval = container_has_focusable_child (GTK_CONTAINER (child)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((child)), ((gtk_container_get_type ()))))))
);
884 if (retval)
885 break;
886 }
887 }
888 g_list_free (list);
889 return retval;
890}
891
892static void
893mate_panel_applet_menu_popup (MatePanelApplet *applet,
894 GdkEvent *event)
895{
896 MatePanelAppletPrivate *priv;
897 GtkWidget *menu;
898
899 priv = mate_panel_applet_get_instance_private (applet);
900 menu = gtk_ui_manager_get_widget (priv->ui_manager,
901 "/MatePanelAppletPopup");
902
903/* Set up theme and transparency support */
904 GtkWidget *toplevel = gtk_widget_get_toplevel (menu);
905/* Fix any failures of compiz/other wm's to communicate with gtk for transparency */
906 GdkScreen *screen = gtk_widget_get_screen(GTK_WIDGET(toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
907 GdkVisual *visual = gdk_screen_get_rgba_visual(screen);
908 gtk_widget_set_visual(GTK_WIDGET(toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
, visual);
909/* Set menu and it's toplevel window to follow panel theme */
910 GtkStyleContext *context;
911 context = gtk_widget_get_style_context (GTK_WIDGET(toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
912 gtk_style_context_add_class(context,"gnome-panel-menu-bar");
913 gtk_style_context_add_class(context,"mate-panel-menu-bar");
914 GdkGravity widget_anchor = GDK_GRAVITY_NORTH_WEST;
915 GdkGravity menu_anchor = GDK_GRAVITY_NORTH_WEST;
916 switch (priv->orient) {
917 case MATE_PANEL_APPLET_ORIENT_UP:
918 menu_anchor = GDK_GRAVITY_SOUTH_WEST;
919 break;
920 case MATE_PANEL_APPLET_ORIENT_DOWN:
921 widget_anchor = GDK_GRAVITY_SOUTH_WEST;
922 break;
923 case MATE_PANEL_APPLET_ORIENT_LEFT:
924 menu_anchor = GDK_GRAVITY_NORTH_EAST;
925 break;
926 case MATE_PANEL_APPLET_ORIENT_RIGHT:
927 widget_anchor = GDK_GRAVITY_NORTH_EAST;
928 break;
929 }
930 gtk_menu_popup_at_widget (GTK_MENU (menu)((((GtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((menu)), ((gtk_menu_get_type ()))))))
,
931 GTK_WIDGET (applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
,
932 widget_anchor,
933 menu_anchor,
934 event);
935}
936
937static gboolean
938mate_panel_applet_can_focus (GtkWidget *widget)
939{
940 /*
941 * A MatePanelApplet widget can focus if it has a tooltip or it does
942 * not have any focusable children.
943 */
944 if (gtk_widget_get_has_tooltip (widget))
945 return TRUE(!(0));
946
947 if (!MATE_PANEL_IS_APPLET (widget))
948 return FALSE(0);
949
950 return !container_has_focusable_child (GTK_CONTAINER (widget)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_container_get_type ()))))))
);
951}
952
953/* Taken from libmatecomponentui/matecomponent/matecomponent-plug.c */
954static gboolean
955mate_panel_applet_button_event (MatePanelApplet *applet,
956 GdkEventButton *event)
957{
958#ifdef HAVE_X111
959 MatePanelAppletPrivate *priv;
960 GtkWidget *widget;
961 GdkWindow *window;
962 GdkWindow *socket_window;
963 XEvent xevent;
964 GdkDisplay *display;
965
966 priv = mate_panel_applet_get_instance_private (applet);
967
968 if (!priv->out_of_process)
969 return FALSE(0);
970
971 widget = priv->plug;
972
973 if (!gtk_widget_is_toplevel (widget))
974 return FALSE(0);
975
976 window = gtk_widget_get_window (widget);
977 socket_window = gtk_plug_get_socket_window (GTK_PLUG (widget)((((GtkPlug*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_plug_get_type ()))))))
);
978
979 display = gdk_display_get_default ();
980
981 if (!GDK_IS_X11_DISPLAY (display)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(display)); GType __t = ((gdk_x11_display_get_type())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
)
982 return FALSE(0);
983
984 if (event->type == GDK_BUTTON_PRESS) {
985 GdkSeat *seat;
986
987 xevent.xbutton.type = ButtonPress4;
988
989 seat = gdk_display_get_default_seat (display);
990
991 /* X does an automatic pointer grab on button press
992 * if we have both button press and release events
993 * selected.
994 * We don't want to hog the pointer on our parent.
995 */
996 gdk_seat_ungrab (seat);
997 } else {
998 xevent.xbutton.type = ButtonRelease5;
999 }
1000
1001 xevent.xbutton.display = GDK_WINDOW_XDISPLAY (window)((gdk_x11_display_get_xdisplay (gdk_window_get_display (window
))))
;
1002 xevent.xbutton.window = GDK_WINDOW_XID (socket_window)(gdk_x11_window_get_xid (socket_window));
1003 xevent.xbutton.root = GDK_WINDOW_XID (gdk_screen_get_root_window(gdk_x11_window_get_xid (gdk_screen_get_root_window (gdk_window_get_screen
(window))))
1004 (gdk_window_get_screen (window)))(gdk_x11_window_get_xid (gdk_screen_get_root_window (gdk_window_get_screen
(window))))
;
1005 /*
1006 * FIXME: the following might cause
1007 * big problems for non-GTK apps
1008 */
1009 xevent.xbutton.x = 0;
1010 xevent.xbutton.y = 0;
1011 xevent.xbutton.x_root = 0;
1012 xevent.xbutton.y_root = 0;
1013 xevent.xbutton.state = event->state;
1014 xevent.xbutton.button = event->button;
1015 xevent.xbutton.same_screen = TRUE(!(0)); /* FIXME ? */
1016
1017 gdk_x11_display_error_trap_push (display);
1018
1019 XSendEvent (GDK_WINDOW_XDISPLAY (window)((gdk_x11_display_get_xdisplay (gdk_window_get_display (window
))))
,
1020 GDK_WINDOW_XID (socket_window)(gdk_x11_window_get_xid (socket_window)),
1021 False0, NoEventMask0L, &xevent);
1022
1023 gdk_display_flush (display);
1024 gdk_x11_display_error_trap_pop_ignored (display);
1025
1026 return TRUE(!(0));
1027#else
1028 return FALSE(0);
1029#endif
1030}
1031
1032static gboolean
1033mate_panel_applet_button_press (GtkWidget *widget,
1034 GdkEventButton *event)
1035{
1036 MatePanelApplet *applet = MATE_PANEL_APPLET (widget);
1037
1038 if (!container_has_focusable_child (GTK_CONTAINER (applet)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_container_get_type ()))))))
)) {
1039 if (!gtk_widget_has_focus (widget)) {
1040 gtk_widget_set_can_focus (widget, TRUE(!(0)));
1041 gtk_widget_grab_focus (widget);
1042 }
1043 }
1044
1045#ifdef HAVE_WAYLAND1
1046 /*Limit the window list's applet menu to the handle area*/
1047 if (!(GDK_IS_X11_DISPLAY (gdk_display_get_default ())(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gdk_display_get_default ())); GType __t = ((gdk_x11_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
))
1048 {
1049 MatePanelAppletFlags flags;
1050 flags = mate_panel_applet_get_flags (applet);
1051 if (flags & MATE_PANEL_APPLET_EXPAND_MAJOR)
1052 return FALSE(0);
1053 }
1054#endif
1055
1056 if (event->button == 3) {
1057 mate_panel_applet_menu_popup (applet, (GdkEvent *) event);
1058
1059 return TRUE(!(0));
1060 }
1061 return mate_panel_applet_button_event (applet, event);
1062}
1063
1064static gboolean
1065mate_panel_applet_button_release (GtkWidget *widget,
1066 GdkEventButton *event)
1067{
1068 MatePanelApplet *applet = MATE_PANEL_APPLET (widget);
1069
1070 return mate_panel_applet_button_event (applet, event);
1071}
1072
1073/*Open the applet context menu only on Menu key
1074 *Do not open it on Return or some applets won't work
1075 */
1076static gboolean
1077mate_panel_applet_key_press_event (GtkWidget *widget,
1078 GdkEventKey *event)
1079{
1080 if (event->keyval == GDK_KEY_Menu0xff67) {
1081 mate_panel_applet_menu_popup (MATE_PANEL_APPLET (widget), (GdkEvent *) event);
1082 return TRUE(!(0));
1083 }
1084 else
1085 return FALSE(0);
1086}
1087
1088static void
1089mate_panel_applet_get_preferred_width (GtkWidget *widget,
1090 int *minimum_width,
1091 int *natural_width)
1092{
1093 GTK_WIDGET_CLASS (mate_panel_applet_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((mate_panel_applet_parent_class)), ((gtk_widget_get_type (
)))))))
->get_preferred_width (widget,
1094 minimum_width,
1095 natural_width);
1096
1097#if !GTK_CHECK_VERSION (3, 23, 0)((3) > (3) || ((3) == (3) && (24) > (23)) || ((
3) == (3) && (24) == (23) && (42) >= (0)))
1098 MatePanelAppletPrivate *priv;
1099
1100 priv = mate_panel_applet_get_instance_private (MATE_PANEL_APPLET (widget));
1101 if (priv->out_of_process) {
1102 /* Out-of-process applets end up scaled up doubly with GTK 3.22.
1103 * For these builds divide by the scale factor to ensure
1104 * they are back at their own intended size.
1105 */
1106 gint scale;
1107 scale = gtk_widget_get_scale_factor (widget);
1108 *minimum_width /= scale;
1109 *natural_width /= scale;
1110 }
1111#endif
1112}
1113
1114static void
1115mate_panel_applet_get_preferred_height (GtkWidget *widget,
1116 int *minimum_height,
1117 int *natural_height)
1118{
1119 GTK_WIDGET_CLASS (mate_panel_applet_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((mate_panel_applet_parent_class)), ((gtk_widget_get_type (
)))))))
->get_preferred_height (widget,
1120 minimum_height,
1121 natural_height);
1122
1123#if !GTK_CHECK_VERSION (3, 23, 0)((3) > (3) || ((3) == (3) && (24) > (23)) || ((
3) == (3) && (24) == (23) && (42) >= (0)))
1124 MatePanelAppletPrivate *priv;
1125
1126 priv = mate_panel_applet_get_instance_private (MATE_PANEL_APPLET (widget));
1127 if (priv->out_of_process) {
1128 gint scale;
1129 /* Out-of-process applets end up scaled up doubly with GTK 3.22.
1130 * For these builds divide by the scale factor to ensure
1131 * they are back at their own intended size.
1132 */
1133 scale = gtk_widget_get_scale_factor (widget);
1134 *minimum_height /= scale;
1135 *natural_height /= scale;
1136 }
1137#endif
1138}
1139
1140static GtkSizeRequestMode
1141mate_panel_applet_get_request_mode (GtkWidget *widget)
1142{
1143 /* Do not use GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH
1144 * or GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT
1145 * to avoid problems with in-process applets
1146 * when the panel is not expanded
1147 * See https://github.com/mate-desktop/mate-panel/issues/797
1148 * and https://github.com/mate-desktop/mate-panel/issues/799
1149 * Out of process applets already use GTK_SIZE_REQUEST_CONSTANT_SIZE
1150 */
1151 return GTK_SIZE_REQUEST_CONSTANT_SIZE;
1152}
1153
1154static void
1155mate_panel_applet_size_allocate (GtkWidget *widget,
1156 GtkAllocation *allocation)
1157{
1158 MatePanelAppletPrivate *priv;
1159 GtkAllocation child_allocation;
1160 MatePanelApplet *applet;
1161
1162 if (!mate_panel_applet_can_focus (widget)) {
1163 GTK_WIDGET_CLASS (mate_panel_applet_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((mate_panel_applet_parent_class)), ((gtk_widget_get_type (
)))))))
->size_allocate (widget, allocation);
1164 } else {
1165 int border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_container_get_type ()))))))
);
1166
1167 gtk_widget_set_allocation (widget, allocation);
1168 GtkBin *bin = GTK_BIN (widget)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_bin_get_type ()))))))
;
1169
1170 child_allocation.x = 0;
1171 child_allocation.y = 0;
1172
1173 child_allocation.width = MAX (allocation->width - border_width * 2, 0)(((allocation->width - border_width * 2) > (0)) ? (allocation
->width - border_width * 2) : (0))
;
1174 child_allocation.height = MAX (allocation->height - border_width * 2, 0)(((allocation->height - border_width * 2) > (0)) ? (allocation
->height - border_width * 2) : (0))
;
1175
1176 if (gtk_widget_get_realized (widget))
1177 gdk_window_move_resize (gtk_widget_get_window (widget),
1178 allocation->x + border_width,
1179 allocation->y + border_width,
1180 child_allocation.width,
1181 child_allocation.height);
1182
1183 GtkWidget *child = gtk_bin_get_child (bin);
1184 if (child)
1185 gtk_widget_size_allocate (child, &child_allocation);
1186 }
1187
1188 applet = MATE_PANEL_APPLET (widget);
1189 priv = mate_panel_applet_get_instance_private (applet);
1190
1191 if ((priv->previous_height != allocation->height) ||
1192 (priv->previous_width != allocation->width)) {
1193 priv->previous_height = allocation->height;
1194 priv->previous_width = allocation->width;
1195 mate_panel_applet_handle_background (applet);
1196 }
1197}
1198
1199static gboolean mate_panel_applet_draw(GtkWidget* widget, cairo_t* cr)
1200{
1201 GtkStyleContext *context;
1202 int border_width;
1203 gdouble x, y, width, height;
1204
1205 GTK_WIDGET_CLASS (mate_panel_applet_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((mate_panel_applet_parent_class)), ((gtk_widget_get_type (
)))))))
->draw(widget, cr);
1206
1207 if (!gtk_widget_has_focus (widget))
1208 return FALSE(0);
1209
1210 width = gtk_widget_get_allocated_width (widget);
1211 height = gtk_widget_get_allocated_height (widget);
1212
1213 border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_container_get_type ()))))))
);
1214
1215 x = 0;
1216 y = 0;
1217
1218 width -= 2 * border_width;
1219 height -= 2 * border_width;
1220
1221 context = gtk_widget_get_style_context (widget);
1222 gtk_style_context_save (context);
1223
1224 cairo_save (cr);
1225 gtk_render_focus (context, cr, x, y, width, height);
1226 cairo_restore (cr);
1227
1228 gtk_style_context_restore (context);
1229
1230 return FALSE(0);
1231}
1232
1233static gboolean
1234mate_panel_applet_focus (GtkWidget *widget,
1235 GtkDirectionType dir)
1236{
1237 MatePanelAppletPrivate *priv;
1238 gboolean ret;
1239 GtkWidget *previous_focus_child;
1240
1241 g_return_val_if_fail (MATE_PANEL_IS_APPLET (widget), FALSE)do { if ((MATE_PANEL_IS_APPLET (widget))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (widget)"
); return ((0)); } } while (0)
;
1242
1243 priv = mate_panel_applet_get_instance_private (MATE_PANEL_APPLET (widget));
1244 if (priv->moving_focus_out) {
1245 /*
1246 * Applet will retain focus if there is nothing else on the
1247 * panel to get focus
1248 */
1249 priv->moving_focus_out = FALSE(0);
1250 return FALSE(0);
1251 }
1252
1253 previous_focus_child = gtk_container_get_focus_child (GTK_CONTAINER (widget)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_container_get_type ()))))))
);
1254 if (!previous_focus_child && !gtk_widget_has_focus (widget)) {
1255 if (gtk_widget_get_has_tooltip (widget)) {
1256 gtk_widget_set_can_focus (widget, TRUE(!(0)));
1257 gtk_widget_grab_focus (widget);
1258 gtk_widget_set_can_focus (widget, FALSE(0));
1259 return TRUE(!(0));
1260 }
1261 }
1262 ret = GTK_WIDGET_CLASS (mate_panel_applet_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((mate_panel_applet_parent_class)), ((gtk_widget_get_type (
)))))))
->focus (widget, dir);
1263
1264 if (!ret && !previous_focus_child) {
1265 if (!gtk_widget_has_focus (widget)) {
1266 /*
1267 * Applet does not have a widget which can focus so set
1268 * the focus on the applet unless it already had focus
1269 * because it had a tooltip.
1270 */
1271 gtk_widget_set_can_focus (widget, TRUE(!(0)));
1272 gtk_widget_grab_focus (widget);
1273 gtk_widget_set_can_focus (widget, FALSE(0));
1274 ret = TRUE(!(0));
1275 }
1276 }
1277
1278 return ret;
1279}
1280
1281static gboolean
1282mate_panel_applet_parse_color (const gchar *color_str,
1283 GdkRGBA *color)
1284{
1285 g_assert (color_str && color)do { if (color_str && color) ; else g_assertion_message_expr
(((gchar*) 0), "mate-panel-applet.c", 1285, ((const char*) (
__func__)), "color_str && color"); } while (0)
;
1286
1287 return gdk_rgba_parse (color, color_str);
1288}
1289
1290#ifdef HAVE_X111
1291static gboolean
1292mate_panel_applet_parse_pixmap_str (const char *str,
1293 Window *xid,
1294 int *x,
1295 int *y)
1296{
1297 char **elements;
1298 char *tmp;
1299
1300 g_return_val_if_fail (str != NULL, FALSE)do { if ((str != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "str != NULL"); return
((0)); } } while (0)
;
1301 g_return_val_if_fail (xid != NULL, FALSE)do { if ((xid != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "xid != NULL"); return
((0)); } } while (0)
;
1302 g_return_val_if_fail (x != NULL, FALSE)do { if ((x != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "x != NULL"); return
((0)); } } while (0)
;
1303 g_return_val_if_fail (y != NULL, FALSE)do { if ((y != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "y != NULL"); return
((0)); } } while (0)
;
1304
1305 elements = g_strsplit (str, ",", -1);
1306
1307 if (!elements)
1308 return FALSE(0);
1309
1310 if (!elements [0] || !*elements [0] ||
1311 !elements [1] || !*elements [1] ||
1312 !elements [2] || !*elements [2])
1313 goto ERROR_AND_FREE;
1314
1315 *xid = strtol (elements [0], &tmp, 10);
1316 if (tmp == elements [0])
1317 goto ERROR_AND_FREE;
1318
1319 *x = strtol (elements [1], &tmp, 10);
1320 if (tmp == elements [1])
1321 goto ERROR_AND_FREE;
1322
1323 *y = strtol (elements [2], &tmp, 10);
1324 if (tmp == elements [2])
1325 goto ERROR_AND_FREE;
1326
1327 g_strfreev (elements);
1328 return TRUE(!(0));
1329
1330ERROR_AND_FREE:
1331 g_strfreev (elements);
1332 return FALSE(0);
1333}
1334
1335static cairo_surface_t *
1336mate_panel_applet_create_foreign_surface_for_display (GdkDisplay *display,
1337 GdkVisual *visual,
1338 Window xid)
1339{
1340 Statusint result = 0;
1341 Window window;
1342 gint x, y;
1343 guint width, height, border, depth;
1344
1345 gdk_x11_display_error_trap_push (display);
1346 result = XGetGeometry (GDK_DISPLAY_XDISPLAY (display)(gdk_x11_display_get_xdisplay (display)), xid, &window,
1347 &x, &y, &width, &height, &border, &depth);
1348 gdk_x11_display_error_trap_pop_ignored (display);
1349
1350 if (result == 0)
1351 return NULL((void*)0);
1352
1353 return cairo_xlib_surface_create (GDK_DISPLAY_XDISPLAY (display)(gdk_x11_display_get_xdisplay (display)),
1354 xid, gdk_x11_visual_get_xvisual (visual),
1355 width, height);
1356}
1357
1358static cairo_pattern_t *
1359mate_panel_applet_get_pattern_from_pixmap (MatePanelApplet *applet,
1360 Window xid,
1361 int x,
1362 int y)
1363{
1364 cairo_surface_t *background;
1365 cairo_surface_t *surface;
1366 GdkWindow *window;
1367 int width;
1368 int height;
1369 GdkDisplay *display;
1370 cairo_t *cr;
1371 cairo_pattern_t *pattern;
1372
1373 g_return_val_if_fail (MATE_PANEL_IS_APPLET (applet), NULL)do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return (((void*)0)); } } while (0)
;
1374
1375 if (!gtk_widget_get_realized (GTK_WIDGET (applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
))
1376 return NULL((void*)0);
1377
1378 window = gtk_widget_get_window (GTK_WIDGET (applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
);
1379 display = gdk_window_get_display (window);
1380
1381 background = mate_panel_applet_create_foreign_surface_for_display (display,
1382 gdk_window_get_visual (window),
1383 xid);
1384
1385 /* background can be NULL if the user changes the background very fast.
1386 * We'll get the next update, so it's not a big deal. */
1387 if (!background || cairo_surface_status (background) != CAIRO_STATUS_SUCCESS) {
1388 if (background)
1389 cairo_surface_destroy (background);
1390 return NULL((void*)0);
1391 }
1392
1393 width = gdk_window_get_width(window);
1394 height = gdk_window_get_height(window);
1395 surface = gdk_window_create_similar_surface (window,
1396 CAIRO_CONTENT_COLOR_ALPHA,
1397 width,
1398 height);
1399 gdk_x11_display_error_trap_push (display);
1400 cr = cairo_create (surface);
1401 cairo_set_source_surface (cr, background, -x, -y);
1402 cairo_rectangle (cr, 0, 0, width, height);
1403 cairo_fill (cr);
1404 gdk_x11_display_error_trap_pop_ignored (display);
1405
1406 cairo_surface_destroy (background);
1407 pattern = NULL((void*)0);
1408
1409 if (cairo_status (cr) == CAIRO_STATUS_SUCCESS) {
1410 pattern = cairo_pattern_create_for_surface (surface);
1411 }
1412
1413 cairo_destroy (cr);
1414 cairo_surface_destroy (surface);
1415
1416 return pattern;
1417}
1418#endif
1419
1420static MatePanelAppletBackgroundType
1421mate_panel_applet_handle_background_string (MatePanelApplet *applet,
1422 GdkRGBA *color,
1423 cairo_pattern_t **pattern)
1424{
1425 MatePanelAppletPrivate *priv;
1426 MatePanelAppletBackgroundType retval;
1427 char **elements;
1428
1429 priv = mate_panel_applet_get_instance_private (applet);
1430 retval = PANEL_NO_BACKGROUND;
1431
1432 if (!gtk_widget_get_realized (GTK_WIDGET (applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
) || !priv->background)
1433 return retval;
1434
1435 elements = g_strsplit (priv->background, ":", -1);
1436
1437 if (elements [0] && !strcmp (elements [0], "none" )) {
1438 retval = PANEL_NO_BACKGROUND;
1439
1440 } else if (elements [0] && !strcmp (elements [0], "color")) {
1441 g_return_val_if_fail (color != NULL, PANEL_NO_BACKGROUND)do { if ((color != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "color != NULL");
return (PANEL_NO_BACKGROUND); } } while (0)
;
1442
1443 if (!elements [1] || !mate_panel_applet_parse_color (elements [1], color)) {
1444
1445 g_warning ("Incomplete '%s' background type received", elements [0]);
1446 g_strfreev (elements);
1447 return PANEL_NO_BACKGROUND;
1448 }
1449
1450 retval = PANEL_COLOR_BACKGROUND;
1451
1452 } else if (elements [0] && !strcmp (elements [0], "pixmap")) {
1453#ifdef HAVE_X111
1454 if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gdk_display_get_default ())); GType __t = ((gdk_x11_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
) {
1455 Window pixmap_id;
1456 int x, y;
1457
1458 g_return_val_if_fail (pattern != NULL, PANEL_NO_BACKGROUND)do { if ((pattern != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "pattern != NULL"
); return (PANEL_NO_BACKGROUND); } } while (0)
;
1459
1460 if (!mate_panel_applet_parse_pixmap_str (elements [1], &pixmap_id, &x, &y)) {
1461 g_warning ("Incomplete '%s' background type received: %s",
1462 elements [0], elements [1]);
1463
1464 g_strfreev (elements);
1465 return PANEL_NO_BACKGROUND;
1466 }
1467
1468 *pattern = mate_panel_applet_get_pattern_from_pixmap (applet, pixmap_id, x, y);
1469 if (!*pattern) {
1470 g_warning ("Failed to get pattern %s", elements [1]);
1471 g_strfreev (elements);
1472 return PANEL_NO_BACKGROUND;
1473 }
1474
1475 retval = PANEL_PIXMAP_BACKGROUND;
1476 } else
1477#endif
1478 { /* not using X11 */
1479 g_warning("Received pixmap background type, which is only supported on X11");
1480 }
1481 } else
1482 g_warning ("Unknown background type received");
1483
1484 g_strfreev (elements);
1485
1486 return retval;
1487}
1488
1489MatePanelAppletBackgroundType
1490mate_panel_applet_get_background (MatePanelApplet *applet,
1491 GdkRGBA *color,
1492 cairo_pattern_t **pattern)
1493{
1494 g_return_val_if_fail (MATE_PANEL_IS_APPLET (applet), PANEL_NO_BACKGROUND)do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return (PANEL_NO_BACKGROUND); } } while (0)
;
1495
1496 /* initial sanity */
1497 if (pattern != NULL((void*)0))
1498 *pattern = NULL((void*)0);
1499
1500 if (color != NULL((void*)0))
1501 memset (color, 0, sizeof (GdkRGBA));
1502
1503 return mate_panel_applet_handle_background_string (applet, color, pattern);
1504}
1505
1506static void
1507mate_panel_applet_set_background_string (MatePanelApplet *applet,
1508 const gchar *background)
1509{
1510 MatePanelAppletPrivate *priv;
1511
1512 priv = mate_panel_applet_get_instance_private (applet);
1513
1514 if (priv->background == background)
1515 return;
1516
1517 if (g_strcmp0 (priv->background, background) == 0)
1518 return;
1519
1520 g_free (priv->background);
1521 priv->background = background ? g_strdup (background)g_strdup_inline (background) : NULL((void*)0);
1522 mate_panel_applet_handle_background (applet);
1523
1524 g_object_notify (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
, "background");
1525}
1526
1527static void
1528mate_panel_applet_handle_background (MatePanelApplet *applet)
1529{
1530 MatePanelAppletBackgroundType type;
1531
1532 GdkRGBA color;
1533 cairo_pattern_t *pattern;
1534
1535 type = mate_panel_applet_get_background (applet, &color, &pattern);
1536
1537 if (!gdk_screen_is_composited (gdk_screen_get_default ())) {
1538 color.alpha = 1.;
1539 }
1540
1541 switch (type) {
1542 case PANEL_NO_BACKGROUND:
1543 g_signal_emit (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
,
1544 mate_panel_applet_signals [CHANGE_BACKGROUND],
1545 0, PANEL_NO_BACKGROUND, NULL((void*)0), NULL((void*)0));
1546 break;
1547 case PANEL_COLOR_BACKGROUND:
1548 g_signal_emit (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
,
1549 mate_panel_applet_signals [CHANGE_BACKGROUND],
1550 0, PANEL_COLOR_BACKGROUND, &color, NULL((void*)0));
1551 break;
1552 case PANEL_PIXMAP_BACKGROUND:
1553 g_signal_emit (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
,
1554 mate_panel_applet_signals [CHANGE_BACKGROUND],
1555
1556 0, PANEL_PIXMAP_BACKGROUND, NULL((void*)0), pattern);
1557
1558 cairo_pattern_destroy (pattern);
1559
1560 break;
1561 default:
1562 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "mate-panel-applet.c"
, 1562, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1563 break;
1564 }
1565}
1566
1567static void
1568mate_panel_applet_realize (GtkWidget *widget)
1569{
1570 MatePanelApplet *applet;
1571 MatePanelAppletPrivate *priv;
1572
1573 GTK_WIDGET_CLASS (mate_panel_applet_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((mate_panel_applet_parent_class)), ((gtk_widget_get_type (
)))))))
->realize (widget);
1574
1575 applet = MATE_PANEL_APPLET (widget);
1576 priv = mate_panel_applet_get_instance_private (applet);
1577 if (priv->background)
1578 mate_panel_applet_handle_background (applet);
1579}
1580
1581static void
1582mate_panel_applet_move_focus_out_of_applet (MatePanelApplet *applet,
1583 GtkDirectionType dir)
1584{
1585 MatePanelAppletPrivate *priv;
1586 GtkWidget *toplevel;
1587
1588 priv = mate_panel_applet_get_instance_private (applet);
1589 priv->moving_focus_out = TRUE(!(0));
1590 toplevel = gtk_widget_get_toplevel (GTK_WIDGET (applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
);
1591 g_return_if_fail (toplevel)do { if ((toplevel)) { } else { g_return_if_fail_warning (((gchar
*) 0), ((const char*) (__func__)), "toplevel"); return; } } while
(0)
;
1592
1593 gtk_widget_child_focus (toplevel, dir);
1594 priv->moving_focus_out = FALSE(0);
1595}
1596
1597static void
1598mate_panel_applet_change_background(MatePanelApplet *applet,
1599 MatePanelAppletBackgroundType type,
1600 GdkRGBA* color,
1601 cairo_pattern_t *pattern)
1602{
1603 MatePanelAppletPrivate *priv;
1604 GdkWindow *window;
1605
1606 priv = mate_panel_applet_get_instance_private (applet);
1607
1608 if (priv->out_of_process)
1609 window = gtk_widget_get_window (GTK_WIDGET (priv->plug)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->plug)), ((gtk_widget_get_type ()))))))
);
1610 else
1611 window = gtk_widget_get_window (GTK_WIDGET (applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
);
1612
1613 gtk_widget_set_app_paintable (GTK_WIDGET (applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
,TRUE(!(0)));
1614
1615 if (priv->out_of_process)
1616 _mate_panel_applet_apply_css (GTK_WIDGET (priv->plug)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->plug)), ((gtk_widget_get_type ()))))))
,type);
1617
1618 switch (type) {
1619 case PANEL_NO_BACKGROUND:
1620 if (priv->out_of_process){
1621 cairo_pattern_t *transparent = cairo_pattern_create_rgba (0, 0, 0, 0); /* Using NULL here breaks transparent */
1622 gdk_window_set_background_pattern (window, transparent); /* backgrounds set by GTK theme */
1623 cairo_pattern_destroy (transparent);
1624 }
1625 break;
1626 case PANEL_COLOR_BACKGROUND:
1627 if (priv->out_of_process){
1628 gdk_window_set_background_rgba(window,color);
1629 gtk_widget_queue_draw (priv->plug); /*change the bg right away always */
1630 }
1631 break;
1632 case PANEL_PIXMAP_BACKGROUND:
1633 if (priv->out_of_process){
1634 gdk_window_set_background_pattern(window,pattern);
1635 gtk_widget_queue_draw (priv->plug); /*change the bg right away always */
1636 }
1637 break;
1638 default:
1639 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "mate-panel-applet.c"
, 1639, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1640 break;
1641 }
1642
1643 if (priv->out_of_process){
1644 GtkStyleContext *context;
1645
1646 context = gtk_widget_get_style_context (GTK_WIDGET (priv->plug)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->plug)), ((gtk_widget_get_type ()))))))
);
1647
1648 if (priv->orient == MATE_PANEL_APPLET_ORIENT_UP ||
1649 priv->orient == MATE_PANEL_APPLET_ORIENT_DOWN)
1650 gtk_style_context_add_class (context, "horizontal");
1651 else
1652 gtk_style_context_add_class (context, "vertical");
1653 }
1654}
1655
1656static void
1657mate_panel_applet_get_property (GObject *object,
1658 guint prop_id,
1659 GValue *value,
1660 GParamSpec *pspec)
1661{
1662 MatePanelApplet *applet;
1663 MatePanelAppletPrivate *priv;
1664
1665 applet = MATE_PANEL_APPLET (object);
1666 priv = mate_panel_applet_get_instance_private (applet);
1667
1668 switch (prop_id) {
1669 case PROP_OUT_OF_PROCESS:
1670 g_value_set_boolean (value, priv->out_of_process);
1671 break;
1672 case PROP_ID:
1673 g_value_set_string (value, priv->id);
1674 break;
1675 case PROP_CLOSURE:
1676 g_value_set_pointer (value, priv->closure);
1677 break;
1678 case PROP_CONNECTION:
1679 g_value_set_object (value, priv->connection);
1680 break;
1681 case PROP_PREFS_PATH:
1682 g_value_set_string (value, priv->prefs_path);
1683 break;
1684 case PROP_ORIENT:
1685 g_value_set_uint (value, priv->orient);
1686 break;
1687 case PROP_SIZE:
1688 g_value_set_uint (value, priv->size);
1689 break;
1690 case PROP_BACKGROUND:
1691 g_value_set_string (value, priv->background);
1692 break;
1693 case PROP_FLAGS:
1694 g_value_set_uint (value, priv->flags);
1695 break;
1696 case PROP_SIZE_HINTS: {
1697 GVariant **children;
1698 GVariant *variant;
1699 gint i;
1700
1701 children = g_new (GVariant *, priv->size_hints_len)((GVariant * *) g_malloc_n ((priv->size_hints_len), sizeof
(GVariant *)))
;
1702 for (i = 0; i < priv->size_hints_len; i++)
1703 children[i] = g_variant_new_int32 (priv->size_hints[i]);
1704 variant = g_variant_new_array (G_VARIANT_TYPE_INT32((const GVariantType *) "i"),
1705 children, priv->size_hints_len);
1706 g_free (children);
1707 g_value_set_pointer (value, variant);
1708 break;
1709 }
1710 case PROP_LOCKED:
1711 g_value_set_boolean (value, priv->locked);
1712 break;
1713 case PROP_LOCKED_DOWN:
1714 g_value_set_boolean (value, priv->locked_down);
1715 break;
1716 default:
1717 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "mate-panel-applet.c", 1717, ("property"), _glib__property_id
, _glib__pspec->name, g_type_name ((((((GTypeClass*) (((GTypeInstance
*) (_glib__pspec))->g_class))->g_type)))), (g_type_name
((((((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
1718 }
1719}
1720
1721static void
1722mate_panel_applet_set_property (GObject *object,
1723 guint prop_id,
1724 const GValue *value,
1725 GParamSpec *pspec)
1726{
1727 MatePanelApplet *applet;
1728 MatePanelAppletPrivate *priv;
1729
1730 applet = MATE_PANEL_APPLET (object);
1731 priv = mate_panel_applet_get_instance_private (applet);
1732
1733 switch (prop_id) {
1734 case PROP_OUT_OF_PROCESS:
1735 priv->out_of_process = g_value_get_boolean (value);
1736 break;
1737 case PROP_ID:
1738 priv->id = g_value_dup_string (value);
1739 break;
1740 case PROP_CLOSURE:
1741 priv->closure = g_value_get_pointer (value);
1742 g_closure_set_marshal (priv->closure,
1743 mate_panel_applet_marshal_BOOLEAN__STRING);
1744 break;
1745 case PROP_CONNECTION:
1746 priv->connection = g_value_dup_object (value);
1747 break;
1748 case PROP_PREFS_PATH:
1749 mate_panel_applet_set_preferences_path (applet, g_value_get_string (value));
1750 break;
1751 case PROP_ORIENT:
1752 mate_panel_applet_set_orient (applet, g_value_get_uint (value));
1753 break;
1754 case PROP_SIZE:
1755 mate_panel_applet_set_size (applet, g_value_get_uint (value));
1756 break;
1757 case PROP_BACKGROUND:
1758 mate_panel_applet_set_background_string (applet, g_value_get_string (value));
1759 break;
1760 case PROP_FLAGS:
1761 mate_panel_applet_set_flags (applet, g_value_get_uint (value));
1762 break;
1763 case PROP_SIZE_HINTS: {
1764 const int *size_hints;
1765 gsize n_elements;
1766
1767 size_hints = g_variant_get_fixed_array (g_value_get_pointer (value),
1768 &n_elements, sizeof (gint32));
1769 mate_panel_applet_set_size_hints (applet, size_hints, n_elements, 0);
1770 }
1771 break;
1772 case PROP_LOCKED:
1773 mate_panel_applet_set_locked (applet, g_value_get_boolean (value));
1774 break;
1775 case PROP_LOCKED_DOWN:
1776 mate_panel_applet_set_locked_down (applet, g_value_get_boolean (value));
1777 break;
1778 default:
1779 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "mate-panel-applet.c", 1779, ("property"), _glib__property_id
, _glib__pspec->name, g_type_name ((((((GTypeClass*) (((GTypeInstance
*) (_glib__pspec))->g_class))->g_type)))), (g_type_name
((((((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
1780 }
1781}
1782
1783static void
1784add_tab_bindings (GtkBindingSet *binding_set,
1785 GdkModifierType modifiers,
1786 GtkDirectionType direction)
1787{
1788 gtk_binding_entry_add_signal (binding_set, GDK_KEY_Tab0xff09, modifiers,
1789 "move_focus_out_of_applet", 1,
1790 GTK_TYPE_DIRECTION_TYPE(gtk_direction_type_get_type ()), direction);
1791 gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Tab0xff89, modifiers,
1792 "move_focus_out_of_applet", 1,
1793 GTK_TYPE_DIRECTION_TYPE(gtk_direction_type_get_type ()), direction);
1794}
1795
1796static void
1797mate_panel_applet_setup (MatePanelApplet *applet)
1798{
1799 MatePanelAppletPrivate *priv;
1800 GValue value = {0, };
1801 GArray *params;
1802 guint i;
1803 gboolean ret;
1804
1805 priv = mate_panel_applet_get_instance_private (applet);
1806
1807 g_assert ((priv->id != NULL) && (priv->closure != NULL))do { if ((priv->id != ((void*)0)) && (priv->closure
!= ((void*)0))) ; else g_assertion_message_expr (((gchar*) 0
), "mate-panel-applet.c", 1807, ((const char*) (__func__)), "(priv->id != NULL) && (priv->closure != NULL)"
); } while (0)
;
1808
1809 params = g_array_sized_new (FALSE(0), TRUE(!(0)), sizeof (GValue), 2);
1810 value.g_type = 0;
1811 g_value_init (&value, G_TYPE_OBJECT((GType) ((20) << (2))));
1812 g_value_set_object (&value, G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
);
1813 g_array_append_val (params, value)g_array_append_vals (params, &(value), 1);
1814
1815 value.g_type = 0;
1816 g_value_init (&value, G_TYPE_STRING((GType) ((16) << (2))));
1817 g_value_set_string (&value, priv->id);
1818 g_array_append_val (params, value)g_array_append_vals (params, &(value), 1);
1819
1820 value.g_type = 0;
1821 g_value_init (&value, G_TYPE_BOOLEAN((GType) ((5) << (2))));
1822
1823 g_closure_invoke (priv->closure,
1824 &value, params->len,
1825 (GValue *) params->data,
1826 NULL((void*)0));
1827
1828 for (i = 0; i < params->len; i++)
1829 g_value_unset (&g_array_index (params, GValue, i)(((GValue*) (void *) (params)->data) [(i)]));
1830 g_array_free (params, TRUE(!(0)));
1831
1832 ret = g_value_get_boolean (&value);
1833 g_value_unset (&value);
1834
1835 if (!ret) { /* FIXME */
1836 g_warning ("need to free the control here");
1837
1838 return;
1839 }
1840}
1841
1842void _mate_panel_applet_apply_css(GtkWidget* widget, MatePanelAppletBackgroundType type)
1843{
1844 GtkStyleContext* context;
1845
1846 context = gtk_widget_get_style_context (widget);
1847
1848 switch (type) {
1849 case PANEL_NO_BACKGROUND:
1850 gtk_style_context_remove_class (context, "mate-custom-panel-background");
1851 break;
1852 case PANEL_COLOR_BACKGROUND:
1853 case PANEL_PIXMAP_BACKGROUND:
1854 gtk_style_context_add_class (context, "mate-custom-panel-background");
1855 break;
1856 default:
1857 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "mate-panel-applet.c"
, 1857, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1858 break;
1859 }
1860}
1861
1862#ifdef HAVE_X111
1863static void _mate_panel_applet_prepare_css (GtkStyleContext *context)
1864{
1865 GtkCssProvider *provider;
1866
1867 g_return_if_fail (GDK_IS_X11_DISPLAY (gdk_display_get_default ()))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((gdk_display_get_default ())); GType __t = ((gdk_x11_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0
), ((const char*) (__func__)), "GDK_IS_X11_DISPLAY (gdk_display_get_default ())"
); return; } } while (0)
;
1868 provider = gtk_css_provider_new ();
1869 gtk_css_provider_load_from_data (provider,
1870 "#PanelPlug {\n"
1871 " background-repeat: no-repeat;\n" /*disable in gtk theme features */
1872 " background-size: cover; " /*that don't work on panel-toplevel */
1873 " }\n"
1874 ".mate-custom-panel-background{\n" /*prepare CSS for user set theme */
1875 " background-color: rgba (0, 0, 0, 0);\n"
1876 " background-image: none;\n"
1877 "}",
1878 -1, NULL((void*)0));
1879
1880 gtk_style_context_add_provider (context,
1881 GTK_STYLE_PROVIDER (provider)((((GtkStyleProvider*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((provider)), ((gtk_style_provider_get_type (
)))))))
,
1882 GTK_STYLE_PROVIDER_PRIORITY_APPLICATION600);
1883 g_object_unref (provider);
1884}
1885#endif /* HAVE_X11 */
1886
1887static void
1888mate_panel_applet_init (MatePanelApplet *applet)
1889{
1890 MatePanelAppletPrivate *priv;
1891
1892 priv = mate_panel_applet_get_instance_private (applet);
1893
1894 priv->flags = MATE_PANEL_APPLET_FLAGS_NONE;
1895 priv->orient = MATE_PANEL_APPLET_ORIENT_UP;
1896 priv->size = 24;
1897
1898 priv->panel_action_group = gtk_action_group_new ("PanelActions");
1899 gtk_action_group_set_translation_domain (priv->panel_action_group, GETTEXT_PACKAGE"mate-panel");
1900 gtk_action_group_add_actions (priv->panel_action_group,
1901 menu_entries,
1902 G_N_ELEMENTS (menu_entries)(sizeof (menu_entries) / sizeof ((menu_entries)[0])),
1903 applet);
1904 gtk_action_group_add_toggle_actions (priv->panel_action_group,
1905 menu_toggle_entries,
1906 G_N_ELEMENTS (menu_toggle_entries)(sizeof (menu_toggle_entries) / sizeof ((menu_toggle_entries)
[0]))
,
1907 applet);
1908
1909 priv->ui_manager = gtk_ui_manager_new ();
1910 gtk_ui_manager_insert_action_group (priv->ui_manager,
1911 priv->panel_action_group, 1);
1912 gtk_ui_manager_add_ui_from_string (priv->ui_manager,
1913 panel_menu_ui, -1, NULL((void*)0));
1914
1915 gtk_widget_set_events (GTK_WIDGET (applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
,
1916 GDK_BUTTON_PRESS_MASK |
1917 GDK_BUTTON_RELEASE_MASK);
1918}
1919
1920static GObject *
1921mate_panel_applet_constructor (GType type,
1922 guint n_construct_properties,
1923 GObjectConstructParam *construct_properties)
1924{
1925 GObject *object;
1926 MatePanelApplet *applet;
1927 MatePanelAppletPrivate *priv;
1928
1929 object = G_OBJECT_CLASS (mate_panel_applet_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((mate_panel_applet_parent_class)), (((GType) ((20) <<
(2))))))))
->constructor (type,
1930 n_construct_properties,
1931 construct_properties);
1932 applet = MATE_PANEL_APPLET (object);
1933 priv = mate_panel_applet_get_instance_private (applet);
1934
1935 if (!priv->out_of_process)
1936 return object;
1937
1938#ifdef HAVE_X111
1939 if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gdk_display_get_default ())); GType __t = ((gdk_x11_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
)
1940 {
1941 GtkStyleContext *context;
1942 GtkWidget *widget;
1943
1944 priv->plug = gtk_plug_new (0);
1945 widget = GTK_WIDGET (priv->plug)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->plug)), ((gtk_widget_get_type ()))))))
;
1946 gtk_widget_set_visual (widget,
1947 gdk_screen_get_rgba_visual (gtk_widget_get_screen (widget)));
1948 context = gtk_widget_get_style_context (widget);
1949 gtk_style_context_add_class (context, "gnome-panel-menu-bar");
1950 gtk_style_context_add_class (context, "mate-panel-menu-bar");
1951 gtk_widget_set_name (widget, "PanelPlug");
1952 _mate_panel_applet_prepare_css (context);
1953
1954 g_signal_connect_swapped (priv->plug, "embedded",g_signal_connect_data ((priv->plug), ("embedded"), (((GCallback
) (mate_panel_applet_setup))), (applet), ((void*)0), G_CONNECT_SWAPPED
)
1955 G_CALLBACK (mate_panel_applet_setup),g_signal_connect_data ((priv->plug), ("embedded"), (((GCallback
) (mate_panel_applet_setup))), (applet), ((void*)0), G_CONNECT_SWAPPED
)
1956 applet)g_signal_connect_data ((priv->plug), ("embedded"), (((GCallback
) (mate_panel_applet_setup))), (applet), ((void*)0), G_CONNECT_SWAPPED
)
;
1957
1958 gtk_container_add (GTK_CONTAINER (priv->plug)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->plug)), ((gtk_container_get_type ()))))))
, GTK_WIDGET (applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
);
1959 } else
1960#endif
1961 { /* not using X11 */
1962 g_warning ("Requested construction of an out-of-process applet, which is only possible on X11");
1963 }
1964
1965 return object;
1966}
1967
1968static void
1969mate_panel_applet_constructed (GObject* object)
1970{
1971 MatePanelApplet* applet = MATE_PANEL_APPLET(object);
1972
1973 /* Rename the class to have compatibility with all GTK2 themes
1974 * https://github.com/perberos/Mate-Desktop-Environment/issues/27
1975 */
1976 gtk_widget_set_name(GTK_WIDGET(applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
, "PanelApplet");
1977
1978 mate_panel_applet_register_object (applet);
1979}
1980
1981static void
1982mate_panel_applet_class_init (MatePanelAppletClass *klass)
1983{
1984 GObjectClass *gobject_class = (GObjectClass *) klass;
1985 GtkWidgetClass *widget_class = (GtkWidgetClass *) klass;
1986 GtkBindingSet *binding_set;
1987
1988 gobject_class->get_property = mate_panel_applet_get_property;
1989 gobject_class->set_property = mate_panel_applet_set_property;
1990 gobject_class->constructor = mate_panel_applet_constructor;
1991 gobject_class->constructed = mate_panel_applet_constructed;
1992 klass->move_focus_out_of_applet = mate_panel_applet_move_focus_out_of_applet;
1993 klass->change_background = mate_panel_applet_change_background;
1994 widget_class->button_press_event = mate_panel_applet_button_press;
1995 widget_class->button_release_event = mate_panel_applet_button_release;
1996 widget_class->get_request_mode = mate_panel_applet_get_request_mode;
1997 widget_class->get_preferred_width = mate_panel_applet_get_preferred_width;
1998 widget_class->get_preferred_height = mate_panel_applet_get_preferred_height;
1999 widget_class->draw = mate_panel_applet_draw;
2000 widget_class->size_allocate = mate_panel_applet_size_allocate;
2001 widget_class->focus = mate_panel_applet_focus;
2002 widget_class->realize = mate_panel_applet_realize;
2003 widget_class->key_press_event = mate_panel_applet_key_press_event;
2004
2005 gobject_class->finalize = mate_panel_applet_finalize;
2006
2007 g_object_class_install_property (gobject_class,
2008 PROP_OUT_OF_PROCESS,
2009 g_param_spec_boolean ("out-of-process",
2010 "out-of-process",
2011 "out-of-process",
2012 TRUE(!(0)),
2013 G_PARAM_CONSTRUCT_ONLY |
2014 G_PARAM_READWRITE));
2015 g_object_class_install_property (gobject_class,
2016 PROP_ID,
2017 g_param_spec_string ("id",
2018 "Id",
2019 "The Applet identifier",
2020 NULL((void*)0),
2021 G_PARAM_CONSTRUCT_ONLY |
2022 G_PARAM_READWRITE));
2023 g_object_class_install_property (gobject_class,
2024 PROP_CLOSURE,
2025 g_param_spec_pointer ("closure",
2026 "GClosure",
2027 "The Applet closure",
2028 G_PARAM_CONSTRUCT_ONLY |
2029 G_PARAM_READWRITE));
2030 g_object_class_install_property (gobject_class,
2031 PROP_CONNECTION,
2032 g_param_spec_object ("connection",
2033 "Connection",
2034 "The DBus Connection",
2035 G_TYPE_DBUS_CONNECTION(g_dbus_connection_get_type ()),
2036 G_PARAM_CONSTRUCT_ONLY |
2037 G_PARAM_READWRITE));
2038 g_object_class_install_property (gobject_class,
2039 PROP_PREFS_PATH,
2040 g_param_spec_string ("prefs-path",
2041 "PrefsPath",
2042 "GSettings Preferences Path",
2043 NULL((void*)0),
2044 G_PARAM_READWRITE));
2045 g_object_class_install_property (gobject_class,
2046 PROP_ORIENT,
2047 g_param_spec_uint ("orient",
2048 "Orient",
2049 "Panel Applet Orientation",
2050 MATE_PANEL_APPLET_ORIENT_FIRSTMATE_PANEL_APPLET_ORIENT_UP,
2051 MATE_PANEL_APPLET_ORIENT_LASTMATE_PANEL_APPLET_ORIENT_RIGHT,
2052 MATE_PANEL_APPLET_ORIENT_UP,
2053 G_PARAM_READWRITE));
2054 g_object_class_install_property (gobject_class,
2055 PROP_SIZE,
2056 g_param_spec_uint ("size",
2057 "Size",
2058 "Panel Applet Size",
2059 0, G_MAXUINT(2147483647 *2U +1U), 0,
2060 G_PARAM_READWRITE));
2061 g_object_class_install_property (gobject_class,
2062 PROP_BACKGROUND,
2063 g_param_spec_string ("background",
2064 "Background",
2065 "Panel Applet Background",
2066 NULL((void*)0),
2067 G_PARAM_READWRITE));
2068 g_object_class_install_property (gobject_class,
2069 PROP_FLAGS,
2070 g_param_spec_uint ("flags",
2071 "Flags",
2072 "Panel Applet flags",
2073 MATE_PANEL_APPLET_FLAGS_NONE,
2074 MATE_PANEL_APPLET_FLAGS_ALL(MATE_PANEL_APPLET_EXPAND_MAJOR|MATE_PANEL_APPLET_EXPAND_MINOR
|MATE_PANEL_APPLET_HAS_HANDLE)
,
2075 MATE_PANEL_APPLET_FLAGS_NONE,
2076 G_PARAM_READWRITE));
2077 g_object_class_install_property (gobject_class,
2078 PROP_SIZE_HINTS,
2079 /* FIXME: value_array? */
2080 g_param_spec_pointer ("size-hints",
2081 "SizeHints",
2082 "Panel Applet Size Hints",
2083 G_PARAM_READWRITE));
2084 g_object_class_install_property (gobject_class,
2085 PROP_LOCKED,
2086 g_param_spec_boolean ("locked",
2087 "Locked",
2088 "Whether Panel Applet is locked",
2089 FALSE(0),
2090 G_PARAM_READWRITE));
2091 g_object_class_install_property (gobject_class,
2092 PROP_LOCKED_DOWN,
2093 g_param_spec_boolean ("locked-down",
2094 "LockedDown",
2095 "Whether Panel Applet is locked down",
2096 FALSE(0),
2097 G_PARAM_READWRITE));
2098
2099 mate_panel_applet_signals [CHANGE_ORIENT] =
2100 g_signal_new ("change-orient",
2101 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2102 G_SIGNAL_RUN_LAST,
2103 G_STRUCT_OFFSET (MatePanelAppletClass, change_orient)((glong) __builtin_offsetof(MatePanelAppletClass, change_orient
))
,
2104 NULL((void*)0),
2105 NULL((void*)0),
2106 mate_panel_applet_marshal_VOID__UINTg_cclosure_marshal_VOID__UINT,
2107 G_TYPE_NONE((GType) ((1) << (2))),
2108 1,
2109 G_TYPE_UINT((GType) ((7) << (2))));
2110
2111 mate_panel_applet_signals [CHANGE_SIZE] =
2112 g_signal_new ("change-size",
2113 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2114 G_SIGNAL_RUN_LAST,
2115 G_STRUCT_OFFSET (MatePanelAppletClass, change_size)((glong) __builtin_offsetof(MatePanelAppletClass, change_size
))
,
2116 NULL((void*)0),
2117 NULL((void*)0),
2118 mate_panel_applet_marshal_VOID__INTg_cclosure_marshal_VOID__INT,
2119 G_TYPE_NONE((GType) ((1) << (2))),
2120 1,
2121 G_TYPE_INT((GType) ((6) << (2))));
2122
2123 mate_panel_applet_signals [CHANGE_BACKGROUND] =
2124 g_signal_new ("change-background",
2125 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2126 G_SIGNAL_RUN_LAST,
2127 G_STRUCT_OFFSET (MatePanelAppletClass, change_background)((glong) __builtin_offsetof(MatePanelAppletClass, change_background
))
,
2128 NULL((void*)0),
2129 NULL((void*)0),
2130 mate_panel_applet_marshal_VOID__ENUM_BOXED_OBJECT,
2131 G_TYPE_NONE((GType) ((1) << (2))),
2132 3,
2133 PANEL_TYPE_MATE_PANEL_APPLET_BACKGROUND_TYPEmate_panel_applet_background_type_get_type(),
2134 GDK_TYPE_RGBA(gdk_rgba_get_type ()),
2135 CAIRO_GOBJECT_TYPE_PATTERNcairo_gobject_pattern_get_type ());
2136
2137 mate_panel_applet_signals [MOVE_FOCUS_OUT_OF_APPLET] =
2138 g_signal_new ("move_focus_out_of_applet",
2139 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2140 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
2141 G_STRUCT_OFFSET (MatePanelAppletClass, move_focus_out_of_applet)((glong) __builtin_offsetof(MatePanelAppletClass, move_focus_out_of_applet
))
,
2142 NULL((void*)0),
2143 NULL((void*)0),
2144 mate_panel_applet_marshal_VOID__ENUMg_cclosure_marshal_VOID__ENUM,
2145 G_TYPE_NONE((GType) ((1) << (2))),
2146 1,
2147 GTK_TYPE_DIRECTION_TYPE(gtk_direction_type_get_type ()));
2148
2149 binding_set = gtk_binding_set_by_class (gobject_class);
2150 add_tab_bindings (binding_set, 0, GTK_DIR_TAB_FORWARD);
2151 add_tab_bindings (binding_set, GDK_SHIFT_MASK, GTK_DIR_TAB_BACKWARD);
2152 add_tab_bindings (binding_set, GDK_CONTROL_MASK, GTK_DIR_TAB_FORWARD);
2153 add_tab_bindings (binding_set, GDK_CONTROL_MASK | GDK_SHIFT_MASK, GTK_DIR_TAB_BACKWARD);
2154
2155 gtk_widget_class_set_css_name (widget_class, "PanelApplet");
2156}
2157
2158GtkWidget* mate_panel_applet_new(void)
2159{
2160 MatePanelApplet* applet = g_object_new(PANEL_TYPE_APPLETmate_panel_applet_get_type (), NULL((void*)0));
2161
2162 return GTK_WIDGET(applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
;
2163}
2164
2165static GdkEvent *
2166button_press_event_new (MatePanelApplet *applet,
2167 guint button,
2168 guint time)
2169{
2170 GdkDisplay *display;
2171 GdkSeat *seat;
2172 GdkDevice *device;
2173 GdkEvent *event;
2174
2175 display = gdk_display_get_default ();
2176 seat = gdk_display_get_default_seat (display);
2177 device = gdk_seat_get_pointer (seat);
2178
2179 event = gdk_event_new (GDK_BUTTON_PRESS);
2180
2181 event->button.time = time;
2182 event->button.button = button;
2183
2184 gdk_event_set_device (event, device);
2185
2186 return event;
2187}
2188
2189static void
2190method_call_cb (GDBusConnection *connection,
2191 const gchar *sender,
2192 const gchar *object_path,
2193 const gchar *interface_name,
2194 const gchar *method_name,
2195 GVariant *parameters,
2196 GDBusMethodInvocation *invocation,
2197 gpointer user_data)
2198{
2199 MatePanelApplet *applet = MATE_PANEL_APPLET (user_data);
2200
2201 if (g_strcmp0 (method_name, "PopupMenu") == 0) {
2202 guint button;
2203 guint time;
2204
2205 g_variant_get (parameters, "(uu)", &button, &time);
2206
2207 GdkEvent *event = button_press_event_new (applet, button, time);
2208 mate_panel_applet_menu_popup (applet, event);
2209 gdk_event_free (event);
2210
2211 g_dbus_method_invocation_return_value (invocation, NULL((void*)0));
2212 }
2213}
2214
2215static GVariant *
2216get_property_cb (GDBusConnection *connection,
2217 const gchar *sender,
2218 const gchar *object_path,
2219 const gchar *interface_name,
2220 const gchar *property_name,
2221 GError **error,
2222 gpointer user_data)
2223{
2224 MatePanelAppletPrivate *priv;
2225 GVariant *retval = NULL((void*)0);
2226
2227 priv = mate_panel_applet_get_instance_private (MATE_PANEL_APPLET (user_data));
2228
2229 if (g_strcmp0 (property_name, "PrefsPath") == 0) {
2230 retval = g_variant_new_string (priv->prefs_path ? priv->prefs_path : "");
2231 } else if (g_strcmp0 (property_name, "Orient") == 0) {
2232 retval = g_variant_new_uint32 (priv->orient);
2233 } else if (g_strcmp0 (property_name, "Size") == 0) {
2234 retval = g_variant_new_uint32 (priv->size);
2235 } else if (g_strcmp0 (property_name, "Background") == 0) {
2236 retval = g_variant_new_string (priv->background ? priv->background : "");
2237 } else if (g_strcmp0 (property_name, "Flags") == 0) {
2238 retval = g_variant_new_uint32 (priv->flags);
2239 } else if (g_strcmp0 (property_name, "SizeHints") == 0) {
2240 GVariant **children;
2241 gint i;
2242
2243 children = g_new (GVariant *, priv->size_hints_len)((GVariant * *) g_malloc_n ((priv->size_hints_len), sizeof
(GVariant *)))
;
2244 for (i = 0; i < priv->size_hints_len; i++)
2245 children[i] = g_variant_new_int32 (priv->size_hints[i]);
2246 retval = g_variant_new_array (G_VARIANT_TYPE_INT32((const GVariantType *) "i"),
2247 children, priv->size_hints_len);
2248 g_free (children);
2249 } else if (g_strcmp0 (property_name, "Locked") == 0) {
2250 retval = g_variant_new_boolean (priv->locked);
2251 } else if (g_strcmp0 (property_name, "LockedDown") == 0) {
2252 retval = g_variant_new_boolean (priv->locked_down);
2253 }
2254
2255 return retval;
2256}
2257
2258static gboolean
2259set_property_cb (GDBusConnection *connection,
2260 const gchar *sender,
2261 const gchar *object_path,
2262 const gchar *interface_name,
2263 const gchar *property_name,
2264 GVariant *value,
2265 GError **error,
2266 gpointer user_data)
2267{
2268 MatePanelApplet *applet = MATE_PANEL_APPLET (user_data);
2269
2270 if (g_strcmp0 (property_name, "PrefsPath") == 0) {
2271 mate_panel_applet_set_preferences_path (applet, g_variant_get_string (value, NULL((void*)0)));
2272 } else if (g_strcmp0 (property_name, "Orient") == 0) {
2273 mate_panel_applet_set_orient (applet, g_variant_get_uint32 (value));
2274 } else if (g_strcmp0 (property_name, "Size") == 0) {
2275 mate_panel_applet_set_size (applet, g_variant_get_uint32 (value));
2276 } else if (g_strcmp0 (property_name, "Background") == 0) {
2277 mate_panel_applet_set_background_string (applet, g_variant_get_string (value, NULL((void*)0)));
2278 } else if (g_strcmp0 (property_name, "Flags") == 0) {
2279 mate_panel_applet_set_flags (applet, g_variant_get_uint32 (value));
2280 } else if (g_strcmp0 (property_name, "SizeHints") == 0) {
2281 const int *size_hints;
2282 gsize n_elements;
2283
2284 size_hints = g_variant_get_fixed_array (value, &n_elements, sizeof (gint32));
2285 mate_panel_applet_set_size_hints (applet, size_hints, n_elements, 0);
2286 } else if (g_strcmp0 (property_name, "Locked") == 0) {
2287 mate_panel_applet_set_locked (applet, g_variant_get_boolean (value));
2288 } else if (g_strcmp0 (property_name, "LockedDown") == 0) {
2289 mate_panel_applet_set_locked_down (applet, g_variant_get_boolean (value));
2290 }
2291
2292 return TRUE(!(0));
2293}
2294
2295static const gchar introspection_xml[] =
2296 "<node>"
2297 "<interface name='org.mate.panel.applet.Applet'>"
2298 "<method name='PopupMenu'>"
2299 "<arg name='button' type='u' direction='in'/>"
2300 "<arg name='time' type='u' direction='in'/>"
2301 "</method>"
2302 "<property name='PrefsPath' type='s' access='readwrite'/>"
2303 "<property name='Orient' type='u' access='readwrite' />"
2304 "<property name='Size' type='u' access='readwrite'/>"
2305 "<property name='Background' type='s' access='readwrite'/>"
2306 "<property name='Flags' type='u' access='readwrite'/>"
2307 "<property name='SizeHints' type='ai' access='readwrite'/>"
2308 "<property name='Locked' type='b' access='readwrite'/>"
2309 "<property name='LockedDown' type='b' access='readwrite'/>"
2310 "<signal name='Move' />"
2311 "<signal name='RemoveFromPanel' />"
2312 "<signal name='Lock' />"
2313 "<signal name='Unlock' />"
2314 "</interface>"
2315 "</node>";
2316
2317static const GDBusInterfaceVTable interface_vtable = {
2318 method_call_cb,
2319 get_property_cb,
2320 set_property_cb,
2321 { 0 }
2322};
2323
2324static GDBusNodeInfo *introspection_data = NULL((void*)0);
2325
2326static void
2327mate_panel_applet_register_object (MatePanelApplet *applet)
2328{
2329 MatePanelAppletPrivate *priv;
2330 GError *error = NULL((void*)0);
2331 static gint id = 0;
2332
2333 if (!introspection_data)
2334 introspection_data = g_dbus_node_info_new_for_xml (introspection_xml, NULL((void*)0));
2335
2336 priv = mate_panel_applet_get_instance_private (applet);
2337 priv->object_path = g_strdup_printf (MATE_PANEL_APPLET_OBJECT_PATH"/org/mate/panel/applet/%s/%d", priv->id, id++);
2338 priv->object_id =
2339 g_dbus_connection_register_object (priv->connection,
2340 priv->object_path,
2341 introspection_data->interfaces[0],
2342 &interface_vtable,
2343 applet, NULL((void*)0),
2344 &error);
2345 if (!priv->object_id) {
2346 g_printerr ("Failed to register object %s: %s\n", priv->object_path, error->message);
2347 g_error_free (error);
2348 }
2349}
2350
2351static void mate_panel_applet_factory_main_finalized(gpointer data, GObject* object)
2352{
2353 gtk_main_quit();
2354
2355 if (introspection_data)
2356 {
2357 g_dbus_node_info_unref(introspection_data);
2358 introspection_data = NULL((void*)0);
2359 }
2360}
2361
2362#ifdef HAVE_X111
2363static int (*_x_error_func) (Display *, XErrorEvent *);
2364
2365static int
2366_x_error_handler (Display *display, XErrorEvent *error)
2367{
2368 if (!error->error_code)
2369 return 0;
2370
2371 /* If we got a BadDrawable or a BadWindow, we ignore it for now.
2372 * FIXME: We need to somehow distinguish real errors from
2373 * X-server-induced errors. Keeping a list of windows for which we
2374 * will ignore BadDrawables would be a good idea. */
2375 if (error->error_code == BadDrawable9 ||
2376 error->error_code == BadWindow3)
2377 return 0;
2378
2379 return _x_error_func (display, error);
2380}
2381
2382/*
2383 * To do graphical embedding in the X window system, MATE Panel
2384 * uses the classic foreign-window-reparenting trick. The
2385 * GtkPlug/GtkSocket widgets are used for this purpose. However,
2386 * serious robustness problems arise if the GtkSocket end of the
2387 * connection unexpectedly dies. The X server sends out DestroyNotify
2388 * events for the descendants of the GtkPlug (i.e., your embedded
2389 * component's windows) in effectively random order. Furthermore, if
2390 * you happened to be drawing on any of those windows when the
2391 * GtkSocket was destroyed (a common state of affairs), an X error
2392 * will kill your application.
2393 *
2394 * To solve this latter problem, MATE Panel sets up its own X error
2395 * handler which ignores certain X errors that might have been
2396 * caused by such a scenario. Other X errors get passed to gdk_x_error
2397 * normally.
2398 */
2399static void
2400_mate_panel_applet_setup_x_error_handler (void)
2401{
2402 static gboolean error_handler_setup = FALSE(0);
2403
2404 if (error_handler_setup)
2405 return;
2406
2407 error_handler_setup = TRUE(!(0));
2408
2409 _x_error_func = XSetErrorHandler (_x_error_handler);
2410}
2411#endif
2412
2413static int
2414_mate_panel_applet_factory_main_internal (const gchar *factory_id,
2415 gboolean out_process,
2416 GType applet_type,
2417 MatePanelAppletFactoryCallback callback,
2418 gpointer user_data)
2419{
2420 MatePanelAppletFactory* factory;
2421 GClosure* closure;
2422
2423 g_return_val_if_fail(factory_id != NULL, 1)do { if ((factory_id != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "factory_id != NULL"
); return (1); } } while (0)
;
2424 g_return_val_if_fail(callback != NULL, 1)do { if ((callback != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "callback != NULL"
); return (1); } } while (0)
;
2425 g_assert(g_type_is_a(applet_type, PANEL_TYPE_APPLET))do { if (((applet_type) == (mate_panel_applet_get_type ()) ||
(g_type_is_a) ((applet_type), (mate_panel_applet_get_type ()
)))) ; else g_assertion_message_expr (((gchar*) 0), "mate-panel-applet.c"
, 2425, ((const char*) (__func__)), "g_type_is_a(applet_type, PANEL_TYPE_APPLET)"
); } while (0)
;
2426
2427#ifdef HAVE_X111
2428 if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gdk_display_get_default ())); GType __t = ((gdk_x11_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
) {
2429 /*Use this both in and out of process as the tray applet always uses GtkSocket
2430 *to handle GtkStatusIcons whether the tray itself is built in or out of process
2431 */
2432 _mate_panel_applet_setup_x_error_handler();
2433 } else
2434#endif
2435 { /* not using X11 */
2436 if (out_process) {
2437 g_warning("Requested out-of-process applet, which is only supported on X11");
2438 return 1;
2439 }
2440 }
2441
2442 closure = g_cclosure_new(G_CALLBACK(callback)((GCallback) (callback)), user_data, NULL((void*)0));
2443 factory = mate_panel_applet_factory_new(factory_id, out_process, applet_type, closure);
2444 g_closure_unref(closure);
2445
2446 if (mate_panel_applet_factory_register_service(factory))
2447 {
2448 if (out_process)
2449 {
2450 g_object_weak_ref(G_OBJECT(factory)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((factory)), (((GType) ((20) << (2))))))))
, mate_panel_applet_factory_main_finalized, NULL((void*)0));
2451 gtk_main();
2452 }
2453
2454 return 0;
2455 }
2456
2457 g_object_unref (factory);
2458
2459 return 1;
2460}
2461
2462/**
2463 * mate_panel_applet_factory_main:
2464 * @out_process: boolean, dummy to support applets sending it
2465 * @factory_id: Factory ID.
2466 * @applet_type: GType of the applet this factory creates.
2467 * @callback: (scope call): Callback to be called when a new applet is to be created.
2468 * @data: (closure): Callback data.
2469 *
2470 * Returns: 0 on success, 1 if there is an error.
2471 */
2472int
2473mate_panel_applet_factory_main (const gchar *factory_id,
2474 gboolean out_process, /*Dummy to support applets w issues with this */
2475 GType applet_type,
2476 MatePanelAppletFactoryCallback callback,
2477 gpointer user_data)
2478{
2479 return _mate_panel_applet_factory_main_internal (factory_id, TRUE(!(0)), applet_type,
2480 callback, user_data);
2481}
2482
2483/**
2484 * mate_panel_applet_factory_setup_in_process: (skip)
2485 * @factory_id: Factory ID.
2486 * @applet_type: GType of the applet this factory creates.
2487 * @callback: (scope call): Callback to be called when a new applet is to be created.
2488 * @data: (closure): Callback data.
2489 *
2490 * Returns: 0 on success, 1 if there is an error.
2491 */
2492int
2493mate_panel_applet_factory_setup_in_process (const gchar *factory_id,
2494 GType applet_type,
2495 MatePanelAppletFactoryCallback callback,
2496 gpointer user_data)
2497{
2498 return _mate_panel_applet_factory_main_internal (factory_id, FALSE(0), applet_type,
2499 callback, user_data);
2500}
2501
2502/**
2503 * mate_panel_applet_set_background_widget:
2504 * @applet: a #PanelApplet.
2505 * @widget: a #GtkWidget.
2506 *
2507 * Configure #PanelApplet to automatically draw the background of the applet on
2508 * @widget. It is generally enough to call this function with @applet as
2509 * @widget.
2510 *
2511 * Deprecated: 3.20: Do not use this API. Since 3.20 this function does nothing.
2512 **/
2513
2514void
2515mate_panel_applet_set_background_widget (MatePanelApplet *applet,
2516 GtkWidget *widget)
2517{
2518}
2519
2520guint32
2521mate_panel_applet_get_xid (MatePanelApplet *applet,
2522 GdkScreen *screen)
2523{
2524 MatePanelAppletPrivate *priv;
2525
2526 priv = mate_panel_applet_get_instance_private (applet);
2527
2528 /* out_of_process should only be true on X11, so an extra runtime Wayland check is not needed */
2529 if (priv->out_of_process == FALSE(0))
2530 return 0;
2531
2532#ifdef HAVE_X111
2533 gtk_window_set_screen (GTK_WINDOW (priv->plug)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->plug)), ((gtk_window_get_type ()))))))
, screen);
2534 gtk_widget_show (priv->plug);
2535
2536 return gtk_plug_get_id (GTK_PLUG (priv->plug)((((GtkPlug*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->plug)), ((gtk_plug_get_type ()))))))
);
2537#else
2538 return 0;
2539#endif
2540}
2541
2542const gchar *
2543mate_panel_applet_get_object_path (MatePanelApplet *applet)
2544{
2545 MatePanelAppletPrivate *priv;
2546
2547 priv = mate_panel_applet_get_instance_private (applet);
2548
2549 return priv->object_path;
2550}
2551
2552G_MODULE_EXPORT__attribute__((visibility("default"))) GtkWidget *
2553mate_panel_applet_get_applet_widget (const gchar *factory_id,
2554 guint uid)
2555{
2556 GtkWidget *widget;
2557
2558 widget = mate_panel_applet_factory_get_applet_widget (factory_id, uid);
2559 if (!widget) {
2560 return NULL((void*)0);
2561 }
2562
2563 mate_panel_applet_setup (MATE_PANEL_APPLET (widget));
2564
2565 return widget;
2566}
diff --git a/2024-06-18-172109-13286-1@e182420b844f_master/report-d1a39f.html b/2024-06-18-172109-13286-1@e182420b844f_master/report-d1a39f.html new file mode 100644 index 00000000..9f115083 --- /dev/null +++ b/2024-06-18-172109-13286-1@e182420b844f_master/report-d1a39f.html @@ -0,0 +1,1375 @@ + + + +panel-multimonitor.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:mate-panel/panel-multimonitor.c
Warning:line 211, column 20
Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name panel-multimonitor.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/mate-panel -fcoverage-compilation-dir=/rootdir/mate-panel -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I .. -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/startup-notification-1.0 -I /usr/include/mate-menus -I /usr/include/gio-unix-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/dconf -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/dconf -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I . -I . -I ../mate-panel -I ../mate-panel/mate-submodules -I ../mate-panel/libpanel-util -D MATELOCALEDIR="/usr/local/share/locale" -D PANELDATADIR="/usr/local/share/mate-panel" -I /usr/include/gtk-layer-shell -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/gtk-3.0 -I /usr/include/cloudproviders -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/atk-1.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/gio-unix-2.0 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -D PANEL_MODULES_DIR="/usr/local/lib/mate-panel/modules" -D MATEMENU_I_KNOW_THIS_IS_UNSTABLE -I /usr/include/gtk-layer-shell -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/gtk-3.0 -I /usr/include/cloudproviders -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/atk-1.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/gio-unix-2.0 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-18-172109-13286-1 -x c panel-multimonitor.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * panel-multimonitor.c: Multi-monitor and Xinerama support for the panel.
3 *
4 * Copyright (C) 2001 George Lebl <jirka@5z.com>
5 * 2002 Sun Microsystems Inc.
6 * Copyright (C) 2012-2021 MATE Developers
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of the
11 * License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
21 * USA
22 *
23 * Authors: George Lebl <jirka@5z.com>,
24 * Mark McLoughlin <mark@skynet.ie>
25 */
26
27#include <config.h>
28
29#ifdef HAVE_X111
30#include <X11/Xatom.h>
31#include <X11/Xlib.h>
32#include <X11/extensions/Xrandr.h>
33#include <gdk/gdkx.h>
34#endif /* HAVE_X11 */
35
36#include "panel-multimonitor.h"
37
38#include <string.h>
39
40/*
41 * The number of logical monitors we are keeping track of
42 * May be different than gdk_display_get_n_monitors()
43 * (see comment in panel_multimonitor_compress_overlapping_monitors for details)
44 */
45static int monitor_count = 0;
46
47/*
48 * A dynamically allocated array of monitor geometries
49 * monitor_count is the length
50 */
51static GdkRectangle *geometries = NULL((void*)0);
52
53static gboolean initialized = FALSE(0);
54static gboolean have_randr = FALSE(0);
55static guint reinit_id = 0;
56
57#ifdef HAVE_X111
58#ifdef HAVE_RANDR1
59static gboolean
60_panel_multimonitor_output_should_be_first (Display *xdisplay,
61 RROutput output,
62 XRROutputInfo *info,
63 RROutput primary)
64{
65 if (primary)
66 return output == primary;
67
68 Atom connector_type_atom;
69 Atom actual_type;
70 int actual_format;
71 unsigned long nitems;
72 unsigned long bytes_after;
73 unsigned char *prop;
74
75 connector_type_atom = XInternAtom (xdisplay, "ConnectorType", False0);
76
77 if (XRRGetOutputProperty (xdisplay, output, connector_type_atom,
78 0, 100, False0, False0, None0L,
79 &actual_type, &actual_format,
80 &nitems, &bytes_after, &prop) == Success0) {
81 if (actual_type == XA_ATOM((Atom) 4) && nitems == 1 && actual_format == 32) {
82 char *connector_type = XGetAtomName (xdisplay, prop[0]);
83 gboolean retval = g_strcmp0 (connector_type, "Panel") == 0;
84 XFree (connector_type);
85 return retval;
86 }
87 }
88
89 /* Fallback (see https://bugs.freedesktop.org/show_bug.cgi?id=26736)
90 * "LVDS" is the oh-so-intuitive name that X gives to laptop LCDs.
91 * It can actually be LVDS0, LVDS-0, Lvds, etc.
92 */
93 return (g_ascii_strncasecmp (info->name, "LVDS", strlen ("LVDS")) == 0);
94}
95
96static gboolean
97panel_multimonitor_get_randr_monitors (int *monitors_ret,
98 GdkRectangle **geometries_ret)
99{
100 GdkDisplay *display;
101 GdkScreen *screen;
102 GdkMonitor *monitor;
103 Display *xdisplay;
104 Window xroot;
105 XRRScreenResources *resources;
106 RROutput primary;
107 GArray *geometries_array;
108 int scale;
109 int i;
110
111 display = gdk_display_get_default ();
112
113 g_return_val_if_fail (have_randr, FALSE)do { if ((have_randr)) { } else { g_return_if_fail_warning ((
(gchar*) 0), ((const char*) (__func__)), "have_randr"); return
((0)); } } while (0)
;
114 g_return_val_if_fail (GDK_IS_X11_DISPLAY (display), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((display)); GType __t = ((gdk_x11_display_get_type())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "GDK_IS_X11_DISPLAY (display)"); return ((0));
} } while (0)
;
115
116 /* GTK+ 2.14.x uses the Xinerama API, instead of RANDR, to get the
117 * monitor geometries. It does this to avoid calling
118 * XRRGetScreenResources(), which is slow as it re-detects all the
119 * monitors --- note that XRRGetScreenResourcesCurrent() had not been
120 * introduced yet. Using Xinerama in GTK+ has the bad side effect that
121 * gdk_screen_get_monitor_plug_name() will return NULL, as Xinerama
122 * does not provide that information, unlike RANDR.
123 *
124 * Here we need to identify the output names, so that we can put the
125 * built-in LCD in a laptop *before* all other outputs. This is so
126 * that mate-panel will normally prefer to appear on the "native"
127 * display rather than on an external monitor.
128 *
129 * To get the output names and geometries, we will not use
130 * gdk_screen_get_n_monitors() and friends, but rather we will call
131 * XRR*() directly.
132 *
133 * See https://bugzilla.novell.com/show_bug.cgi?id=479684 for this
134 * particular bug, and and
135 * http://bugzilla.gnome.org/show_bug.cgi?id=562944 for a more
136 * long-term solution.
137 */
138 screen = gdk_display_get_default_screen (display);
139 xdisplay = GDK_SCREEN_XDISPLAY (screen)(gdk_x11_display_get_xdisplay (gdk_screen_get_display (screen
)))
;
140 xroot = GDK_WINDOW_XID (gdk_screen_get_root_window (screen))(gdk_x11_window_get_xid (gdk_screen_get_root_window (screen))
)
;
141
142 resources = XRRGetScreenResourcesCurrent (xdisplay, xroot);
143 if (resources->noutput == 0) {
144 /* This might happen if nothing tried to get randr
145 * resources from the server before, so we need an
146 * active probe. See comment #27 in
147 * https://bugzilla.gnome.org/show_bug.cgi?id=597101 */
148 XRRFreeScreenResources (resources);
149 resources = XRRGetScreenResources (xdisplay, xroot);
150 }
151
152 if (!resources)
153 return FALSE(0);
154
155 primary = XRRGetOutputPrimary (xdisplay, xroot);
156 monitor = gdk_display_get_primary_monitor (display);
157
158 /* Use scale factor to bring geometries down to device pixels to support HiDPI displays */
159 scale = gdk_monitor_get_scale_factor (monitor);
160
161 geometries_array = g_array_sized_new (FALSE(0), FALSE(0),
162 sizeof (GdkRectangle),
163 resources->noutput);
164
165 for (i = 0; i < resources->noutput; i++) {
166 XRROutputInfo *output;
167
168 output = XRRGetOutputInfo (xdisplay, resources,
169 resources->outputs[i]);
170
171 if (output->connection != RR_Disconnected1 &&
172 output->crtc != 0) {
173 XRRCrtcInfo *crtc;
174 GdkRectangle rect;
175
176 crtc = XRRGetCrtcInfo (xdisplay, resources,
177 output->crtc);
178
179 rect.x = crtc->x / scale;
180 rect.y = crtc->y / scale;
181 rect.width = crtc->width / scale;
182 rect.height = crtc->height / scale;
183
184 XRRFreeCrtcInfo (crtc);
185
186 if (_panel_multimonitor_output_should_be_first (xdisplay,
187 resources->outputs[i],
188 output, primary))
189 g_array_prepend_vals (geometries_array, &rect, 1);
190 else
191 g_array_append_vals (geometries_array, &rect, 1);
192 }
193
194 XRRFreeOutputInfo (output);
195 }
196
197 XRRFreeScreenResources (resources);
198
199 if (geometries_array->len == 0) {
200 /* This can happen in at least one case:
201 * https://bugzilla.novell.com/show_bug.cgi?id=543876 where all
202 * monitors appear disconnected (possibly because the screen
203 * is behing a KVM switch) -- see comment #8.
204 * There might be other cases too, so we stay on the safe side.
205 */
206 g_array_free (geometries_array, TRUE(!(0)));
207 return FALSE(0);
208 }
209
210 *monitors_ret = geometries_array->len;
211 *geometries_ret = (GdkRectangle *) g_array_free (geometries_array, FALSE(0));
Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption
212
213 return TRUE(!(0));
214}
215#endif /* HAVE_RANDR */
216#endif /* HAVE_X11 */
217
218static void
219panel_multimonitor_get_gdk_monitors (int *monitors_ret,
220 GdkRectangle **geometries_ret)
221{
222 GdkDisplay *display;
223 int num_monitors;
224 GdkRectangle *geometries_array;
225 int i;
226
227 display = gdk_display_get_default ();
228 num_monitors = gdk_display_get_n_monitors (display);
229 geometries_array = g_new (GdkRectangle, num_monitors)((GdkRectangle *) g_malloc_n ((num_monitors), sizeof (GdkRectangle
)))
;
230
231 for (i = 0; i < num_monitors; i++)
232 gdk_monitor_get_geometry (gdk_display_get_monitor (display, i), &(geometries_array[i]));
233
234 *monitors_ret = num_monitors;
235 *geometries_ret = geometries_array;
236}
237
238static void
239panel_multimonitor_get_raw_monitors (int *monitors_ret,
240 GdkRectangle **geometries_ret)
241{
242 *monitors_ret = 0;
243 *geometries_ret = NULL((void*)0);
244
245#ifdef HAVE_X111
246#ifdef HAVE_RANDR1
247 if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gdk_display_get_default ())); GType __t = ((gdk_x11_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
&& have_randr)
248 {
249 gboolean res;
250
251 res = panel_multimonitor_get_randr_monitors (monitors_ret,
252 geometries_ret);
253 if (res && *monitors_ret > 0)
254 return;
255 }
256#endif /* HAVE_RANDR */
257#endif /* HAVE_X11 */
258
259 panel_multimonitor_get_gdk_monitors (monitors_ret, geometries_ret);
260}
261
262static inline gboolean
263rectangle_overlaps (GdkRectangle *a,
264 GdkRectangle *b)
265{
266 return gdk_rectangle_intersect (a, b, NULL((void*)0));
267}
268
269static long
270pixels_in_rectangle (GdkRectangle *r)
271{
272 return (long) (r->width * r->height);
273}
274
275static void
276panel_multimonitor_compress_overlapping_monitors (int *num_monitors_inout,
277 GdkRectangle **geometries_inout)
278{
279 int num_monitors;
280 GdkRectangle *geometries_array;
281 int i;
282
283 num_monitors = *num_monitors_inout;
284 geometries_array = *geometries_inout;
285
286 /* http://bugzilla.gnome.org/show_bug.cgi?id=530969
287 * https://bugzilla.novell.com/show_bug.cgi?id=310208
288 * and many other such bugs...
289 *
290 * RANDR sometimes gives us monitors that overlap (i.e. outputs whose
291 * bounding rectangles overlap). This is sometimes right and sometimes
292 * wrong:
293 *
294 * * Right - two 1024x768 outputs at the same offset (0, 0) that show
295 * the same thing. Think "laptop plus projector with the same
296 * resolution".
297 *
298 * * Wrong - one 1280x1024 output ("laptop internal LCD") and another
299 * 1024x768 output ("external monitor"), both at offset (0, 0).
300 * There is no way for the monitor with the small resolution to
301 * show the complete image from the laptop's LCD, unless one uses
302 * panning (but nobody wants panning, right!?).
303 *
304 * With overlapping monitors, we may end up placing the panel with
305 * respect to the "wrong" one. This is always wrong, as the panel
306 * appears "in the middle of the screen" of the monitor with the
307 * smaller resolution, instead of at the edge.
308 *
309 * Our strategy is to find the subsets of overlapping monitors, and
310 * "compress" each such set to being like if there were a single
311 * monitor with the biggest resolution of each of that set's monitors.
312 * Say we have four monitors
313 *
314 * A, B, C, D
315 *
316 * where B and D overlap. In that case, we'll generate a new list that
317 * looks like
318 *
319 * A, MAX(B, D), C
320 *
321 * with three monitors.
322 *
323 * NOTE FOR THE FUTURE: We could avoid most of this mess if we had a
324 * concept of a "primary monitor". Also, we could look at each
325 * output's name or properties to see if it is the built-in LCD in a
326 * laptop. However, with GTK+ 2.14.x we don't get output names, since
327 * it gets the list outputs from Xinerama, not RANDR (and Xinerama
328 * doesn't provide output names).
329 */
330
331 for (i = 0; i < num_monitors; i++) {
332 long max_pixels;
333 int j;
334
335 max_pixels = pixels_in_rectangle (&geometries_array[i]);
336
337 j = i + 1;
338
339 while (j < num_monitors) {
340 if (rectangle_overlaps (&geometries_array[i],
341 &geometries_array[j])) {
342 long pixels;
343
344 pixels = pixels_in_rectangle (&geometries_array[j]);
345 if (pixels > max_pixels) {
346 max_pixels = pixels;
347 /* keep the maximum */
348 geometries_array[i] = geometries_array[j];
349 }
350
351 /* Shift the remaining monitors to the left */
352 if (num_monitors - j - 1 > 0)
353 memmove (&geometries_array[j],
354 &geometries_array[j + 1],
355 sizeof (geometries_array[0]) * (num_monitors - j - 1));
356
357 num_monitors--;
358 g_assert (num_monitors > 0)do { if (num_monitors > 0) ; else g_assertion_message_expr
(((gchar*) 0), "panel-multimonitor.c", 358, ((const char*) (
__func__)), "num_monitors > 0"); } while (0)
;
359 } else
360 j++;
361 }
362 }
363
364 *num_monitors_inout = num_monitors;
365 *geometries_inout = geometries_array;
366}
367
368static gboolean
369panel_multimonitor_reinit_idle (gpointer data)
370{
371 panel_multimonitor_reinit ();
372 reinit_id = 0;
373
374 return FALSE(0);
375}
376
377static void
378panel_multimonitor_handle_screen_changed (GdkScreen *screen,
379 gpointer user_data)
380{
381 if (reinit_id)
382 return;
383
384 reinit_id = g_idle_add (panel_multimonitor_reinit_idle, NULL((void*)0));
385}
386
387static void
388panel_multimonitor_handle_monitor_changed (GdkDisplay *display,
389 GdkMonitor *monitor,
390 gpointer user_data)
391{
392 if (reinit_id)
393 return;
394
395 reinit_id = g_idle_add (panel_multimonitor_reinit_idle, NULL((void*)0));
396}
397
398static void
399panel_multimonitor_handle_monitor_invalidate (GdkMonitor *monitor,
400 gpointer user_data)
401{
402 if (reinit_id)
403 return;
404
405 reinit_id = g_idle_add (panel_multimonitor_reinit_idle, NULL((void*)0));
406}
407
408#ifdef HAVE_X111
409#ifdef HAVE_RANDR1
410static void
411panel_multimonitor_init_randr (GdkDisplay *display)
412{
413 Display *xdisplay;
414 int event_base, error_base;
415
416 g_return_if_fail (GDK_IS_X11_DISPLAY (display))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((display)); GType __t = ((gdk_x11_display_get_type())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "GDK_IS_X11_DISPLAY (display)"); return; } } while
(0)
;
417
418 have_randr = FALSE(0);
419
420 if (!GDK_IS_X11_DISPLAY (display)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(display)); GType __t = ((gdk_x11_display_get_type())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
)
421 return;
422
423 xdisplay = GDK_DISPLAY_XDISPLAY (display)(gdk_x11_display_get_xdisplay (display));
424
425 /* We don't remember the event/error bases, as we expect to get monitor
426 * added/removed events from the display instead.
427 */
428
429 if (XRRQueryExtension (xdisplay, &event_base, &error_base)) {
430 int major, minor;
431
432 XRRQueryVersion (xdisplay, &major, &minor);
433 if ((major == 1 && minor >= 3) || major > 1)
434 have_randr = TRUE(!(0));
435 }
436}
437#endif /* HAVE_RANDR */
438#endif /* HAVE_X11 */
439
440void
441panel_multimonitor_init (void)
442{
443 GdkDisplay *display;
444 GdkScreen *screen;
445 int i;
446
447 if (initialized)
448 return;
449
450 display = gdk_display_get_default ();
451 screen = gdk_display_get_default_screen (display);
452
453 have_randr = FALSE(0);
454
455#ifdef HAVE_X111
456#ifdef HAVE_RANDR1
457 if (GDK_IS_X11_DISPLAY (display)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(display)); GType __t = ((gdk_x11_display_get_type())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
)
458 panel_multimonitor_init_randr (display);
459#endif /* HAVE_RANDR */
460#endif /* HAVE_X11 */
461
462 /*
463 * The screen signals probably shouldn't be needed, but sometimes on X11 they are
464 * the only ones that get fired
465 */
466
467 g_signal_handlers_disconnect_by_func (screen, panel_multimonitor_handle_screen_changed, NULL)g_signal_handlers_disconnect_matched ((screen), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (panel_multimonitor_handle_screen_changed), (((void*)0)))
;
468 g_signal_connect (screen, "size-changed",g_signal_connect_data ((screen), ("size-changed"), (((GCallback
) (panel_multimonitor_handle_screen_changed))), (((void*)0)),
((void*)0), (GConnectFlags) 0)
469 G_CALLBACK (panel_multimonitor_handle_screen_changed), NULL)g_signal_connect_data ((screen), ("size-changed"), (((GCallback
) (panel_multimonitor_handle_screen_changed))), (((void*)0)),
((void*)0), (GConnectFlags) 0)
;
470 g_signal_connect (screen, "monitors-changed",g_signal_connect_data ((screen), ("monitors-changed"), (((GCallback
) (panel_multimonitor_handle_screen_changed))), (((void*)0)),
((void*)0), (GConnectFlags) 0)
471 G_CALLBACK (panel_multimonitor_handle_screen_changed), NULL)g_signal_connect_data ((screen), ("monitors-changed"), (((GCallback
) (panel_multimonitor_handle_screen_changed))), (((void*)0)),
((void*)0), (GConnectFlags) 0)
;
472
473 g_signal_handlers_disconnect_by_func (display, panel_multimonitor_handle_monitor_changed, NULL)g_signal_handlers_disconnect_matched ((display), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (panel_multimonitor_handle_monitor_changed), (((void*)0))
)
;
474 g_signal_connect (display, "monitor-added",g_signal_connect_data ((display), ("monitor-added"), (((GCallback
) (panel_multimonitor_handle_monitor_changed))), (((void*)0))
, ((void*)0), (GConnectFlags) 0)
475 G_CALLBACK (panel_multimonitor_handle_monitor_changed), NULL)g_signal_connect_data ((display), ("monitor-added"), (((GCallback
) (panel_multimonitor_handle_monitor_changed))), (((void*)0))
, ((void*)0), (GConnectFlags) 0)
;
476 g_signal_connect (display, "monitor-removed",g_signal_connect_data ((display), ("monitor-removed"), (((GCallback
) (panel_multimonitor_handle_monitor_changed))), (((void*)0))
, ((void*)0), (GConnectFlags) 0)
477 G_CALLBACK (panel_multimonitor_handle_monitor_changed), NULL)g_signal_connect_data ((display), ("monitor-removed"), (((GCallback
) (panel_multimonitor_handle_monitor_changed))), (((void*)0))
, ((void*)0), (GConnectFlags) 0)
;
478
479 for (i = 0; i < gdk_display_get_n_monitors (display); i++) {
480 GdkMonitor *monitor;
481
482 monitor = gdk_display_get_monitor (display, i);
483 g_signal_handlers_disconnect_by_func (display, panel_multimonitor_handle_monitor_invalidate, NULL)g_signal_handlers_disconnect_matched ((display), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (panel_multimonitor_handle_monitor_invalidate), (((void*)
0)))
;
484 g_signal_connect (monitor, "invalidate",g_signal_connect_data ((monitor), ("invalidate"), (((GCallback
) (panel_multimonitor_handle_monitor_invalidate))), (((void*)
0)), ((void*)0), (GConnectFlags) 0)
485 G_CALLBACK (panel_multimonitor_handle_monitor_invalidate), NULL)g_signal_connect_data ((monitor), ("invalidate"), (((GCallback
) (panel_multimonitor_handle_monitor_invalidate))), (((void*)
0)), ((void*)0), (GConnectFlags) 0)
;
486 }
487
488 panel_multimonitor_get_raw_monitors (&monitor_count, &geometries);
489 panel_multimonitor_compress_overlapping_monitors (&monitor_count, &geometries);
490
491 initialized = TRUE(!(0));
492}
493
494void
495panel_multimonitor_reinit (void)
496{
497 GList *toplevels, *l;
498
499 if (geometries)
500 g_free (geometries);
501
502 initialized = FALSE(0);
503 panel_multimonitor_init ();
504
505 toplevels = gtk_window_list_toplevels ();
506
507 for (l = toplevels; l; l = l->next)
508 gtk_widget_queue_resize (l->data);
509
510 g_list_free (toplevels);
511}
512
513int
514panel_multimonitor_monitors ()
515{
516 return monitor_count;
517}
518
519int
520panel_multimonitor_x (int monitor)
521{
522 g_return_val_if_fail (monitor >= 0 && monitor < monitor_count, 0)do { if ((monitor >= 0 && monitor < monitor_count
)) { } else { g_return_if_fail_warning (((gchar*) 0), ((const
char*) (__func__)), "monitor >= 0 && monitor < monitor_count"
); return (0); } } while (0)
;
523 return geometries [monitor].x;
524}
525
526int
527panel_multimonitor_y (int monitor)
528{
529 g_return_val_if_fail (monitor >= 0 && monitor < monitor_count, 0)do { if ((monitor >= 0 && monitor < monitor_count
)) { } else { g_return_if_fail_warning (((gchar*) 0), ((const
char*) (__func__)), "monitor >= 0 && monitor < monitor_count"
); return (0); } } while (0)
;
530 return geometries [monitor].y;
531}
532
533int
534panel_multimonitor_width (int monitor)
535{
536 g_return_val_if_fail (monitor >= 0 && monitor < monitor_count, 0)do { if ((monitor >= 0 && monitor < monitor_count
)) { } else { g_return_if_fail_warning (((gchar*) 0), ((const
char*) (__func__)), "monitor >= 0 && monitor < monitor_count"
); return (0); } } while (0)
;
537 return geometries [monitor].width;
538}
539
540int
541panel_multimonitor_height (int monitor)
542{
543 g_return_val_if_fail (monitor >= 0 && monitor < monitor_count, 0)do { if ((monitor >= 0 && monitor < monitor_count
)) { } else { g_return_if_fail_warning (((gchar*) 0), ((const
char*) (__func__)), "monitor >= 0 && monitor < monitor_count"
); return (0); } } while (0)
;
544 return geometries [monitor].height;
545}
546
547int
548panel_multimonitor_locate_widget_monitor (GtkWidget *widget)
549{
550 GtkWidget *toplevel;
551 int retval = -1;
552
553 toplevel = gtk_widget_get_toplevel (widget);
554 if (!toplevel)
555 return -1;
556
557 g_object_get (toplevel, "monitor", &retval, NULL((void*)0));
558
559 return retval;
560}
561
562static int
563axis_distance (int p, int axis_start, int axis_size)
564{
565 if (p >= axis_start && p < axis_start + axis_size)
566 return 0;
567 else if (p < axis_start)
568 return (axis_start - p);
569 else
570 return (p - (axis_start + axis_size - 1));
571}
572
573/* The panel can't use gdk_screen_get_monitor_at_point() since it has its own
574 * view of which monitors are present. Look at get_monitors_for_screen() above
575 * to see why. */
576int
577panel_multimonitor_get_monitor_at_point (int x, int y)
578{
579 int i;
580 int min_dist_squared;
581 int closest_monitor;
582
583 min_dist_squared = G_MAXINT32((gint32) 0x7fffffff);
584 closest_monitor = 0;
585
586 for (i = 0; i < monitor_count; i++) {
587 int dist_x, dist_y;
588 int dist_squared;
589
590 dist_x = axis_distance (x, geometries[i].x, geometries[i].width);
591 dist_y = axis_distance (y, geometries[i].y, geometries[i].height);
592
593 if (dist_x == 0 && dist_y == 0)
594 return i;
595
596 dist_squared = dist_x * dist_x + dist_y * dist_y;
597
598 if (dist_squared < min_dist_squared) {
599 min_dist_squared = dist_squared;
600 closest_monitor = i;
601 }
602 }
603
604 return closest_monitor;
605}
606
607typedef struct {
608 int x0;
609 int y0;
610 int x1;
611 int y1;
612} MonitorBounds;
613
614static inline void
615get_monitor_bounds (int n_monitor,
616 MonitorBounds *bounds)
617{
618 g_return_if_fail (n_monitor >= 0 || n_monitor < monitor_count)do { if ((n_monitor >= 0 || n_monitor < monitor_count))
{ } else { g_return_if_fail_warning (((gchar*) 0), ((const char
*) (__func__)), "n_monitor >= 0 || n_monitor < monitor_count"
); return; } } while (0)
;
619 g_return_if_fail (bounds != NULL)do { if ((bounds != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "bounds != NULL")
; return; } } while (0)
;
620
621 bounds->x0 = geometries [n_monitor].x;
622 bounds->y0 = geometries [n_monitor].y;
623 bounds->x1 = bounds->x0 + geometries [n_monitor].width;
624 bounds->y1 = bounds->y0 + geometries [n_monitor].height;
625}
626
627/* determines whether a given monitor is along the visible
628 * edge of the logical screen.
629 */
630void
631panel_multimonitor_is_at_visible_extreme (int n_monitor,
632 gboolean *leftmost,
633 gboolean *rightmost,
634 gboolean *topmost,
635 gboolean *bottommost)
636{
637 MonitorBounds monitor;
638 int i;
639
640 *leftmost = TRUE(!(0));
641 *rightmost = TRUE(!(0));
642 *topmost = TRUE(!(0));
643 *bottommost = TRUE(!(0));
644
645 g_return_if_fail (n_monitor >= 0 && n_monitor < monitor_count)do { if ((n_monitor >= 0 && n_monitor < monitor_count
)) { } else { g_return_if_fail_warning (((gchar*) 0), ((const
char*) (__func__)), "n_monitor >= 0 && n_monitor < monitor_count"
); return; } } while (0)
;
646
647 get_monitor_bounds (n_monitor, &monitor);
648
649 /* go through each monitor and try to find one either right,
650 * below, above, or left of the specified monitor
651 */
652
653 for (i = 0; i < monitor_count; i++) {
654 MonitorBounds iter;
655
656 if (i == n_monitor) continue;
657
658 get_monitor_bounds (i, &iter);
659
660 if ((iter.y0 >= monitor.y0 && iter.y0 < monitor.y1) ||
661 (iter.y1 > monitor.y0 && iter.y1 <= monitor.y1)) {
662 if (iter.x0 < monitor.x0)
663 *leftmost = FALSE(0);
664 if (iter.x1 > monitor.x1)
665 *rightmost = FALSE(0);
666 }
667
668 if ((iter.x0 >= monitor.x0 && iter.x0 < monitor.x1) ||
669 (iter.x1 > monitor.x0 && iter.x1 <= monitor.x1)) {
670 if (iter.y0 < monitor.y0)
671 *topmost = FALSE(0);
672 if (iter.y1 > monitor.y1)
673 *bottommost = FALSE(0);
674 }
675 }
676}
677
678void
679panel_multimonitor_get_bounds (GdkPoint *min,
680 GdkPoint *max)
681{
682 int i;
683
684 g_return_if_fail (monitor_count > 0)do { if ((monitor_count > 0)) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "monitor_count > 0"
); return; } } while (0)
;
685
686 min->x = min->y = G_MAXINT2147483647;
687 max->x = max->y = G_MININT(-2147483647 -1);
688
689 for (i = 0; i < monitor_count; i++) {
690 min->x = MIN (min->x, geometries[i].x)(((min->x) < (geometries[i].x)) ? (min->x) : (geometries
[i].x))
;
691 min->y = MIN (min->y, geometries[i].y)(((min->y) < (geometries[i].y)) ? (min->y) : (geometries
[i].y))
;
692 max->x = MAX (max->x, geometries[i].x + geometries[i].width)(((max->x) > (geometries[i].x + geometries[i].width)) ?
(max->x) : (geometries[i].x + geometries[i].width))
;
693 max->y = MAX (max->y, geometries[i].y + geometries[i].height)(((max->y) > (geometries[i].y + geometries[i].height)) ?
(max->y) : (geometries[i].y + geometries[i].height))
;
694 }
695}
diff --git a/2024-06-18-172109-13286-1@e182420b844f_master/report-d88d55.html b/2024-06-18-172109-13286-1@e182420b844f_master/report-d88d55.html new file mode 100644 index 00000000..a7912e33 --- /dev/null +++ b/2024-06-18-172109-13286-1@e182420b844f_master/report-d88d55.html @@ -0,0 +1,3246 @@ + + + +mate-panel-applet.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:libmate-panel-applet/mate-panel-applet.c
Warning:line 336, column 47
Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name mate-panel-applet.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/libmate-panel-applet -fcoverage-compilation-dir=/rootdir/libmate-panel-applet -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I .. -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/gio-unix-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I ../libmate-panel-applet -D MATELOCALEDIR="/usr/local/share/locale" -D PIC -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-18-172109-13286-1 -x c mate-panel-applet.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * mate-panel-applet.c: panel applet writing library.
3 *
4 * Copyright (c) 2010 Carlos Garcia Campos <carlosgc@gnome.org>
5 * Copyright (C) 2001 Sun Microsystems, Inc.
6 * Copyright (C) 2012-2021 MATE Developers
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
17 *
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the
20 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22 *
23 * Authors:
24 * Mark McLoughlin <mark@skynet.ie>
25 */
26
27#ifdef HAVE_CONFIG_H1
28#include <config.h>
29#endif
30
31#include <unistd.h>
32#include <stdlib.h>
33#include <string.h>
34
35#include <glib/gi18n-lib.h>
36#include <cairo.h>
37#include <gdk/gdk.h>
38#include <gdk/gdkkeysyms.h>
39#include <gtk/gtk.h>
40
41#ifdef HAVE_X111
42#include <cairo-xlib.h>
43#include <gdk/gdkx.h>
44#include <gtk/gtkx.h>
45#include <X11/Xatom.h>
46#include "panel-plug-private.h"
47#endif
48
49#include "mate-panel-applet.h"
50#include "panel-applet-private.h"
51#include "mate-panel-applet-factory.h"
52#include "mate-panel-applet-marshal.h"
53#include "mate-panel-applet-enums.h"
54
55typedef struct {
56 GtkWidget *plug;
57 GDBusConnection *connection;
58
59 gboolean out_of_process;
60
61 char *id;
62 GClosure *closure;
63 char *object_path;
64 guint object_id;
65 char *prefs_path;
66
67 GtkUIManager *ui_manager;
68 GtkActionGroup *applet_action_group;
69 GtkActionGroup *panel_action_group;
70
71 MatePanelAppletFlags flags;
72 MatePanelAppletOrient orient;
73 guint size;
74 char *background;
75
76 int previous_width;
77 int previous_height;
78
79 int *size_hints;
80 int size_hints_len;
81
82 gboolean moving_focus_out;
83
84 gboolean locked;
85 gboolean locked_down;
86} MatePanelAppletPrivate;
87
88enum {
89 CHANGE_ORIENT,
90 CHANGE_SIZE,
91 CHANGE_BACKGROUND,
92 MOVE_FOCUS_OUT_OF_APPLET,
93 LAST_SIGNAL
94};
95
96static guint mate_panel_applet_signals[LAST_SIGNAL] = { 0 };
97
98enum {
99 PROP_0,
100 PROP_OUT_OF_PROCESS,
101 PROP_ID,
102 PROP_CLOSURE,
103 PROP_CONNECTION,
104 PROP_PREFS_PATH,
105 PROP_ORIENT,
106 PROP_SIZE,
107 PROP_BACKGROUND,
108 PROP_FLAGS,
109 PROP_SIZE_HINTS,
110 PROP_LOCKED,
111 PROP_LOCKED_DOWN
112};
113
114static void mate_panel_applet_handle_background (MatePanelApplet *applet);
115static GtkAction *mate_panel_applet_menu_get_action (MatePanelApplet *applet,
116 const gchar *action);
117static void mate_panel_applet_menu_update_actions (MatePanelApplet *applet);
118static void mate_panel_applet_menu_cmd_remove (GtkAction *action,
119 MatePanelApplet *applet);
120static void mate_panel_applet_menu_cmd_move (GtkAction *action,
121 MatePanelApplet *applet);
122static void mate_panel_applet_menu_cmd_lock (GtkAction *action,
123 MatePanelApplet *applet);
124static void mate_panel_applet_register_object (MatePanelApplet *applet);
125void _mate_panel_applet_apply_css (GtkWidget* widget, MatePanelAppletBackgroundType type);
126
127static const gchar panel_menu_ui[] =
128 "<ui>\n"
129 " <popup name=\"MatePanelAppletPopup\" action=\"PopupAction\">\n"
130 " <placeholder name=\"AppletItems\"/>\n"
131 " <separator/>\n"
132 " <menuitem name=\"RemoveItem\" action=\"Remove\"/>\n"
133 " <menuitem name=\"MoveItem\" action=\"Move\"/>\n"
134 " <separator/>\n"
135 " <menuitem name=\"LockItem\" action=\"Lock\"/>\n"
136 " </popup>\n"
137 "</ui>\n";
138
139static const GtkActionEntry menu_entries[] = {
140 { "Remove", "list-remove", N_("_Remove From Panel")("_Remove From Panel"),
141 NULL((void*)0), NULL((void*)0),
142 G_CALLBACK (mate_panel_applet_menu_cmd_remove)((GCallback) (mate_panel_applet_menu_cmd_remove)) },
143 { "Move", NULL((void*)0), N_("_Move")("_Move"),
144 NULL((void*)0), NULL((void*)0),
145 G_CALLBACK (mate_panel_applet_menu_cmd_move)((GCallback) (mate_panel_applet_menu_cmd_move)) }
146};
147
148static const GtkToggleActionEntry menu_toggle_entries[] = {
149 { "Lock", NULL((void*)0), N_("Loc_k To Panel")("Loc_k To Panel"),
150 NULL((void*)0), NULL((void*)0),
151 G_CALLBACK (mate_panel_applet_menu_cmd_lock)((GCallback) (mate_panel_applet_menu_cmd_lock)),
152 FALSE(0) }
153};
154
155G_DEFINE_TYPE_WITH_PRIVATE (MatePanelApplet, mate_panel_applet, GTK_TYPE_EVENT_BOX)static void mate_panel_applet_init (MatePanelApplet *self); static
void mate_panel_applet_class_init (MatePanelAppletClass *klass
); static GType mate_panel_applet_get_type_once (void); static
gpointer mate_panel_applet_parent_class = ((void*)0); static
gint MatePanelApplet_private_offset; static void mate_panel_applet_class_intern_init
(gpointer klass) { mate_panel_applet_parent_class = g_type_class_peek_parent
(klass); if (MatePanelApplet_private_offset != 0) g_type_class_adjust_private_offset
(klass, &MatePanelApplet_private_offset); mate_panel_applet_class_init
((MatePanelAppletClass*) klass); } __attribute__ ((__unused__
)) static inline gpointer mate_panel_applet_get_instance_private
(MatePanelApplet *self) { return (((gpointer) ((guint8*) (self
) + (glong) (MatePanelApplet_private_offset)))); } GType mate_panel_applet_get_type
(void) { static GType static_g_define_type_id = 0; if ((__extension__
({ _Static_assert (sizeof *(&static_g_define_type_id) ==
sizeof (gpointer), "Expression evaluates to false"); (void) (
0 ? (gpointer) * (&static_g_define_type_id) : ((void*)0))
; (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter_pointer (
&static_g_define_type_id)); })) ) { GType g_define_type_id
= mate_panel_applet_get_type_once (); (__extension__ ({ _Static_assert
(sizeof *(&static_g_define_type_id) == sizeof (gpointer)
, "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id
) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer
((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id
)); })) ; } return static_g_define_type_id; } __attribute__ (
(__noinline__)) static GType mate_panel_applet_get_type_once (
void) { GType g_define_type_id = g_type_register_static_simple
((gtk_event_box_get_type ()), g_intern_static_string ("MatePanelApplet"
), sizeof (MatePanelAppletClass), (GClassInitFunc)(void (*)(void
)) mate_panel_applet_class_intern_init, sizeof (MatePanelApplet
), (GInstanceInitFunc)(void (*)(void)) mate_panel_applet_init
, (GTypeFlags) 0); { {{ MatePanelApplet_private_offset = g_type_add_instance_private
(g_define_type_id, sizeof (MatePanelAppletPrivate)); };} } return
g_define_type_id; }
156
157#define MATE_PANEL_APPLET_INTERFACE"org.mate.panel.applet.Applet" "org.mate.panel.applet.Applet"
158#define MATE_PANEL_APPLET_OBJECT_PATH"/org/mate/panel/applet/%s/%d" "/org/mate/panel/applet/%s/%d"
159
160char *
161mate_panel_applet_get_preferences_path (MatePanelApplet *applet)
162{
163 MatePanelAppletPrivate *priv;
164
165 g_return_val_if_fail (MATE_PANEL_IS_APPLET (applet), NULL)do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return (((void*)0)); } } while (0)
;
166
167 priv = mate_panel_applet_get_instance_private (applet);
168 if (!priv->prefs_path)
169 return NULL((void*)0);
170
171 return g_strdup (priv->prefs_path)g_strdup_inline (priv->prefs_path);
172}
173
174static void
175mate_panel_applet_set_preferences_path (MatePanelApplet *applet,
176 const char *prefs_path)
177{
178 MatePanelAppletPrivate *priv;
179
180 priv = mate_panel_applet_get_instance_private (applet);
181
182 if (priv->prefs_path == prefs_path)
183 return;
184
185 if (g_strcmp0 (priv->prefs_path, prefs_path) == 0)
186 return;
187
188 if (prefs_path)
189 priv->prefs_path = g_strdup (prefs_path)g_strdup_inline (prefs_path);
190
191 g_object_notify (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
, "prefs-path");
192}
193
194MatePanelAppletFlags
195mate_panel_applet_get_flags (MatePanelApplet *applet)
196{
197 MatePanelAppletPrivate *priv;
198
199 g_return_val_if_fail (MATE_PANEL_IS_APPLET (applet), MATE_PANEL_APPLET_FLAGS_NONE)do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return (MATE_PANEL_APPLET_FLAGS_NONE); } } while (0)
;
200
201 priv = mate_panel_applet_get_instance_private (applet);
202
203 return priv->flags;
204}
205
206void
207mate_panel_applet_set_flags (MatePanelApplet *applet,
208 MatePanelAppletFlags flags)
209{
210 MatePanelAppletPrivate *priv;
211
212 g_return_if_fail (MATE_PANEL_IS_APPLET (applet))do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return; } } while (0)
;
213
214 priv = mate_panel_applet_get_instance_private (applet);
215
216 if (priv->flags == flags)
217 return;
218
219 priv->flags = flags;
220
221 g_object_notify (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
, "flags");
222
223 if (priv->connection) {
224 GVariantBuilder builder;
225 GVariantBuilder invalidated_builder;
226 GError *error = NULL((void*)0);
227
228 g_variant_builder_init (&builder, G_VARIANT_TYPE_ARRAY((const GVariantType *) "a*"));
229 g_variant_builder_init (&invalidated_builder, G_VARIANT_TYPE ("as")(g_variant_type_checked_ (("as"))));
230
231 g_variant_builder_add (&builder, "{sv}", "Flags",
232 g_variant_new_uint32 (priv->flags));
233
234 g_dbus_connection_emit_signal (priv->connection,
235 NULL((void*)0),
236 priv->object_path,
237 "org.freedesktop.DBus.Properties",
238 "PropertiesChanged",
239 g_variant_new ("(sa{sv}as)",
240 MATE_PANEL_APPLET_INTERFACE"org.mate.panel.applet.Applet",
241 &builder,
242 &invalidated_builder),
243 &error);
244 if (error) {
245 g_printerr ("Failed to send signal PropertiesChanged::Flags: %s\n",
246 error->message);
247 g_error_free (error);
248 }
249 g_variant_builder_clear (&builder);
250 g_variant_builder_clear (&invalidated_builder);
251 }
252}
253
254static void
255mate_panel_applet_size_hints_ensure (MatePanelApplet *applet,
256 int new_size)
257{
258 MatePanelAppletPrivate *priv;
259
260 priv = mate_panel_applet_get_instance_private (applet);
261 if (priv->size_hints && priv->size_hints_len < new_size) {
262 g_free (priv->size_hints);
263 priv->size_hints = g_new (gint, new_size)((gint *) g_malloc_n ((new_size), sizeof (gint)));
264 } else if (!priv->size_hints) {
265 priv->size_hints = g_new (gint, new_size)((gint *) g_malloc_n ((new_size), sizeof (gint)));
266 }
267 priv->size_hints_len = new_size;
268}
269
270static gboolean
271mate_panel_applet_size_hints_changed (MatePanelApplet *applet,
272 const int *size_hints,
273 int n_elements,
274 int base_size)
275{
276 MatePanelAppletPrivate *priv;
277 gint i;
278
279 priv = mate_panel_applet_get_instance_private (applet);
280
281 if (!priv->size_hints)
282 return TRUE(!(0));
283
284 if (priv->size_hints_len != n_elements)
285 return TRUE(!(0));
286
287 for (i = 0; i < n_elements; i++) {
288 if (size_hints[i] + base_size != priv->size_hints[i])
289 return TRUE(!(0));
290 }
291
292 return FALSE(0);
293}
294
295/**
296 * mate_panel_applet_set_size_hints:
297 * @applet: applet
298 * @size_hints: (array length=n_elements): List of integers
299 * @n_elements: Length of @size_hints
300 * @base_size: base_size
301 */
302void
303mate_panel_applet_set_size_hints (MatePanelApplet *applet,
304 const int *size_hints,
305 int n_elements,
306 int base_size)
307{
308 MatePanelAppletPrivate *priv;
309 gint i;
310
311 /* Make sure property has really changed to avoid bus traffic */
312 if (!mate_panel_applet_size_hints_changed (applet, size_hints, n_elements, base_size))
313 return;
314
315 priv = mate_panel_applet_get_instance_private (applet);
316
317 mate_panel_applet_size_hints_ensure (applet, n_elements);
318 for (i = 0; i < n_elements; i++)
319 priv->size_hints[i] = size_hints[i] + base_size;
320
321 g_object_notify (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
, "size-hints");
322
323 if (priv->connection) {
324 GVariantBuilder builder;
325 GVariantBuilder invalidated_builder;
326 GVariant **children;
327 GError *error = NULL((void*)0);
328
329 g_variant_builder_init (&builder, G_VARIANT_TYPE_ARRAY((const GVariantType *) "a*"));
330 g_variant_builder_init (&invalidated_builder, G_VARIANT_TYPE ("as")(g_variant_type_checked_ (("as"))));
331
332 children = g_new (GVariant *, priv->size_hints_len)((GVariant * *) g_malloc_n ((priv->size_hints_len), sizeof
(GVariant *)))
;
333 for (i = 0; i < n_elements; i++)
334 children[i] = g_variant_new_int32 (priv->size_hints[i]);
335 g_variant_builder_add (&builder, "{sv}", "SizeHints",
336 g_variant_new_array (G_VARIANT_TYPE_INT32((const GVariantType *) "i"),
Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption
337 children, priv->size_hints_len));
338 g_free (children);
339
340 g_dbus_connection_emit_signal (priv->connection,
341 NULL((void*)0),
342 priv->object_path,
343 "org.freedesktop.DBus.Properties",
344 "PropertiesChanged",
345 g_variant_new ("(sa{sv}as)",
346 MATE_PANEL_APPLET_INTERFACE"org.mate.panel.applet.Applet",
347 &builder,
348 &invalidated_builder),
349 &error);
350 if (error) {
351 g_printerr ("Failed to send signal PropertiesChanged::SizeHints: %s\n",
352 error->message);
353 g_error_free (error);
354 }
355 g_variant_builder_clear (&builder);
356 g_variant_builder_clear (&invalidated_builder);
357 }
358}
359
360guint
361mate_panel_applet_get_size (MatePanelApplet *applet)
362{
363 MatePanelAppletPrivate *priv;
364
365 g_return_val_if_fail (MATE_PANEL_IS_APPLET (applet), 0)do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return (0); } } while (0)
;
366
367 priv = mate_panel_applet_get_instance_private (applet);
368
369 return priv->size;
370}
371
372/* Applets cannot set their size, so API is not public. */
373static void
374mate_panel_applet_set_size (MatePanelApplet *applet,
375 guint size)
376{
377 MatePanelAppletPrivate *priv;
378
379 g_return_if_fail (MATE_PANEL_IS_APPLET (applet))do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return; } } while (0)
;
380
381 priv = mate_panel_applet_get_instance_private (applet);
382
383 if (priv->size == size)
384 return;
385
386 priv->size = size;
387 g_signal_emit (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
,
388 mate_panel_applet_signals [CHANGE_SIZE],
389 0, size);
390
391 g_object_notify (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
, "size");
392}
393
394MatePanelAppletOrient
395mate_panel_applet_get_orient (MatePanelApplet *applet)
396{
397 MatePanelAppletPrivate *priv;
398
399 g_return_val_if_fail (MATE_PANEL_IS_APPLET (applet), 0)do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return (0); } } while (0)
;
400
401 priv = mate_panel_applet_get_instance_private (applet);
402
403 return priv->orient;
404}
405
406/* Applets cannot set their orientation, so API is not public. */
407static void
408mate_panel_applet_set_orient (MatePanelApplet *applet,
409 MatePanelAppletOrient orient)
410{
411 MatePanelAppletPrivate *priv;
412
413 g_return_if_fail (MATE_PANEL_IS_APPLET (applet))do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return; } } while (0)
;
414
415 priv = mate_panel_applet_get_instance_private (applet);
416
417 if (priv->orient == orient)
418 return;
419
420 priv->orient = orient;
421 g_signal_emit (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
,
422 mate_panel_applet_signals [CHANGE_ORIENT],
423 0, orient);
424
425 g_object_notify (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
, "orient");
426}
427
428static void
429mate_panel_applet_set_locked (MatePanelApplet *applet,
430 gboolean locked)
431{
432 MatePanelAppletPrivate *priv;
433 GtkAction *action;
434
435 g_return_if_fail (MATE_PANEL_IS_APPLET (applet))do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return; } } while (0)
;
436
437 priv = mate_panel_applet_get_instance_private (applet);
438
439 if (priv->locked == locked)
440 return;
441
442 priv->locked = locked;
443
444 action = mate_panel_applet_menu_get_action (applet, "Lock");
445 g_signal_handlers_block_by_func (action,g_signal_handlers_block_matched ((action), (GSignalMatchType)
(G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0
), (mate_panel_applet_menu_cmd_lock), (applet))
446 mate_panel_applet_menu_cmd_lock,g_signal_handlers_block_matched ((action), (GSignalMatchType)
(G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0
), (mate_panel_applet_menu_cmd_lock), (applet))
447 applet)g_signal_handlers_block_matched ((action), (GSignalMatchType)
(G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0
), (mate_panel_applet_menu_cmd_lock), (applet))
;
448 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action)((((GtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((gtk_toggle_action_get_type ()))))))
, locked);
449 g_signal_handlers_unblock_by_func (action,g_signal_handlers_unblock_matched ((action), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (mate_panel_applet_menu_cmd_lock), (applet))
450 mate_panel_applet_menu_cmd_lock,g_signal_handlers_unblock_matched ((action), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (mate_panel_applet_menu_cmd_lock), (applet))
451 applet)g_signal_handlers_unblock_matched ((action), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (mate_panel_applet_menu_cmd_lock), (applet))
;
452
453 mate_panel_applet_menu_update_actions (applet);
454
455 g_object_notify (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
, "locked");
456
457 if (priv->connection) {
458 GError *error = NULL((void*)0);
459
460 g_dbus_connection_emit_signal (priv->connection,
461 NULL((void*)0),
462 priv->object_path,
463 MATE_PANEL_APPLET_INTERFACE"org.mate.panel.applet.Applet",
464 locked ? "Lock" : "Unlock",
465 NULL((void*)0), &error);
466 if (error) {
467 g_printerr ("Failed to send signal %s: %s\n",
468 locked ? "Lock" : "Unlock",
469 error->message);
470 g_error_free (error);
471 }
472 }
473}
474
475gboolean
476mate_panel_applet_get_locked_down (MatePanelApplet *applet)
477{
478 MatePanelAppletPrivate *priv;
479
480 g_return_val_if_fail (MATE_PANEL_IS_APPLET (applet), FALSE)do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return ((0)); } } while (0)
;
481
482 priv = mate_panel_applet_get_instance_private (applet);
483
484 return priv->locked_down;
485}
486
487/* Applets cannot set the lockdown state, so API is not public. */
488static void
489mate_panel_applet_set_locked_down (MatePanelApplet *applet,
490 gboolean locked_down)
491{
492 MatePanelAppletPrivate *priv;
493
494 g_return_if_fail (MATE_PANEL_IS_APPLET (applet))do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return; } } while (0)
;
495
496 priv = mate_panel_applet_get_instance_private (applet);
497
498 if (priv->locked_down == locked_down)
499 return;
500
501 priv->locked_down = locked_down;
502 mate_panel_applet_menu_update_actions (applet);
503
504 g_object_notify (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
, "locked-down");
505}
506
507#ifdef HAVE_X111
508
509static Atom _net_wm_window_type = None0L;
510static Atom _net_wm_window_type_dock = None0L;
511static Atom _net_active_window = None0L;
512
513static void
514mate_panel_applet_init_atoms (Display *xdisplay)
515{
516 if (_net_wm_window_type == None0L)
517 _net_wm_window_type = XInternAtom (xdisplay,
518 "_NET_WM_WINDOW_TYPE",
519 False0);
520
521 if (_net_wm_window_type_dock == None0L)
522 _net_wm_window_type_dock = XInternAtom (xdisplay,
523 "_NET_WM_WINDOW_TYPE_DOCK",
524 False0);
525
526 if (_net_active_window == None0L)
527 _net_active_window = XInternAtom (xdisplay,
528 "_NET_ACTIVE_WINDOW",
529 False0);
530}
531
532static Window
533mate_panel_applet_find_toplevel_dock_window (MatePanelApplet *applet,
534 Display *xdisplay)
535{
536 GtkWidget *toplevel;
537 Window xwin;
538 Window root, parent, *child;
539 int num_children;
540
541 toplevel = gtk_widget_get_toplevel (GTK_WIDGET (applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
);
542 if (!gtk_widget_get_realized (toplevel))
543 return None0L;
544
545 xwin = GDK_WINDOW_XID (gtk_widget_get_window (toplevel))(gdk_x11_window_get_xid (gtk_widget_get_window (toplevel)));
546
547 child = NULL((void*)0);
548 parent = root = None0L;
549 do {
550 Atom type_return;
551 Atom window_type;
552 int format_return;
553 gulong number_return, bytes_after_return;
554 guchar *data_return;
555
556 XGetWindowProperty (xdisplay,
557 xwin,
558 _net_wm_window_type,
559 0, 1, False0,
560 XA_ATOM((Atom) 4),
561 &type_return, &format_return,
562 &number_return,
563 &bytes_after_return,
564 &data_return);
565
566 if (type_return == XA_ATOM((Atom) 4)) {
567 window_type = *(Atom *) data_return;
568
569 XFree (data_return);
570 data_return = NULL((void*)0);
571
572 if (window_type == _net_wm_window_type_dock)
573 return xwin;
574 }
575
576 if (!XQueryTree (xdisplay,
577 xwin,
578 &root, &parent, &child,
579 (guint *) &num_children)) {
580 return None0L;
581 }
582
583 if (child && num_children > 0)
584 XFree (child);
585
586 xwin = parent;
587
588 } while (xwin != None0L && xwin != root);
589
590 return None0L;
591}
592
593#endif /* HAVE_X11 */
594
595/* This function
596 * 1) Gets the window id of the panel that contains the applet
597 * using XQueryTree and XGetWindowProperty to find an ancestor
598 * window with the _NET_WM_WINDOW_TYPE_DOCK window type.
599 * 2) Sends a _NET_ACTIVE_WINDOW message to get that panel focused
600 */
601void
602mate_panel_applet_request_focus (MatePanelApplet *applet,
603 guint32 timestamp)
604{
605#ifdef HAVE_X111
606 GdkScreen *screen;
607 GdkWindow *root;
608 GdkDisplay *display;
609 Display *xdisplay;
610 Window dock_xwindow;
611 Window xroot;
612 XEvent xev;
613
614 if (!GDK_IS_X11_DISPLAY (gdk_display_get_default ())(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gdk_display_get_default ())); GType __t = ((gdk_x11_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
)
615 return;
616
617 g_return_if_fail (MATE_PANEL_IS_APPLET (applet))do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return; } } while (0)
;
618
619 screen = gdk_screen_get_default(); /*There is only one screen since GTK 3.22*/
620 root = gdk_screen_get_root_window (screen);
621 display = gdk_screen_get_display (screen);
622
623 xdisplay = GDK_DISPLAY_XDISPLAY (display)(gdk_x11_display_get_xdisplay (display));
624 xroot = GDK_WINDOW_XID (root)(gdk_x11_window_get_xid (root));
625
626 mate_panel_applet_init_atoms (xdisplay);
627
628 dock_xwindow = mate_panel_applet_find_toplevel_dock_window (applet, xdisplay);
629 if (dock_xwindow == None0L)
630 return;
631
632 xev.xclient.type = ClientMessage33;
633 xev.xclient.serial = 0;
634 xev.xclient.send_event = True1;
635 xev.xclient.window = dock_xwindow;
636 xev.xclient.message_type = _net_active_window;
637 xev.xclient.format = 32;
638 xev.xclient.data.l[0] = 1; /* requestor type; we're an app, I guess */
639 xev.xclient.data.l[1] = timestamp;
640 xev.xclient.data.l[2] = None0L; /* "currently active window", supposedly */
641 xev.xclient.data.l[3] = 0;
642 xev.xclient.data.l[4] = 0;
643
644 XSendEvent (xdisplay,
645 xroot, False0,
646 SubstructureRedirectMask(1L<<20) | SubstructureNotifyMask(1L<<19),
647 &xev);
648#endif
649}
650
651static GtkAction *
652mate_panel_applet_menu_get_action (MatePanelApplet *applet,
653 const gchar *action)
654{
655 MatePanelAppletPrivate *priv;
656
657 priv = mate_panel_applet_get_instance_private (applet);
658
659 return gtk_action_group_get_action (priv->panel_action_group, action);
660}
661
662static void
663mate_panel_applet_menu_update_actions (MatePanelApplet *applet)
664{
665 MatePanelAppletPrivate *priv;
666
667 priv = mate_panel_applet_get_instance_private (applet);
668 g_object_set (mate_panel_applet_menu_get_action (applet, "Lock"),
669 "visible", !priv->locked_down,
670 NULL((void*)0));
671 g_object_set (mate_panel_applet_menu_get_action (applet, "Move"),
672 "sensitive", !priv->locked,
673 "visible", !priv->locked_down,
674 NULL((void*)0));
675 g_object_set (mate_panel_applet_menu_get_action (applet, "Remove"),
676 "sensitive", !priv->locked,
677 "visible", !priv->locked_down,
678 NULL((void*)0));
679}
680
681static void
682mate_panel_applet_menu_cmd_remove (GtkAction *action,
683 MatePanelApplet *applet)
684{
685 MatePanelAppletPrivate *priv;
686 GError *error = NULL((void*)0);
687
688 priv = mate_panel_applet_get_instance_private (applet);
689
690 if (!priv->connection)
691 return;
692
693 g_dbus_connection_emit_signal (priv->connection,
694 NULL((void*)0),
695 priv->object_path,
696 MATE_PANEL_APPLET_INTERFACE"org.mate.panel.applet.Applet",
697 "RemoveFromPanel",
698 NULL((void*)0), &error);
699 if (error) {
700 g_printerr ("Failed to send signal RemoveFromPanel: %s\n",
701 error->message);
702 g_error_free (error);
703 }
704}
705
706static void
707mate_panel_applet_menu_cmd_move (GtkAction *action,
708 MatePanelApplet *applet)
709{
710 MatePanelAppletPrivate *priv;
711 GError *error = NULL((void*)0);
712
713 priv = mate_panel_applet_get_instance_private (applet);
714
715 if (!priv->connection)
716 return;
717
718 g_dbus_connection_emit_signal (priv->connection,
719 NULL((void*)0),
720 priv->object_path,
721 MATE_PANEL_APPLET_INTERFACE"org.mate.panel.applet.Applet",
722 "Move",
723 NULL((void*)0), &error);
724 if (error) {
725 g_printerr ("Failed to send signal RemoveFromPanel: %s\n",
726 error->message);
727 g_error_free (error);
728 }
729}
730
731static void
732mate_panel_applet_menu_cmd_lock (GtkAction *action,
733 MatePanelApplet *applet)
734{
735 gboolean locked;
736
737 locked = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)((((GtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((gtk_toggle_action_get_type ()))))))
);
738 mate_panel_applet_set_locked (applet, locked);
739}
740
741void
742mate_panel_applet_setup_menu (MatePanelApplet *applet,
743 const gchar *xml,
744 GtkActionGroup *applet_action_group)
745{
746 MatePanelAppletPrivate *priv;
747 gchar *new_xml;
748 GError *error = NULL((void*)0);
749
750 g_return_if_fail (MATE_PANEL_IS_APPLET (applet))do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return; } } while (0)
;
751 g_return_if_fail (xml != NULL)do { if ((xml != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "xml != NULL"); return
; } } while (0)
;
752
753 priv = mate_panel_applet_get_instance_private (applet);
754
755 if (priv->applet_action_group)
756 return;
757
758 priv->applet_action_group = g_object_ref (applet_action_group)((__typeof__ (applet_action_group)) (g_object_ref) (applet_action_group
))
;
759 gtk_ui_manager_insert_action_group (priv->ui_manager,
760 applet_action_group, 0);
761
762 new_xml = g_strdup_printf ("<ui><popup name=\"MatePanelAppletPopup\" action=\"AppletItems\">"
763 "<placeholder name=\"AppletItems\">%s\n</placeholder>\n"
764 "</popup></ui>\n", xml);
765 gtk_ui_manager_add_ui_from_string (priv->ui_manager, new_xml, -1, &error);
766 g_free (new_xml);
767 gtk_ui_manager_ensure_update (priv->ui_manager);
768 if (error) {
769 g_warning ("Error merging menus: %s\n", error->message);
770 g_error_free (error);
771 }
772}
773
774void
775mate_panel_applet_setup_menu_from_file (MatePanelApplet *applet,
776 const gchar *filename,
777 GtkActionGroup *applet_action_group)
778{
779 gchar *xml = NULL((void*)0);
780 GError *error = NULL((void*)0);
781
782 if (g_file_get_contents (filename, &xml, NULL((void*)0), &error)) {
783 mate_panel_applet_setup_menu (applet, xml, applet_action_group);
784 } else {
785 g_warning ("%s", error->message);
786 g_error_free (error);
787 }
788
789 g_free (xml);
790}
791
792/**
793 * mate_panel_applet_setup_menu_from_resource:
794 * @applet: a #MatePanelApplet.
795 * @resource_path: a resource path
796 * @action_group: a #GtkActionGroup.
797 *
798 * Sets up the context menu of @applet. @filename is a resource path to a menu
799 * XML file, containing a #GtkUIManager UI definition that describes how to
800 * display the menu items. @action_group contains the various #GtkAction that
801 * are referenced in @xml.
802 *
803 * See also the <link linkend="getting-started.context-menu">Context
804 * Menu</link> section.
805 *
806 * Since: 1.20.1
807 **/
808void
809mate_panel_applet_setup_menu_from_resource (MatePanelApplet *applet,
810 const gchar *resource_path,
811 GtkActionGroup *action_group)
812{
813 GBytes *bytes;
814 GError *error = NULL((void*)0);
815
816 bytes = g_resources_lookup_data (resource_path,
817 G_RESOURCE_LOOKUP_FLAGS_NONE,
818 &error);
819
820 if (bytes) {
821 mate_panel_applet_setup_menu (applet,
822 g_bytes_get_data (bytes, NULL((void*)0)),
823 action_group);
824 } else {
825 g_warning ("%s", error->message);
826 g_error_free (error);
827 }
828
829 g_bytes_unref (bytes);
830}
831
832static void
833mate_panel_applet_finalize (GObject *object)
834{
835 MatePanelApplet *applet;
836 MatePanelAppletPrivate *priv;
837
838 applet = MATE_PANEL_APPLET (object);
839 priv = mate_panel_applet_get_instance_private (applet);
840
841 if (priv->connection) {
842 if (priv->object_id)
843 g_dbus_connection_unregister_object (priv->connection,
844 priv->object_id);
845 priv->object_id = 0;
846 g_clear_object (&priv->connection)do { _Static_assert (sizeof *((&priv->connection)) == sizeof
(gpointer), "Expression evaluates to false"); __typeof__ (((
&priv->connection))) _pp = ((&priv->connection)
); __typeof__ (*((&priv->connection))) _ptr = *_pp; *_pp
= ((void*)0); if (_ptr) (g_object_unref) (_ptr); } while (0)
;
847 }
848
849 g_clear_pointer (&priv->object_path, g_free)do { _Static_assert (sizeof *(&priv->object_path) == sizeof
(gpointer), "Expression evaluates to false"); __typeof__ ((&
priv->object_path)) _pp = (&priv->object_path); __typeof__
(*(&priv->object_path)) _ptr = *_pp; *_pp = ((void*)0
); if (_ptr) (g_free) (_ptr); } while (0)
;
850
851 mate_panel_applet_set_preferences_path (applet, NULL((void*)0));
852
853 g_clear_object (&priv->applet_action_group)do { _Static_assert (sizeof *((&priv->applet_action_group
)) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(((&priv->applet_action_group))) _pp = ((&priv->
applet_action_group)); __typeof__ (*((&priv->applet_action_group
))) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (g_object_unref
) (_ptr); } while (0)
;
854 g_clear_object (&priv->panel_action_group)do { _Static_assert (sizeof *((&priv->panel_action_group
)) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(((&priv->panel_action_group))) _pp = ((&priv->
panel_action_group)); __typeof__ (*((&priv->panel_action_group
))) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (g_object_unref
) (_ptr); } while (0)
;
855 g_clear_object (&priv->ui_manager)do { _Static_assert (sizeof *((&priv->ui_manager)) == sizeof
(gpointer), "Expression evaluates to false"); __typeof__ (((
&priv->ui_manager))) _pp = ((&priv->ui_manager)
); __typeof__ (*((&priv->ui_manager))) _ptr = *_pp; *_pp
= ((void*)0); if (_ptr) (g_object_unref) (_ptr); } while (0)
;
856
857 g_clear_pointer (&priv->size_hints, g_free)do { _Static_assert (sizeof *(&priv->size_hints) == sizeof
(gpointer), "Expression evaluates to false"); __typeof__ ((&
priv->size_hints)) _pp = (&priv->size_hints); __typeof__
(*(&priv->size_hints)) _ptr = *_pp; *_pp = ((void*)0)
; if (_ptr) (g_free) (_ptr); } while (0)
;
858 g_clear_pointer (&priv->prefs_path, g_free)do { _Static_assert (sizeof *(&priv->prefs_path) == sizeof
(gpointer), "Expression evaluates to false"); __typeof__ ((&
priv->prefs_path)) _pp = (&priv->prefs_path); __typeof__
(*(&priv->prefs_path)) _ptr = *_pp; *_pp = ((void*)0)
; if (_ptr) (g_free) (_ptr); } while (0)
;
859 g_clear_pointer (&priv->background, g_free)do { _Static_assert (sizeof *(&priv->background) == sizeof
(gpointer), "Expression evaluates to false"); __typeof__ ((&
priv->background)) _pp = (&priv->background); __typeof__
(*(&priv->background)) _ptr = *_pp; *_pp = ((void*)0)
; if (_ptr) (g_free) (_ptr); } while (0)
;
860 g_clear_pointer (&priv->id, g_free)do { _Static_assert (sizeof *(&priv->id) == sizeof (gpointer
), "Expression evaluates to false"); __typeof__ ((&priv->
id)) _pp = (&priv->id); __typeof__ (*(&priv->id
)) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (g_free) (_ptr);
} while (0)
;
861
862 /* closure is owned by the factory */
863 priv->closure = NULL((void*)0);
864
865 G_OBJECT_CLASS (mate_panel_applet_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((mate_panel_applet_parent_class)), (((GType) ((20) <<
(2))))))))
->finalize (object);
866}
867
868static gboolean
869container_has_focusable_child (GtkContainer *container)
870{
871 GList *list;
872 GList *t;
873 gboolean retval = FALSE(0);
874
875 list = gtk_container_get_children (container);
876
877 for (t = list; t; t = t->next) {
878 GtkWidget *child = GTK_WIDGET (t->data)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((t->data)), ((gtk_widget_get_type ()))))))
;
879 if (gtk_widget_get_can_focus (child)) {
880 retval = TRUE(!(0));
881 break;
882 } else if (GTK_IS_CONTAINER (child)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(child)); GType __t = ((gtk_container_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; }))))
) {
883 retval = container_has_focusable_child (GTK_CONTAINER (child)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((child)), ((gtk_container_get_type ()))))))
);
884 if (retval)
885 break;
886 }
887 }
888 g_list_free (list);
889 return retval;
890}
891
892static void
893mate_panel_applet_menu_popup (MatePanelApplet *applet,
894 GdkEvent *event)
895{
896 MatePanelAppletPrivate *priv;
897 GtkWidget *menu;
898
899 priv = mate_panel_applet_get_instance_private (applet);
900 menu = gtk_ui_manager_get_widget (priv->ui_manager,
901 "/MatePanelAppletPopup");
902
903/* Set up theme and transparency support */
904 GtkWidget *toplevel = gtk_widget_get_toplevel (menu);
905/* Fix any failures of compiz/other wm's to communicate with gtk for transparency */
906 GdkScreen *screen = gtk_widget_get_screen(GTK_WIDGET(toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
907 GdkVisual *visual = gdk_screen_get_rgba_visual(screen);
908 gtk_widget_set_visual(GTK_WIDGET(toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
, visual);
909/* Set menu and it's toplevel window to follow panel theme */
910 GtkStyleContext *context;
911 context = gtk_widget_get_style_context (GTK_WIDGET(toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
912 gtk_style_context_add_class(context,"gnome-panel-menu-bar");
913 gtk_style_context_add_class(context,"mate-panel-menu-bar");
914 GdkGravity widget_anchor = GDK_GRAVITY_NORTH_WEST;
915 GdkGravity menu_anchor = GDK_GRAVITY_NORTH_WEST;
916 switch (priv->orient) {
917 case MATE_PANEL_APPLET_ORIENT_UP:
918 menu_anchor = GDK_GRAVITY_SOUTH_WEST;
919 break;
920 case MATE_PANEL_APPLET_ORIENT_DOWN:
921 widget_anchor = GDK_GRAVITY_SOUTH_WEST;
922 break;
923 case MATE_PANEL_APPLET_ORIENT_LEFT:
924 menu_anchor = GDK_GRAVITY_NORTH_EAST;
925 break;
926 case MATE_PANEL_APPLET_ORIENT_RIGHT:
927 widget_anchor = GDK_GRAVITY_NORTH_EAST;
928 break;
929 }
930 gtk_menu_popup_at_widget (GTK_MENU (menu)((((GtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((menu)), ((gtk_menu_get_type ()))))))
,
931 GTK_WIDGET (applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
,
932 widget_anchor,
933 menu_anchor,
934 event);
935}
936
937static gboolean
938mate_panel_applet_can_focus (GtkWidget *widget)
939{
940 /*
941 * A MatePanelApplet widget can focus if it has a tooltip or it does
942 * not have any focusable children.
943 */
944 if (gtk_widget_get_has_tooltip (widget))
945 return TRUE(!(0));
946
947 if (!MATE_PANEL_IS_APPLET (widget))
948 return FALSE(0);
949
950 return !container_has_focusable_child (GTK_CONTAINER (widget)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_container_get_type ()))))))
);
951}
952
953/* Taken from libmatecomponentui/matecomponent/matecomponent-plug.c */
954static gboolean
955mate_panel_applet_button_event (MatePanelApplet *applet,
956 GdkEventButton *event)
957{
958#ifdef HAVE_X111
959 MatePanelAppletPrivate *priv;
960 GtkWidget *widget;
961 GdkWindow *window;
962 GdkWindow *socket_window;
963 XEvent xevent;
964 GdkDisplay *display;
965
966 priv = mate_panel_applet_get_instance_private (applet);
967
968 if (!priv->out_of_process)
969 return FALSE(0);
970
971 widget = priv->plug;
972
973 if (!gtk_widget_is_toplevel (widget))
974 return FALSE(0);
975
976 window = gtk_widget_get_window (widget);
977 socket_window = gtk_plug_get_socket_window (GTK_PLUG (widget)((((GtkPlug*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_plug_get_type ()))))))
);
978
979 display = gdk_display_get_default ();
980
981 if (!GDK_IS_X11_DISPLAY (display)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(display)); GType __t = ((gdk_x11_display_get_type())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
)
982 return FALSE(0);
983
984 if (event->type == GDK_BUTTON_PRESS) {
985 GdkSeat *seat;
986
987 xevent.xbutton.type = ButtonPress4;
988
989 seat = gdk_display_get_default_seat (display);
990
991 /* X does an automatic pointer grab on button press
992 * if we have both button press and release events
993 * selected.
994 * We don't want to hog the pointer on our parent.
995 */
996 gdk_seat_ungrab (seat);
997 } else {
998 xevent.xbutton.type = ButtonRelease5;
999 }
1000
1001 xevent.xbutton.display = GDK_WINDOW_XDISPLAY (window)((gdk_x11_display_get_xdisplay (gdk_window_get_display (window
))))
;
1002 xevent.xbutton.window = GDK_WINDOW_XID (socket_window)(gdk_x11_window_get_xid (socket_window));
1003 xevent.xbutton.root = GDK_WINDOW_XID (gdk_screen_get_root_window(gdk_x11_window_get_xid (gdk_screen_get_root_window (gdk_window_get_screen
(window))))
1004 (gdk_window_get_screen (window)))(gdk_x11_window_get_xid (gdk_screen_get_root_window (gdk_window_get_screen
(window))))
;
1005 /*
1006 * FIXME: the following might cause
1007 * big problems for non-GTK apps
1008 */
1009 xevent.xbutton.x = 0;
1010 xevent.xbutton.y = 0;
1011 xevent.xbutton.x_root = 0;
1012 xevent.xbutton.y_root = 0;
1013 xevent.xbutton.state = event->state;
1014 xevent.xbutton.button = event->button;
1015 xevent.xbutton.same_screen = TRUE(!(0)); /* FIXME ? */
1016
1017 gdk_x11_display_error_trap_push (display);
1018
1019 XSendEvent (GDK_WINDOW_XDISPLAY (window)((gdk_x11_display_get_xdisplay (gdk_window_get_display (window
))))
,
1020 GDK_WINDOW_XID (socket_window)(gdk_x11_window_get_xid (socket_window)),
1021 False0, NoEventMask0L, &xevent);
1022
1023 gdk_display_flush (display);
1024 gdk_x11_display_error_trap_pop_ignored (display);
1025
1026 return TRUE(!(0));
1027#else
1028 return FALSE(0);
1029#endif
1030}
1031
1032static gboolean
1033mate_panel_applet_button_press (GtkWidget *widget,
1034 GdkEventButton *event)
1035{
1036 MatePanelApplet *applet = MATE_PANEL_APPLET (widget);
1037
1038 if (!container_has_focusable_child (GTK_CONTAINER (applet)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_container_get_type ()))))))
)) {
1039 if (!gtk_widget_has_focus (widget)) {
1040 gtk_widget_set_can_focus (widget, TRUE(!(0)));
1041 gtk_widget_grab_focus (widget);
1042 }
1043 }
1044
1045#ifdef HAVE_WAYLAND1
1046 /*Limit the window list's applet menu to the handle area*/
1047 if (!(GDK_IS_X11_DISPLAY (gdk_display_get_default ())(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gdk_display_get_default ())); GType __t = ((gdk_x11_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
))
1048 {
1049 MatePanelAppletFlags flags;
1050 flags = mate_panel_applet_get_flags (applet);
1051 if (flags & MATE_PANEL_APPLET_EXPAND_MAJOR)
1052 return FALSE(0);
1053 }
1054#endif
1055
1056 if (event->button == 3) {
1057 mate_panel_applet_menu_popup (applet, (GdkEvent *) event);
1058
1059 return TRUE(!(0));
1060 }
1061 return mate_panel_applet_button_event (applet, event);
1062}
1063
1064static gboolean
1065mate_panel_applet_button_release (GtkWidget *widget,
1066 GdkEventButton *event)
1067{
1068 MatePanelApplet *applet = MATE_PANEL_APPLET (widget);
1069
1070 return mate_panel_applet_button_event (applet, event);
1071}
1072
1073/*Open the applet context menu only on Menu key
1074 *Do not open it on Return or some applets won't work
1075 */
1076static gboolean
1077mate_panel_applet_key_press_event (GtkWidget *widget,
1078 GdkEventKey *event)
1079{
1080 if (event->keyval == GDK_KEY_Menu0xff67) {
1081 mate_panel_applet_menu_popup (MATE_PANEL_APPLET (widget), (GdkEvent *) event);
1082 return TRUE(!(0));
1083 }
1084 else
1085 return FALSE(0);
1086}
1087
1088static void
1089mate_panel_applet_get_preferred_width (GtkWidget *widget,
1090 int *minimum_width,
1091 int *natural_width)
1092{
1093 GTK_WIDGET_CLASS (mate_panel_applet_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((mate_panel_applet_parent_class)), ((gtk_widget_get_type (
)))))))
->get_preferred_width (widget,
1094 minimum_width,
1095 natural_width);
1096
1097#if !GTK_CHECK_VERSION (3, 23, 0)((3) > (3) || ((3) == (3) && (24) > (23)) || ((
3) == (3) && (24) == (23) && (42) >= (0)))
1098 MatePanelAppletPrivate *priv;
1099
1100 priv = mate_panel_applet_get_instance_private (MATE_PANEL_APPLET (widget));
1101 if (priv->out_of_process) {
1102 /* Out-of-process applets end up scaled up doubly with GTK 3.22.
1103 * For these builds divide by the scale factor to ensure
1104 * they are back at their own intended size.
1105 */
1106 gint scale;
1107 scale = gtk_widget_get_scale_factor (widget);
1108 *minimum_width /= scale;
1109 *natural_width /= scale;
1110 }
1111#endif
1112}
1113
1114static void
1115mate_panel_applet_get_preferred_height (GtkWidget *widget,
1116 int *minimum_height,
1117 int *natural_height)
1118{
1119 GTK_WIDGET_CLASS (mate_panel_applet_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((mate_panel_applet_parent_class)), ((gtk_widget_get_type (
)))))))
->get_preferred_height (widget,
1120 minimum_height,
1121 natural_height);
1122
1123#if !GTK_CHECK_VERSION (3, 23, 0)((3) > (3) || ((3) == (3) && (24) > (23)) || ((
3) == (3) && (24) == (23) && (42) >= (0)))
1124 MatePanelAppletPrivate *priv;
1125
1126 priv = mate_panel_applet_get_instance_private (MATE_PANEL_APPLET (widget));
1127 if (priv->out_of_process) {
1128 gint scale;
1129 /* Out-of-process applets end up scaled up doubly with GTK 3.22.
1130 * For these builds divide by the scale factor to ensure
1131 * they are back at their own intended size.
1132 */
1133 scale = gtk_widget_get_scale_factor (widget);
1134 *minimum_height /= scale;
1135 *natural_height /= scale;
1136 }
1137#endif
1138}
1139
1140static GtkSizeRequestMode
1141mate_panel_applet_get_request_mode (GtkWidget *widget)
1142{
1143 /* Do not use GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH
1144 * or GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT
1145 * to avoid problems with in-process applets
1146 * when the panel is not expanded
1147 * See https://github.com/mate-desktop/mate-panel/issues/797
1148 * and https://github.com/mate-desktop/mate-panel/issues/799
1149 * Out of process applets already use GTK_SIZE_REQUEST_CONSTANT_SIZE
1150 */
1151 return GTK_SIZE_REQUEST_CONSTANT_SIZE;
1152}
1153
1154static void
1155mate_panel_applet_size_allocate (GtkWidget *widget,
1156 GtkAllocation *allocation)
1157{
1158 MatePanelAppletPrivate *priv;
1159 GtkAllocation child_allocation;
1160 MatePanelApplet *applet;
1161
1162 if (!mate_panel_applet_can_focus (widget)) {
1163 GTK_WIDGET_CLASS (mate_panel_applet_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((mate_panel_applet_parent_class)), ((gtk_widget_get_type (
)))))))
->size_allocate (widget, allocation);
1164 } else {
1165 int border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_container_get_type ()))))))
);
1166
1167 gtk_widget_set_allocation (widget, allocation);
1168 GtkBin *bin = GTK_BIN (widget)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_bin_get_type ()))))))
;
1169
1170 child_allocation.x = 0;
1171 child_allocation.y = 0;
1172
1173 child_allocation.width = MAX (allocation->width - border_width * 2, 0)(((allocation->width - border_width * 2) > (0)) ? (allocation
->width - border_width * 2) : (0))
;
1174 child_allocation.height = MAX (allocation->height - border_width * 2, 0)(((allocation->height - border_width * 2) > (0)) ? (allocation
->height - border_width * 2) : (0))
;
1175
1176 if (gtk_widget_get_realized (widget))
1177 gdk_window_move_resize (gtk_widget_get_window (widget),
1178 allocation->x + border_width,
1179 allocation->y + border_width,
1180 child_allocation.width,
1181 child_allocation.height);
1182
1183 GtkWidget *child = gtk_bin_get_child (bin);
1184 if (child)
1185 gtk_widget_size_allocate (child, &child_allocation);
1186 }
1187
1188 applet = MATE_PANEL_APPLET (widget);
1189 priv = mate_panel_applet_get_instance_private (applet);
1190
1191 if ((priv->previous_height != allocation->height) ||
1192 (priv->previous_width != allocation->width)) {
1193 priv->previous_height = allocation->height;
1194 priv->previous_width = allocation->width;
1195 mate_panel_applet_handle_background (applet);
1196 }
1197}
1198
1199static gboolean mate_panel_applet_draw(GtkWidget* widget, cairo_t* cr)
1200{
1201 GtkStyleContext *context;
1202 int border_width;
1203 gdouble x, y, width, height;
1204
1205 GTK_WIDGET_CLASS (mate_panel_applet_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((mate_panel_applet_parent_class)), ((gtk_widget_get_type (
)))))))
->draw(widget, cr);
1206
1207 if (!gtk_widget_has_focus (widget))
1208 return FALSE(0);
1209
1210 width = gtk_widget_get_allocated_width (widget);
1211 height = gtk_widget_get_allocated_height (widget);
1212
1213 border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_container_get_type ()))))))
);
1214
1215 x = 0;
1216 y = 0;
1217
1218 width -= 2 * border_width;
1219 height -= 2 * border_width;
1220
1221 context = gtk_widget_get_style_context (widget);
1222 gtk_style_context_save (context);
1223
1224 cairo_save (cr);
1225 gtk_render_focus (context, cr, x, y, width, height);
1226 cairo_restore (cr);
1227
1228 gtk_style_context_restore (context);
1229
1230 return FALSE(0);
1231}
1232
1233static gboolean
1234mate_panel_applet_focus (GtkWidget *widget,
1235 GtkDirectionType dir)
1236{
1237 MatePanelAppletPrivate *priv;
1238 gboolean ret;
1239 GtkWidget *previous_focus_child;
1240
1241 g_return_val_if_fail (MATE_PANEL_IS_APPLET (widget), FALSE)do { if ((MATE_PANEL_IS_APPLET (widget))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (widget)"
); return ((0)); } } while (0)
;
1242
1243 priv = mate_panel_applet_get_instance_private (MATE_PANEL_APPLET (widget));
1244 if (priv->moving_focus_out) {
1245 /*
1246 * Applet will retain focus if there is nothing else on the
1247 * panel to get focus
1248 */
1249 priv->moving_focus_out = FALSE(0);
1250 return FALSE(0);
1251 }
1252
1253 previous_focus_child = gtk_container_get_focus_child (GTK_CONTAINER (widget)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_container_get_type ()))))))
);
1254 if (!previous_focus_child && !gtk_widget_has_focus (widget)) {
1255 if (gtk_widget_get_has_tooltip (widget)) {
1256 gtk_widget_set_can_focus (widget, TRUE(!(0)));
1257 gtk_widget_grab_focus (widget);
1258 gtk_widget_set_can_focus (widget, FALSE(0));
1259 return TRUE(!(0));
1260 }
1261 }
1262 ret = GTK_WIDGET_CLASS (mate_panel_applet_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((mate_panel_applet_parent_class)), ((gtk_widget_get_type (
)))))))
->focus (widget, dir);
1263
1264 if (!ret && !previous_focus_child) {
1265 if (!gtk_widget_has_focus (widget)) {
1266 /*
1267 * Applet does not have a widget which can focus so set
1268 * the focus on the applet unless it already had focus
1269 * because it had a tooltip.
1270 */
1271 gtk_widget_set_can_focus (widget, TRUE(!(0)));
1272 gtk_widget_grab_focus (widget);
1273 gtk_widget_set_can_focus (widget, FALSE(0));
1274 ret = TRUE(!(0));
1275 }
1276 }
1277
1278 return ret;
1279}
1280
1281static gboolean
1282mate_panel_applet_parse_color (const gchar *color_str,
1283 GdkRGBA *color)
1284{
1285 g_assert (color_str && color)do { if (color_str && color) ; else g_assertion_message_expr
(((gchar*) 0), "mate-panel-applet.c", 1285, ((const char*) (
__func__)), "color_str && color"); } while (0)
;
1286
1287 return gdk_rgba_parse (color, color_str);
1288}
1289
1290#ifdef HAVE_X111
1291static gboolean
1292mate_panel_applet_parse_pixmap_str (const char *str,
1293 Window *xid,
1294 int *x,
1295 int *y)
1296{
1297 char **elements;
1298 char *tmp;
1299
1300 g_return_val_if_fail (str != NULL, FALSE)do { if ((str != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "str != NULL"); return
((0)); } } while (0)
;
1301 g_return_val_if_fail (xid != NULL, FALSE)do { if ((xid != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "xid != NULL"); return
((0)); } } while (0)
;
1302 g_return_val_if_fail (x != NULL, FALSE)do { if ((x != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "x != NULL"); return
((0)); } } while (0)
;
1303 g_return_val_if_fail (y != NULL, FALSE)do { if ((y != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "y != NULL"); return
((0)); } } while (0)
;
1304
1305 elements = g_strsplit (str, ",", -1);
1306
1307 if (!elements)
1308 return FALSE(0);
1309
1310 if (!elements [0] || !*elements [0] ||
1311 !elements [1] || !*elements [1] ||
1312 !elements [2] || !*elements [2])
1313 goto ERROR_AND_FREE;
1314
1315 *xid = strtol (elements [0], &tmp, 10);
1316 if (tmp == elements [0])
1317 goto ERROR_AND_FREE;
1318
1319 *x = strtol (elements [1], &tmp, 10);
1320 if (tmp == elements [1])
1321 goto ERROR_AND_FREE;
1322
1323 *y = strtol (elements [2], &tmp, 10);
1324 if (tmp == elements [2])
1325 goto ERROR_AND_FREE;
1326
1327 g_strfreev (elements);
1328 return TRUE(!(0));
1329
1330ERROR_AND_FREE:
1331 g_strfreev (elements);
1332 return FALSE(0);
1333}
1334
1335static cairo_surface_t *
1336mate_panel_applet_create_foreign_surface_for_display (GdkDisplay *display,
1337 GdkVisual *visual,
1338 Window xid)
1339{
1340 Statusint result = 0;
1341 Window window;
1342 gint x, y;
1343 guint width, height, border, depth;
1344
1345 gdk_x11_display_error_trap_push (display);
1346 result = XGetGeometry (GDK_DISPLAY_XDISPLAY (display)(gdk_x11_display_get_xdisplay (display)), xid, &window,
1347 &x, &y, &width, &height, &border, &depth);
1348 gdk_x11_display_error_trap_pop_ignored (display);
1349
1350 if (result == 0)
1351 return NULL((void*)0);
1352
1353 return cairo_xlib_surface_create (GDK_DISPLAY_XDISPLAY (display)(gdk_x11_display_get_xdisplay (display)),
1354 xid, gdk_x11_visual_get_xvisual (visual),
1355 width, height);
1356}
1357
1358static cairo_pattern_t *
1359mate_panel_applet_get_pattern_from_pixmap (MatePanelApplet *applet,
1360 Window xid,
1361 int x,
1362 int y)
1363{
1364 cairo_surface_t *background;
1365 cairo_surface_t *surface;
1366 GdkWindow *window;
1367 int width;
1368 int height;
1369 GdkDisplay *display;
1370 cairo_t *cr;
1371 cairo_pattern_t *pattern;
1372
1373 g_return_val_if_fail (MATE_PANEL_IS_APPLET (applet), NULL)do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return (((void*)0)); } } while (0)
;
1374
1375 if (!gtk_widget_get_realized (GTK_WIDGET (applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
))
1376 return NULL((void*)0);
1377
1378 window = gtk_widget_get_window (GTK_WIDGET (applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
);
1379 display = gdk_window_get_display (window);
1380
1381 background = mate_panel_applet_create_foreign_surface_for_display (display,
1382 gdk_window_get_visual (window),
1383 xid);
1384
1385 /* background can be NULL if the user changes the background very fast.
1386 * We'll get the next update, so it's not a big deal. */
1387 if (!background || cairo_surface_status (background) != CAIRO_STATUS_SUCCESS) {
1388 if (background)
1389 cairo_surface_destroy (background);
1390 return NULL((void*)0);
1391 }
1392
1393 width = gdk_window_get_width(window);
1394 height = gdk_window_get_height(window);
1395 surface = gdk_window_create_similar_surface (window,
1396 CAIRO_CONTENT_COLOR_ALPHA,
1397 width,
1398 height);
1399 gdk_x11_display_error_trap_push (display);
1400 cr = cairo_create (surface);
1401 cairo_set_source_surface (cr, background, -x, -y);
1402 cairo_rectangle (cr, 0, 0, width, height);
1403 cairo_fill (cr);
1404 gdk_x11_display_error_trap_pop_ignored (display);
1405
1406 cairo_surface_destroy (background);
1407 pattern = NULL((void*)0);
1408
1409 if (cairo_status (cr) == CAIRO_STATUS_SUCCESS) {
1410 pattern = cairo_pattern_create_for_surface (surface);
1411 }
1412
1413 cairo_destroy (cr);
1414 cairo_surface_destroy (surface);
1415
1416 return pattern;
1417}
1418#endif
1419
1420static MatePanelAppletBackgroundType
1421mate_panel_applet_handle_background_string (MatePanelApplet *applet,
1422 GdkRGBA *color,
1423 cairo_pattern_t **pattern)
1424{
1425 MatePanelAppletPrivate *priv;
1426 MatePanelAppletBackgroundType retval;
1427 char **elements;
1428
1429 priv = mate_panel_applet_get_instance_private (applet);
1430 retval = PANEL_NO_BACKGROUND;
1431
1432 if (!gtk_widget_get_realized (GTK_WIDGET (applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
) || !priv->background)
1433 return retval;
1434
1435 elements = g_strsplit (priv->background, ":", -1);
1436
1437 if (elements [0] && !strcmp (elements [0], "none" )) {
1438 retval = PANEL_NO_BACKGROUND;
1439
1440 } else if (elements [0] && !strcmp (elements [0], "color")) {
1441 g_return_val_if_fail (color != NULL, PANEL_NO_BACKGROUND)do { if ((color != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "color != NULL");
return (PANEL_NO_BACKGROUND); } } while (0)
;
1442
1443 if (!elements [1] || !mate_panel_applet_parse_color (elements [1], color)) {
1444
1445 g_warning ("Incomplete '%s' background type received", elements [0]);
1446 g_strfreev (elements);
1447 return PANEL_NO_BACKGROUND;
1448 }
1449
1450 retval = PANEL_COLOR_BACKGROUND;
1451
1452 } else if (elements [0] && !strcmp (elements [0], "pixmap")) {
1453#ifdef HAVE_X111
1454 if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gdk_display_get_default ())); GType __t = ((gdk_x11_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
) {
1455 Window pixmap_id;
1456 int x, y;
1457
1458 g_return_val_if_fail (pattern != NULL, PANEL_NO_BACKGROUND)do { if ((pattern != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "pattern != NULL"
); return (PANEL_NO_BACKGROUND); } } while (0)
;
1459
1460 if (!mate_panel_applet_parse_pixmap_str (elements [1], &pixmap_id, &x, &y)) {
1461 g_warning ("Incomplete '%s' background type received: %s",
1462 elements [0], elements [1]);
1463
1464 g_strfreev (elements);
1465 return PANEL_NO_BACKGROUND;
1466 }
1467
1468 *pattern = mate_panel_applet_get_pattern_from_pixmap (applet, pixmap_id, x, y);
1469 if (!*pattern) {
1470 g_warning ("Failed to get pattern %s", elements [1]);
1471 g_strfreev (elements);
1472 return PANEL_NO_BACKGROUND;
1473 }
1474
1475 retval = PANEL_PIXMAP_BACKGROUND;
1476 } else
1477#endif
1478 { /* not using X11 */
1479 g_warning("Received pixmap background type, which is only supported on X11");
1480 }
1481 } else
1482 g_warning ("Unknown background type received");
1483
1484 g_strfreev (elements);
1485
1486 return retval;
1487}
1488
1489MatePanelAppletBackgroundType
1490mate_panel_applet_get_background (MatePanelApplet *applet,
1491 GdkRGBA *color,
1492 cairo_pattern_t **pattern)
1493{
1494 g_return_val_if_fail (MATE_PANEL_IS_APPLET (applet), PANEL_NO_BACKGROUND)do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return (PANEL_NO_BACKGROUND); } } while (0)
;
1495
1496 /* initial sanity */
1497 if (pattern != NULL((void*)0))
1498 *pattern = NULL((void*)0);
1499
1500 if (color != NULL((void*)0))
1501 memset (color, 0, sizeof (GdkRGBA));
1502
1503 return mate_panel_applet_handle_background_string (applet, color, pattern);
1504}
1505
1506static void
1507mate_panel_applet_set_background_string (MatePanelApplet *applet,
1508 const gchar *background)
1509{
1510 MatePanelAppletPrivate *priv;
1511
1512 priv = mate_panel_applet_get_instance_private (applet);
1513
1514 if (priv->background == background)
1515 return;
1516
1517 if (g_strcmp0 (priv->background, background) == 0)
1518 return;
1519
1520 g_free (priv->background);
1521 priv->background = background ? g_strdup (background)g_strdup_inline (background) : NULL((void*)0);
1522 mate_panel_applet_handle_background (applet);
1523
1524 g_object_notify (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
, "background");
1525}
1526
1527static void
1528mate_panel_applet_handle_background (MatePanelApplet *applet)
1529{
1530 MatePanelAppletBackgroundType type;
1531
1532 GdkRGBA color;
1533 cairo_pattern_t *pattern;
1534
1535 type = mate_panel_applet_get_background (applet, &color, &pattern);
1536
1537 if (!gdk_screen_is_composited (gdk_screen_get_default ())) {
1538 color.alpha = 1.;
1539 }
1540
1541 switch (type) {
1542 case PANEL_NO_BACKGROUND:
1543 g_signal_emit (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
,
1544 mate_panel_applet_signals [CHANGE_BACKGROUND],
1545 0, PANEL_NO_BACKGROUND, NULL((void*)0), NULL((void*)0));
1546 break;
1547 case PANEL_COLOR_BACKGROUND:
1548 g_signal_emit (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
,
1549 mate_panel_applet_signals [CHANGE_BACKGROUND],
1550 0, PANEL_COLOR_BACKGROUND, &color, NULL((void*)0));
1551 break;
1552 case PANEL_PIXMAP_BACKGROUND:
1553 g_signal_emit (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
,
1554 mate_panel_applet_signals [CHANGE_BACKGROUND],
1555
1556 0, PANEL_PIXMAP_BACKGROUND, NULL((void*)0), pattern);
1557
1558 cairo_pattern_destroy (pattern);
1559
1560 break;
1561 default:
1562 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "mate-panel-applet.c"
, 1562, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1563 break;
1564 }
1565}
1566
1567static void
1568mate_panel_applet_realize (GtkWidget *widget)
1569{
1570 MatePanelApplet *applet;
1571 MatePanelAppletPrivate *priv;
1572
1573 GTK_WIDGET_CLASS (mate_panel_applet_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((mate_panel_applet_parent_class)), ((gtk_widget_get_type (
)))))))
->realize (widget);
1574
1575 applet = MATE_PANEL_APPLET (widget);
1576 priv = mate_panel_applet_get_instance_private (applet);
1577 if (priv->background)
1578 mate_panel_applet_handle_background (applet);
1579}
1580
1581static void
1582mate_panel_applet_move_focus_out_of_applet (MatePanelApplet *applet,
1583 GtkDirectionType dir)
1584{
1585 MatePanelAppletPrivate *priv;
1586 GtkWidget *toplevel;
1587
1588 priv = mate_panel_applet_get_instance_private (applet);
1589 priv->moving_focus_out = TRUE(!(0));
1590 toplevel = gtk_widget_get_toplevel (GTK_WIDGET (applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
);
1591 g_return_if_fail (toplevel)do { if ((toplevel)) { } else { g_return_if_fail_warning (((gchar
*) 0), ((const char*) (__func__)), "toplevel"); return; } } while
(0)
;
1592
1593 gtk_widget_child_focus (toplevel, dir);
1594 priv->moving_focus_out = FALSE(0);
1595}
1596
1597static void
1598mate_panel_applet_change_background(MatePanelApplet *applet,
1599 MatePanelAppletBackgroundType type,
1600 GdkRGBA* color,
1601 cairo_pattern_t *pattern)
1602{
1603 MatePanelAppletPrivate *priv;
1604 GdkWindow *window;
1605
1606 priv = mate_panel_applet_get_instance_private (applet);
1607
1608 if (priv->out_of_process)
1609 window = gtk_widget_get_window (GTK_WIDGET (priv->plug)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->plug)), ((gtk_widget_get_type ()))))))
);
1610 else
1611 window = gtk_widget_get_window (GTK_WIDGET (applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
);
1612
1613 gtk_widget_set_app_paintable (GTK_WIDGET (applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
,TRUE(!(0)));
1614
1615 if (priv->out_of_process)
1616 _mate_panel_applet_apply_css (GTK_WIDGET (priv->plug)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->plug)), ((gtk_widget_get_type ()))))))
,type);
1617
1618 switch (type) {
1619 case PANEL_NO_BACKGROUND:
1620 if (priv->out_of_process){
1621 cairo_pattern_t *transparent = cairo_pattern_create_rgba (0, 0, 0, 0); /* Using NULL here breaks transparent */
1622 gdk_window_set_background_pattern (window, transparent); /* backgrounds set by GTK theme */
1623 cairo_pattern_destroy (transparent);
1624 }
1625 break;
1626 case PANEL_COLOR_BACKGROUND:
1627 if (priv->out_of_process){
1628 gdk_window_set_background_rgba(window,color);
1629 gtk_widget_queue_draw (priv->plug); /*change the bg right away always */
1630 }
1631 break;
1632 case PANEL_PIXMAP_BACKGROUND:
1633 if (priv->out_of_process){
1634 gdk_window_set_background_pattern(window,pattern);
1635 gtk_widget_queue_draw (priv->plug); /*change the bg right away always */
1636 }
1637 break;
1638 default:
1639 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "mate-panel-applet.c"
, 1639, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1640 break;
1641 }
1642
1643 if (priv->out_of_process){
1644 GtkStyleContext *context;
1645
1646 context = gtk_widget_get_style_context (GTK_WIDGET (priv->plug)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->plug)), ((gtk_widget_get_type ()))))))
);
1647
1648 if (priv->orient == MATE_PANEL_APPLET_ORIENT_UP ||
1649 priv->orient == MATE_PANEL_APPLET_ORIENT_DOWN)
1650 gtk_style_context_add_class (context, "horizontal");
1651 else
1652 gtk_style_context_add_class (context, "vertical");
1653 }
1654}
1655
1656static void
1657mate_panel_applet_get_property (GObject *object,
1658 guint prop_id,
1659 GValue *value,
1660 GParamSpec *pspec)
1661{
1662 MatePanelApplet *applet;
1663 MatePanelAppletPrivate *priv;
1664
1665 applet = MATE_PANEL_APPLET (object);
1666 priv = mate_panel_applet_get_instance_private (applet);
1667
1668 switch (prop_id) {
1669 case PROP_OUT_OF_PROCESS:
1670 g_value_set_boolean (value, priv->out_of_process);
1671 break;
1672 case PROP_ID:
1673 g_value_set_string (value, priv->id);
1674 break;
1675 case PROP_CLOSURE:
1676 g_value_set_pointer (value, priv->closure);
1677 break;
1678 case PROP_CONNECTION:
1679 g_value_set_object (value, priv->connection);
1680 break;
1681 case PROP_PREFS_PATH:
1682 g_value_set_string (value, priv->prefs_path);
1683 break;
1684 case PROP_ORIENT:
1685 g_value_set_uint (value, priv->orient);
1686 break;
1687 case PROP_SIZE:
1688 g_value_set_uint (value, priv->size);
1689 break;
1690 case PROP_BACKGROUND:
1691 g_value_set_string (value, priv->background);
1692 break;
1693 case PROP_FLAGS:
1694 g_value_set_uint (value, priv->flags);
1695 break;
1696 case PROP_SIZE_HINTS: {
1697 GVariant **children;
1698 GVariant *variant;
1699 gint i;
1700
1701 children = g_new (GVariant *, priv->size_hints_len)((GVariant * *) g_malloc_n ((priv->size_hints_len), sizeof
(GVariant *)))
;
1702 for (i = 0; i < priv->size_hints_len; i++)
1703 children[i] = g_variant_new_int32 (priv->size_hints[i]);
1704 variant = g_variant_new_array (G_VARIANT_TYPE_INT32((const GVariantType *) "i"),
1705 children, priv->size_hints_len);
1706 g_free (children);
1707 g_value_set_pointer (value, variant);
1708 break;
1709 }
1710 case PROP_LOCKED:
1711 g_value_set_boolean (value, priv->locked);
1712 break;
1713 case PROP_LOCKED_DOWN:
1714 g_value_set_boolean (value, priv->locked_down);
1715 break;
1716 default:
1717 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "mate-panel-applet.c", 1717, ("property"), _glib__property_id
, _glib__pspec->name, g_type_name ((((((GTypeClass*) (((GTypeInstance
*) (_glib__pspec))->g_class))->g_type)))), (g_type_name
((((((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
1718 }
1719}
1720
1721static void
1722mate_panel_applet_set_property (GObject *object,
1723 guint prop_id,
1724 const GValue *value,
1725 GParamSpec *pspec)
1726{
1727 MatePanelApplet *applet;
1728 MatePanelAppletPrivate *priv;
1729
1730 applet = MATE_PANEL_APPLET (object);
1731 priv = mate_panel_applet_get_instance_private (applet);
1732
1733 switch (prop_id) {
1734 case PROP_OUT_OF_PROCESS:
1735 priv->out_of_process = g_value_get_boolean (value);
1736 break;
1737 case PROP_ID:
1738 priv->id = g_value_dup_string (value);
1739 break;
1740 case PROP_CLOSURE:
1741 priv->closure = g_value_get_pointer (value);
1742 g_closure_set_marshal (priv->closure,
1743 mate_panel_applet_marshal_BOOLEAN__STRING);
1744 break;
1745 case PROP_CONNECTION:
1746 priv->connection = g_value_dup_object (value);
1747 break;
1748 case PROP_PREFS_PATH:
1749 mate_panel_applet_set_preferences_path (applet, g_value_get_string (value));
1750 break;
1751 case PROP_ORIENT:
1752 mate_panel_applet_set_orient (applet, g_value_get_uint (value));
1753 break;
1754 case PROP_SIZE:
1755 mate_panel_applet_set_size (applet, g_value_get_uint (value));
1756 break;
1757 case PROP_BACKGROUND:
1758 mate_panel_applet_set_background_string (applet, g_value_get_string (value));
1759 break;
1760 case PROP_FLAGS:
1761 mate_panel_applet_set_flags (applet, g_value_get_uint (value));
1762 break;
1763 case PROP_SIZE_HINTS: {
1764 const int *size_hints;
1765 gsize n_elements;
1766
1767 size_hints = g_variant_get_fixed_array (g_value_get_pointer (value),
1768 &n_elements, sizeof (gint32));
1769 mate_panel_applet_set_size_hints (applet, size_hints, n_elements, 0);
1770 }
1771 break;
1772 case PROP_LOCKED:
1773 mate_panel_applet_set_locked (applet, g_value_get_boolean (value));
1774 break;
1775 case PROP_LOCKED_DOWN:
1776 mate_panel_applet_set_locked_down (applet, g_value_get_boolean (value));
1777 break;
1778 default:
1779 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "mate-panel-applet.c", 1779, ("property"), _glib__property_id
, _glib__pspec->name, g_type_name ((((((GTypeClass*) (((GTypeInstance
*) (_glib__pspec))->g_class))->g_type)))), (g_type_name
((((((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
1780 }
1781}
1782
1783static void
1784add_tab_bindings (GtkBindingSet *binding_set,
1785 GdkModifierType modifiers,
1786 GtkDirectionType direction)
1787{
1788 gtk_binding_entry_add_signal (binding_set, GDK_KEY_Tab0xff09, modifiers,
1789 "move_focus_out_of_applet", 1,
1790 GTK_TYPE_DIRECTION_TYPE(gtk_direction_type_get_type ()), direction);
1791 gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Tab0xff89, modifiers,
1792 "move_focus_out_of_applet", 1,
1793 GTK_TYPE_DIRECTION_TYPE(gtk_direction_type_get_type ()), direction);
1794}
1795
1796static void
1797mate_panel_applet_setup (MatePanelApplet *applet)
1798{
1799 MatePanelAppletPrivate *priv;
1800 GValue value = {0, };
1801 GArray *params;
1802 guint i;
1803 gboolean ret;
1804
1805 priv = mate_panel_applet_get_instance_private (applet);
1806
1807 g_assert ((priv->id != NULL) && (priv->closure != NULL))do { if ((priv->id != ((void*)0)) && (priv->closure
!= ((void*)0))) ; else g_assertion_message_expr (((gchar*) 0
), "mate-panel-applet.c", 1807, ((const char*) (__func__)), "(priv->id != NULL) && (priv->closure != NULL)"
); } while (0)
;
1808
1809 params = g_array_sized_new (FALSE(0), TRUE(!(0)), sizeof (GValue), 2);
1810 value.g_type = 0;
1811 g_value_init (&value, G_TYPE_OBJECT((GType) ((20) << (2))));
1812 g_value_set_object (&value, G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
);
1813 g_array_append_val (params, value)g_array_append_vals (params, &(value), 1);
1814
1815 value.g_type = 0;
1816 g_value_init (&value, G_TYPE_STRING((GType) ((16) << (2))));
1817 g_value_set_string (&value, priv->id);
1818 g_array_append_val (params, value)g_array_append_vals (params, &(value), 1);
1819
1820 value.g_type = 0;
1821 g_value_init (&value, G_TYPE_BOOLEAN((GType) ((5) << (2))));
1822
1823 g_closure_invoke (priv->closure,
1824 &value, params->len,
1825 (GValue *) params->data,
1826 NULL((void*)0));
1827
1828 for (i = 0; i < params->len; i++)
1829 g_value_unset (&g_array_index (params, GValue, i)(((GValue*) (void *) (params)->data) [(i)]));
1830 g_array_free (params, TRUE(!(0)));
1831
1832 ret = g_value_get_boolean (&value);
1833 g_value_unset (&value);
1834
1835 if (!ret) { /* FIXME */
1836 g_warning ("need to free the control here");
1837
1838 return;
1839 }
1840}
1841
1842void _mate_panel_applet_apply_css(GtkWidget* widget, MatePanelAppletBackgroundType type)
1843{
1844 GtkStyleContext* context;
1845
1846 context = gtk_widget_get_style_context (widget);
1847
1848 switch (type) {
1849 case PANEL_NO_BACKGROUND:
1850 gtk_style_context_remove_class (context, "mate-custom-panel-background");
1851 break;
1852 case PANEL_COLOR_BACKGROUND:
1853 case PANEL_PIXMAP_BACKGROUND:
1854 gtk_style_context_add_class (context, "mate-custom-panel-background");
1855 break;
1856 default:
1857 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "mate-panel-applet.c"
, 1857, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1858 break;
1859 }
1860}
1861
1862#ifdef HAVE_X111
1863static void _mate_panel_applet_prepare_css (GtkStyleContext *context)
1864{
1865 GtkCssProvider *provider;
1866
1867 g_return_if_fail (GDK_IS_X11_DISPLAY (gdk_display_get_default ()))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((gdk_display_get_default ())); GType __t = ((gdk_x11_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0
), ((const char*) (__func__)), "GDK_IS_X11_DISPLAY (gdk_display_get_default ())"
); return; } } while (0)
;
1868 provider = gtk_css_provider_new ();
1869 gtk_css_provider_load_from_data (provider,
1870 "#PanelPlug {\n"
1871 " background-repeat: no-repeat;\n" /*disable in gtk theme features */
1872 " background-size: cover; " /*that don't work on panel-toplevel */
1873 " }\n"
1874 ".mate-custom-panel-background{\n" /*prepare CSS for user set theme */
1875 " background-color: rgba (0, 0, 0, 0);\n"
1876 " background-image: none;\n"
1877 "}",
1878 -1, NULL((void*)0));
1879
1880 gtk_style_context_add_provider (context,
1881 GTK_STYLE_PROVIDER (provider)((((GtkStyleProvider*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((provider)), ((gtk_style_provider_get_type (
)))))))
,
1882 GTK_STYLE_PROVIDER_PRIORITY_APPLICATION600);
1883 g_object_unref (provider);
1884}
1885#endif /* HAVE_X11 */
1886
1887static void
1888mate_panel_applet_init (MatePanelApplet *applet)
1889{
1890 MatePanelAppletPrivate *priv;
1891
1892 priv = mate_panel_applet_get_instance_private (applet);
1893
1894 priv->flags = MATE_PANEL_APPLET_FLAGS_NONE;
1895 priv->orient = MATE_PANEL_APPLET_ORIENT_UP;
1896 priv->size = 24;
1897
1898 priv->panel_action_group = gtk_action_group_new ("PanelActions");
1899 gtk_action_group_set_translation_domain (priv->panel_action_group, GETTEXT_PACKAGE"mate-panel");
1900 gtk_action_group_add_actions (priv->panel_action_group,
1901 menu_entries,
1902 G_N_ELEMENTS (menu_entries)(sizeof (menu_entries) / sizeof ((menu_entries)[0])),
1903 applet);
1904 gtk_action_group_add_toggle_actions (priv->panel_action_group,
1905 menu_toggle_entries,
1906 G_N_ELEMENTS (menu_toggle_entries)(sizeof (menu_toggle_entries) / sizeof ((menu_toggle_entries)
[0]))
,
1907 applet);
1908
1909 priv->ui_manager = gtk_ui_manager_new ();
1910 gtk_ui_manager_insert_action_group (priv->ui_manager,
1911 priv->panel_action_group, 1);
1912 gtk_ui_manager_add_ui_from_string (priv->ui_manager,
1913 panel_menu_ui, -1, NULL((void*)0));
1914
1915 gtk_widget_set_events (GTK_WIDGET (applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
,
1916 GDK_BUTTON_PRESS_MASK |
1917 GDK_BUTTON_RELEASE_MASK);
1918}
1919
1920static GObject *
1921mate_panel_applet_constructor (GType type,
1922 guint n_construct_properties,
1923 GObjectConstructParam *construct_properties)
1924{
1925 GObject *object;
1926 MatePanelApplet *applet;
1927 MatePanelAppletPrivate *priv;
1928
1929 object = G_OBJECT_CLASS (mate_panel_applet_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((mate_panel_applet_parent_class)), (((GType) ((20) <<
(2))))))))
->constructor (type,
1930 n_construct_properties,
1931 construct_properties);
1932 applet = MATE_PANEL_APPLET (object);
1933 priv = mate_panel_applet_get_instance_private (applet);
1934
1935 if (!priv->out_of_process)
1936 return object;
1937
1938#ifdef HAVE_X111
1939 if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gdk_display_get_default ())); GType __t = ((gdk_x11_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
)
1940 {
1941 GtkStyleContext *context;
1942 GtkWidget *widget;
1943
1944 priv->plug = gtk_plug_new (0);
1945 widget = GTK_WIDGET (priv->plug)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->plug)), ((gtk_widget_get_type ()))))))
;
1946 gtk_widget_set_visual (widget,
1947 gdk_screen_get_rgba_visual (gtk_widget_get_screen (widget)));
1948 context = gtk_widget_get_style_context (widget);
1949 gtk_style_context_add_class (context, "gnome-panel-menu-bar");
1950 gtk_style_context_add_class (context, "mate-panel-menu-bar");
1951 gtk_widget_set_name (widget, "PanelPlug");
1952 _mate_panel_applet_prepare_css (context);
1953
1954 g_signal_connect_swapped (priv->plug, "embedded",g_signal_connect_data ((priv->plug), ("embedded"), (((GCallback
) (mate_panel_applet_setup))), (applet), ((void*)0), G_CONNECT_SWAPPED
)
1955 G_CALLBACK (mate_panel_applet_setup),g_signal_connect_data ((priv->plug), ("embedded"), (((GCallback
) (mate_panel_applet_setup))), (applet), ((void*)0), G_CONNECT_SWAPPED
)
1956 applet)g_signal_connect_data ((priv->plug), ("embedded"), (((GCallback
) (mate_panel_applet_setup))), (applet), ((void*)0), G_CONNECT_SWAPPED
)
;
1957
1958 gtk_container_add (GTK_CONTAINER (priv->plug)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->plug)), ((gtk_container_get_type ()))))))
, GTK_WIDGET (applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
);
1959 } else
1960#endif
1961 { /* not using X11 */
1962 g_warning ("Requested construction of an out-of-process applet, which is only possible on X11");
1963 }
1964
1965 return object;
1966}
1967
1968static void
1969mate_panel_applet_constructed (GObject* object)
1970{
1971 MatePanelApplet* applet = MATE_PANEL_APPLET(object);
1972
1973 /* Rename the class to have compatibility with all GTK2 themes
1974 * https://github.com/perberos/Mate-Desktop-Environment/issues/27
1975 */
1976 gtk_widget_set_name(GTK_WIDGET(applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
, "PanelApplet");
1977
1978 mate_panel_applet_register_object (applet);
1979}
1980
1981static void
1982mate_panel_applet_class_init (MatePanelAppletClass *klass)
1983{
1984 GObjectClass *gobject_class = (GObjectClass *) klass;
1985 GtkWidgetClass *widget_class = (GtkWidgetClass *) klass;
1986 GtkBindingSet *binding_set;
1987
1988 gobject_class->get_property = mate_panel_applet_get_property;
1989 gobject_class->set_property = mate_panel_applet_set_property;
1990 gobject_class->constructor = mate_panel_applet_constructor;
1991 gobject_class->constructed = mate_panel_applet_constructed;
1992 klass->move_focus_out_of_applet = mate_panel_applet_move_focus_out_of_applet;
1993 klass->change_background = mate_panel_applet_change_background;
1994 widget_class->button_press_event = mate_panel_applet_button_press;
1995 widget_class->button_release_event = mate_panel_applet_button_release;
1996 widget_class->get_request_mode = mate_panel_applet_get_request_mode;
1997 widget_class->get_preferred_width = mate_panel_applet_get_preferred_width;
1998 widget_class->get_preferred_height = mate_panel_applet_get_preferred_height;
1999 widget_class->draw = mate_panel_applet_draw;
2000 widget_class->size_allocate = mate_panel_applet_size_allocate;
2001 widget_class->focus = mate_panel_applet_focus;
2002 widget_class->realize = mate_panel_applet_realize;
2003 widget_class->key_press_event = mate_panel_applet_key_press_event;
2004
2005 gobject_class->finalize = mate_panel_applet_finalize;
2006
2007 g_object_class_install_property (gobject_class,
2008 PROP_OUT_OF_PROCESS,
2009 g_param_spec_boolean ("out-of-process",
2010 "out-of-process",
2011 "out-of-process",
2012 TRUE(!(0)),
2013 G_PARAM_CONSTRUCT_ONLY |
2014 G_PARAM_READWRITE));
2015 g_object_class_install_property (gobject_class,
2016 PROP_ID,
2017 g_param_spec_string ("id",
2018 "Id",
2019 "The Applet identifier",
2020 NULL((void*)0),
2021 G_PARAM_CONSTRUCT_ONLY |
2022 G_PARAM_READWRITE));
2023 g_object_class_install_property (gobject_class,
2024 PROP_CLOSURE,
2025 g_param_spec_pointer ("closure",
2026 "GClosure",
2027 "The Applet closure",
2028 G_PARAM_CONSTRUCT_ONLY |
2029 G_PARAM_READWRITE));
2030 g_object_class_install_property (gobject_class,
2031 PROP_CONNECTION,
2032 g_param_spec_object ("connection",
2033 "Connection",
2034 "The DBus Connection",
2035 G_TYPE_DBUS_CONNECTION(g_dbus_connection_get_type ()),
2036 G_PARAM_CONSTRUCT_ONLY |
2037 G_PARAM_READWRITE));
2038 g_object_class_install_property (gobject_class,
2039 PROP_PREFS_PATH,
2040 g_param_spec_string ("prefs-path",
2041 "PrefsPath",
2042 "GSettings Preferences Path",
2043 NULL((void*)0),
2044 G_PARAM_READWRITE));
2045 g_object_class_install_property (gobject_class,
2046 PROP_ORIENT,
2047 g_param_spec_uint ("orient",
2048 "Orient",
2049 "Panel Applet Orientation",
2050 MATE_PANEL_APPLET_ORIENT_FIRSTMATE_PANEL_APPLET_ORIENT_UP,
2051 MATE_PANEL_APPLET_ORIENT_LASTMATE_PANEL_APPLET_ORIENT_RIGHT,
2052 MATE_PANEL_APPLET_ORIENT_UP,
2053 G_PARAM_READWRITE));
2054 g_object_class_install_property (gobject_class,
2055 PROP_SIZE,
2056 g_param_spec_uint ("size",
2057 "Size",
2058 "Panel Applet Size",
2059 0, G_MAXUINT(2147483647 *2U +1U), 0,
2060 G_PARAM_READWRITE));
2061 g_object_class_install_property (gobject_class,
2062 PROP_BACKGROUND,
2063 g_param_spec_string ("background",
2064 "Background",
2065 "Panel Applet Background",
2066 NULL((void*)0),
2067 G_PARAM_READWRITE));
2068 g_object_class_install_property (gobject_class,
2069 PROP_FLAGS,
2070 g_param_spec_uint ("flags",
2071 "Flags",
2072 "Panel Applet flags",
2073 MATE_PANEL_APPLET_FLAGS_NONE,
2074 MATE_PANEL_APPLET_FLAGS_ALL(MATE_PANEL_APPLET_EXPAND_MAJOR|MATE_PANEL_APPLET_EXPAND_MINOR
|MATE_PANEL_APPLET_HAS_HANDLE)
,
2075 MATE_PANEL_APPLET_FLAGS_NONE,
2076 G_PARAM_READWRITE));
2077 g_object_class_install_property (gobject_class,
2078 PROP_SIZE_HINTS,
2079 /* FIXME: value_array? */
2080 g_param_spec_pointer ("size-hints",
2081 "SizeHints",
2082 "Panel Applet Size Hints",
2083 G_PARAM_READWRITE));
2084 g_object_class_install_property (gobject_class,
2085 PROP_LOCKED,
2086 g_param_spec_boolean ("locked",
2087 "Locked",
2088 "Whether Panel Applet is locked",
2089 FALSE(0),
2090 G_PARAM_READWRITE));
2091 g_object_class_install_property (gobject_class,
2092 PROP_LOCKED_DOWN,
2093 g_param_spec_boolean ("locked-down",
2094 "LockedDown",
2095 "Whether Panel Applet is locked down",
2096 FALSE(0),
2097 G_PARAM_READWRITE));
2098
2099 mate_panel_applet_signals [CHANGE_ORIENT] =
2100 g_signal_new ("change-orient",
2101 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2102 G_SIGNAL_RUN_LAST,
2103 G_STRUCT_OFFSET (MatePanelAppletClass, change_orient)((glong) __builtin_offsetof(MatePanelAppletClass, change_orient
))
,
2104 NULL((void*)0),
2105 NULL((void*)0),
2106 mate_panel_applet_marshal_VOID__UINTg_cclosure_marshal_VOID__UINT,
2107 G_TYPE_NONE((GType) ((1) << (2))),
2108 1,
2109 G_TYPE_UINT((GType) ((7) << (2))));
2110
2111 mate_panel_applet_signals [CHANGE_SIZE] =
2112 g_signal_new ("change-size",
2113 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2114 G_SIGNAL_RUN_LAST,
2115 G_STRUCT_OFFSET (MatePanelAppletClass, change_size)((glong) __builtin_offsetof(MatePanelAppletClass, change_size
))
,
2116 NULL((void*)0),
2117 NULL((void*)0),
2118 mate_panel_applet_marshal_VOID__INTg_cclosure_marshal_VOID__INT,
2119 G_TYPE_NONE((GType) ((1) << (2))),
2120 1,
2121 G_TYPE_INT((GType) ((6) << (2))));
2122
2123 mate_panel_applet_signals [CHANGE_BACKGROUND] =
2124 g_signal_new ("change-background",
2125 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2126 G_SIGNAL_RUN_LAST,
2127 G_STRUCT_OFFSET (MatePanelAppletClass, change_background)((glong) __builtin_offsetof(MatePanelAppletClass, change_background
))
,
2128 NULL((void*)0),
2129 NULL((void*)0),
2130 mate_panel_applet_marshal_VOID__ENUM_BOXED_OBJECT,
2131 G_TYPE_NONE((GType) ((1) << (2))),
2132 3,
2133 PANEL_TYPE_MATE_PANEL_APPLET_BACKGROUND_TYPEmate_panel_applet_background_type_get_type(),
2134 GDK_TYPE_RGBA(gdk_rgba_get_type ()),
2135 CAIRO_GOBJECT_TYPE_PATTERNcairo_gobject_pattern_get_type ());
2136
2137 mate_panel_applet_signals [MOVE_FOCUS_OUT_OF_APPLET] =
2138 g_signal_new ("move_focus_out_of_applet",
2139 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2140 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
2141 G_STRUCT_OFFSET (MatePanelAppletClass, move_focus_out_of_applet)((glong) __builtin_offsetof(MatePanelAppletClass, move_focus_out_of_applet
))
,
2142 NULL((void*)0),
2143 NULL((void*)0),
2144 mate_panel_applet_marshal_VOID__ENUMg_cclosure_marshal_VOID__ENUM,
2145 G_TYPE_NONE((GType) ((1) << (2))),
2146 1,
2147 GTK_TYPE_DIRECTION_TYPE(gtk_direction_type_get_type ()));
2148
2149 binding_set = gtk_binding_set_by_class (gobject_class);
2150 add_tab_bindings (binding_set, 0, GTK_DIR_TAB_FORWARD);
2151 add_tab_bindings (binding_set, GDK_SHIFT_MASK, GTK_DIR_TAB_BACKWARD);
2152 add_tab_bindings (binding_set, GDK_CONTROL_MASK, GTK_DIR_TAB_FORWARD);
2153 add_tab_bindings (binding_set, GDK_CONTROL_MASK | GDK_SHIFT_MASK, GTK_DIR_TAB_BACKWARD);
2154
2155 gtk_widget_class_set_css_name (widget_class, "PanelApplet");
2156}
2157
2158GtkWidget* mate_panel_applet_new(void)
2159{
2160 MatePanelApplet* applet = g_object_new(PANEL_TYPE_APPLETmate_panel_applet_get_type (), NULL((void*)0));
2161
2162 return GTK_WIDGET(applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
;
2163}
2164
2165static GdkEvent *
2166button_press_event_new (MatePanelApplet *applet,
2167 guint button,
2168 guint time)
2169{
2170 GdkDisplay *display;
2171 GdkSeat *seat;
2172 GdkDevice *device;
2173 GdkEvent *event;
2174
2175 display = gdk_display_get_default ();
2176 seat = gdk_display_get_default_seat (display);
2177 device = gdk_seat_get_pointer (seat);
2178
2179 event = gdk_event_new (GDK_BUTTON_PRESS);
2180
2181 event->button.time = time;
2182 event->button.button = button;
2183
2184 gdk_event_set_device (event, device);
2185
2186 return event;
2187}
2188
2189static void
2190method_call_cb (GDBusConnection *connection,
2191 const gchar *sender,
2192 const gchar *object_path,
2193 const gchar *interface_name,
2194 const gchar *method_name,
2195 GVariant *parameters,
2196 GDBusMethodInvocation *invocation,
2197 gpointer user_data)
2198{
2199 MatePanelApplet *applet = MATE_PANEL_APPLET (user_data);
2200
2201 if (g_strcmp0 (method_name, "PopupMenu") == 0) {
2202 guint button;
2203 guint time;
2204
2205 g_variant_get (parameters, "(uu)", &button, &time);
2206
2207 GdkEvent *event = button_press_event_new (applet, button, time);
2208 mate_panel_applet_menu_popup (applet, event);
2209 gdk_event_free (event);
2210
2211 g_dbus_method_invocation_return_value (invocation, NULL((void*)0));
2212 }
2213}
2214
2215static GVariant *
2216get_property_cb (GDBusConnection *connection,
2217 const gchar *sender,
2218 const gchar *object_path,
2219 const gchar *interface_name,
2220 const gchar *property_name,
2221 GError **error,
2222 gpointer user_data)
2223{
2224 MatePanelAppletPrivate *priv;
2225 GVariant *retval = NULL((void*)0);
2226
2227 priv = mate_panel_applet_get_instance_private (MATE_PANEL_APPLET (user_data));
2228
2229 if (g_strcmp0 (property_name, "PrefsPath") == 0) {
2230 retval = g_variant_new_string (priv->prefs_path ? priv->prefs_path : "");
2231 } else if (g_strcmp0 (property_name, "Orient") == 0) {
2232 retval = g_variant_new_uint32 (priv->orient);
2233 } else if (g_strcmp0 (property_name, "Size") == 0) {
2234 retval = g_variant_new_uint32 (priv->size);
2235 } else if (g_strcmp0 (property_name, "Background") == 0) {
2236 retval = g_variant_new_string (priv->background ? priv->background : "");
2237 } else if (g_strcmp0 (property_name, "Flags") == 0) {
2238 retval = g_variant_new_uint32 (priv->flags);
2239 } else if (g_strcmp0 (property_name, "SizeHints") == 0) {
2240 GVariant **children;
2241 gint i;
2242
2243 children = g_new (GVariant *, priv->size_hints_len)((GVariant * *) g_malloc_n ((priv->size_hints_len), sizeof
(GVariant *)))
;
2244 for (i = 0; i < priv->size_hints_len; i++)
2245 children[i] = g_variant_new_int32 (priv->size_hints[i]);
2246 retval = g_variant_new_array (G_VARIANT_TYPE_INT32((const GVariantType *) "i"),
2247 children, priv->size_hints_len);
2248 g_free (children);
2249 } else if (g_strcmp0 (property_name, "Locked") == 0) {
2250 retval = g_variant_new_boolean (priv->locked);
2251 } else if (g_strcmp0 (property_name, "LockedDown") == 0) {
2252 retval = g_variant_new_boolean (priv->locked_down);
2253 }
2254
2255 return retval;
2256}
2257
2258static gboolean
2259set_property_cb (GDBusConnection *connection,
2260 const gchar *sender,
2261 const gchar *object_path,
2262 const gchar *interface_name,
2263 const gchar *property_name,
2264 GVariant *value,
2265 GError **error,
2266 gpointer user_data)
2267{
2268 MatePanelApplet *applet = MATE_PANEL_APPLET (user_data);
2269
2270 if (g_strcmp0 (property_name, "PrefsPath") == 0) {
2271 mate_panel_applet_set_preferences_path (applet, g_variant_get_string (value, NULL((void*)0)));
2272 } else if (g_strcmp0 (property_name, "Orient") == 0) {
2273 mate_panel_applet_set_orient (applet, g_variant_get_uint32 (value));
2274 } else if (g_strcmp0 (property_name, "Size") == 0) {
2275 mate_panel_applet_set_size (applet, g_variant_get_uint32 (value));
2276 } else if (g_strcmp0 (property_name, "Background") == 0) {
2277 mate_panel_applet_set_background_string (applet, g_variant_get_string (value, NULL((void*)0)));
2278 } else if (g_strcmp0 (property_name, "Flags") == 0) {
2279 mate_panel_applet_set_flags (applet, g_variant_get_uint32 (value));
2280 } else if (g_strcmp0 (property_name, "SizeHints") == 0) {
2281 const int *size_hints;
2282 gsize n_elements;
2283
2284 size_hints = g_variant_get_fixed_array (value, &n_elements, sizeof (gint32));
2285 mate_panel_applet_set_size_hints (applet, size_hints, n_elements, 0);
2286 } else if (g_strcmp0 (property_name, "Locked") == 0) {
2287 mate_panel_applet_set_locked (applet, g_variant_get_boolean (value));
2288 } else if (g_strcmp0 (property_name, "LockedDown") == 0) {
2289 mate_panel_applet_set_locked_down (applet, g_variant_get_boolean (value));
2290 }
2291
2292 return TRUE(!(0));
2293}
2294
2295static const gchar introspection_xml[] =
2296 "<node>"
2297 "<interface name='org.mate.panel.applet.Applet'>"
2298 "<method name='PopupMenu'>"
2299 "<arg name='button' type='u' direction='in'/>"
2300 "<arg name='time' type='u' direction='in'/>"
2301 "</method>"
2302 "<property name='PrefsPath' type='s' access='readwrite'/>"
2303 "<property name='Orient' type='u' access='readwrite' />"
2304 "<property name='Size' type='u' access='readwrite'/>"
2305 "<property name='Background' type='s' access='readwrite'/>"
2306 "<property name='Flags' type='u' access='readwrite'/>"
2307 "<property name='SizeHints' type='ai' access='readwrite'/>"
2308 "<property name='Locked' type='b' access='readwrite'/>"
2309 "<property name='LockedDown' type='b' access='readwrite'/>"
2310 "<signal name='Move' />"
2311 "<signal name='RemoveFromPanel' />"
2312 "<signal name='Lock' />"
2313 "<signal name='Unlock' />"
2314 "</interface>"
2315 "</node>";
2316
2317static const GDBusInterfaceVTable interface_vtable = {
2318 method_call_cb,
2319 get_property_cb,
2320 set_property_cb,
2321 { 0 }
2322};
2323
2324static GDBusNodeInfo *introspection_data = NULL((void*)0);
2325
2326static void
2327mate_panel_applet_register_object (MatePanelApplet *applet)
2328{
2329 MatePanelAppletPrivate *priv;
2330 GError *error = NULL((void*)0);
2331 static gint id = 0;
2332
2333 if (!introspection_data)
2334 introspection_data = g_dbus_node_info_new_for_xml (introspection_xml, NULL((void*)0));
2335
2336 priv = mate_panel_applet_get_instance_private (applet);
2337 priv->object_path = g_strdup_printf (MATE_PANEL_APPLET_OBJECT_PATH"/org/mate/panel/applet/%s/%d", priv->id, id++);
2338 priv->object_id =
2339 g_dbus_connection_register_object (priv->connection,
2340 priv->object_path,
2341 introspection_data->interfaces[0],
2342 &interface_vtable,
2343 applet, NULL((void*)0),
2344 &error);
2345 if (!priv->object_id) {
2346 g_printerr ("Failed to register object %s: %s\n", priv->object_path, error->message);
2347 g_error_free (error);
2348 }
2349}
2350
2351static void mate_panel_applet_factory_main_finalized(gpointer data, GObject* object)
2352{
2353 gtk_main_quit();
2354
2355 if (introspection_data)
2356 {
2357 g_dbus_node_info_unref(introspection_data);
2358 introspection_data = NULL((void*)0);
2359 }
2360}
2361
2362#ifdef HAVE_X111
2363static int (*_x_error_func) (Display *, XErrorEvent *);
2364
2365static int
2366_x_error_handler (Display *display, XErrorEvent *error)
2367{
2368 if (!error->error_code)
2369 return 0;
2370
2371 /* If we got a BadDrawable or a BadWindow, we ignore it for now.
2372 * FIXME: We need to somehow distinguish real errors from
2373 * X-server-induced errors. Keeping a list of windows for which we
2374 * will ignore BadDrawables would be a good idea. */
2375 if (error->error_code == BadDrawable9 ||
2376 error->error_code == BadWindow3)
2377 return 0;
2378
2379 return _x_error_func (display, error);
2380}
2381
2382/*
2383 * To do graphical embedding in the X window system, MATE Panel
2384 * uses the classic foreign-window-reparenting trick. The
2385 * GtkPlug/GtkSocket widgets are used for this purpose. However,
2386 * serious robustness problems arise if the GtkSocket end of the
2387 * connection unexpectedly dies. The X server sends out DestroyNotify
2388 * events for the descendants of the GtkPlug (i.e., your embedded
2389 * component's windows) in effectively random order. Furthermore, if
2390 * you happened to be drawing on any of those windows when the
2391 * GtkSocket was destroyed (a common state of affairs), an X error
2392 * will kill your application.
2393 *
2394 * To solve this latter problem, MATE Panel sets up its own X error
2395 * handler which ignores certain X errors that might have been
2396 * caused by such a scenario. Other X errors get passed to gdk_x_error
2397 * normally.
2398 */
2399static void
2400_mate_panel_applet_setup_x_error_handler (void)
2401{
2402 static gboolean error_handler_setup = FALSE(0);
2403
2404 if (error_handler_setup)
2405 return;
2406
2407 error_handler_setup = TRUE(!(0));
2408
2409 _x_error_func = XSetErrorHandler (_x_error_handler);
2410}
2411#endif
2412
2413static int
2414_mate_panel_applet_factory_main_internal (const gchar *factory_id,
2415 gboolean out_process,
2416 GType applet_type,
2417 MatePanelAppletFactoryCallback callback,
2418 gpointer user_data)
2419{
2420 MatePanelAppletFactory* factory;
2421 GClosure* closure;
2422
2423 g_return_val_if_fail(factory_id != NULL, 1)do { if ((factory_id != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "factory_id != NULL"
); return (1); } } while (0)
;
2424 g_return_val_if_fail(callback != NULL, 1)do { if ((callback != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "callback != NULL"
); return (1); } } while (0)
;
2425 g_assert(g_type_is_a(applet_type, PANEL_TYPE_APPLET))do { if (((applet_type) == (mate_panel_applet_get_type ()) ||
(g_type_is_a) ((applet_type), (mate_panel_applet_get_type ()
)))) ; else g_assertion_message_expr (((gchar*) 0), "mate-panel-applet.c"
, 2425, ((const char*) (__func__)), "g_type_is_a(applet_type, PANEL_TYPE_APPLET)"
); } while (0)
;
2426
2427#ifdef HAVE_X111
2428 if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gdk_display_get_default ())); GType __t = ((gdk_x11_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
) {
2429 /*Use this both in and out of process as the tray applet always uses GtkSocket
2430 *to handle GtkStatusIcons whether the tray itself is built in or out of process
2431 */
2432 _mate_panel_applet_setup_x_error_handler();
2433 } else
2434#endif
2435 { /* not using X11 */
2436 if (out_process) {
2437 g_warning("Requested out-of-process applet, which is only supported on X11");
2438 return 1;
2439 }
2440 }
2441
2442 closure = g_cclosure_new(G_CALLBACK(callback)((GCallback) (callback)), user_data, NULL((void*)0));
2443 factory = mate_panel_applet_factory_new(factory_id, out_process, applet_type, closure);
2444 g_closure_unref(closure);
2445
2446 if (mate_panel_applet_factory_register_service(factory))
2447 {
2448 if (out_process)
2449 {
2450 g_object_weak_ref(G_OBJECT(factory)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((factory)), (((GType) ((20) << (2))))))))
, mate_panel_applet_factory_main_finalized, NULL((void*)0));
2451 gtk_main();
2452 }
2453
2454 return 0;
2455 }
2456
2457 g_object_unref (factory);
2458
2459 return 1;
2460}
2461
2462/**
2463 * mate_panel_applet_factory_main:
2464 * @out_process: boolean, dummy to support applets sending it
2465 * @factory_id: Factory ID.
2466 * @applet_type: GType of the applet this factory creates.
2467 * @callback: (scope call): Callback to be called when a new applet is to be created.
2468 * @data: (closure): Callback data.
2469 *
2470 * Returns: 0 on success, 1 if there is an error.
2471 */
2472int
2473mate_panel_applet_factory_main (const gchar *factory_id,
2474 gboolean out_process, /*Dummy to support applets w issues with this */
2475 GType applet_type,
2476 MatePanelAppletFactoryCallback callback,
2477 gpointer user_data)
2478{
2479 return _mate_panel_applet_factory_main_internal (factory_id, TRUE(!(0)), applet_type,
2480 callback, user_data);
2481}
2482
2483/**
2484 * mate_panel_applet_factory_setup_in_process: (skip)
2485 * @factory_id: Factory ID.
2486 * @applet_type: GType of the applet this factory creates.
2487 * @callback: (scope call): Callback to be called when a new applet is to be created.
2488 * @data: (closure): Callback data.
2489 *
2490 * Returns: 0 on success, 1 if there is an error.
2491 */
2492int
2493mate_panel_applet_factory_setup_in_process (const gchar *factory_id,
2494 GType applet_type,
2495 MatePanelAppletFactoryCallback callback,
2496 gpointer user_data)
2497{
2498 return _mate_panel_applet_factory_main_internal (factory_id, FALSE(0), applet_type,
2499 callback, user_data);
2500}
2501
2502/**
2503 * mate_panel_applet_set_background_widget:
2504 * @applet: a #PanelApplet.
2505 * @widget: a #GtkWidget.
2506 *
2507 * Configure #PanelApplet to automatically draw the background of the applet on
2508 * @widget. It is generally enough to call this function with @applet as
2509 * @widget.
2510 *
2511 * Deprecated: 3.20: Do not use this API. Since 3.20 this function does nothing.
2512 **/
2513
2514void
2515mate_panel_applet_set_background_widget (MatePanelApplet *applet,
2516 GtkWidget *widget)
2517{
2518}
2519
2520guint32
2521mate_panel_applet_get_xid (MatePanelApplet *applet,
2522 GdkScreen *screen)
2523{
2524 MatePanelAppletPrivate *priv;
2525
2526 priv = mate_panel_applet_get_instance_private (applet);
2527
2528 /* out_of_process should only be true on X11, so an extra runtime Wayland check is not needed */
2529 if (priv->out_of_process == FALSE(0))
2530 return 0;
2531
2532#ifdef HAVE_X111
2533 gtk_window_set_screen (GTK_WINDOW (priv->plug)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->plug)), ((gtk_window_get_type ()))))))
, screen);
2534 gtk_widget_show (priv->plug);
2535
2536 return gtk_plug_get_id (GTK_PLUG (priv->plug)((((GtkPlug*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->plug)), ((gtk_plug_get_type ()))))))
);
2537#else
2538 return 0;
2539#endif
2540}
2541
2542const gchar *
2543mate_panel_applet_get_object_path (MatePanelApplet *applet)
2544{
2545 MatePanelAppletPrivate *priv;
2546
2547 priv = mate_panel_applet_get_instance_private (applet);
2548
2549 return priv->object_path;
2550}
2551
2552G_MODULE_EXPORT__attribute__((visibility("default"))) GtkWidget *
2553mate_panel_applet_get_applet_widget (const gchar *factory_id,
2554 guint uid)
2555{
2556 GtkWidget *widget;
2557
2558 widget = mate_panel_applet_factory_get_applet_widget (factory_id, uid);
2559 if (!widget) {
2560 return NULL((void*)0);
2561 }
2562
2563 mate_panel_applet_setup (MATE_PANEL_APPLET (widget));
2564
2565 return widget;
2566}
diff --git a/2024-06-18-172109-13286-1@e182420b844f_master/report-db7134.html b/2024-06-18-172109-13286-1@e182420b844f_master/report-db7134.html new file mode 100644 index 00000000..b03a0c1c --- /dev/null +++ b/2024-06-18-172109-13286-1@e182420b844f_master/report-db7134.html @@ -0,0 +1,1031 @@ + + + +panel-context-menu.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:mate-panel/panel-context-menu.c
Warning:line 305, column 10
Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name panel-context-menu.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/mate-panel -fcoverage-compilation-dir=/rootdir/mate-panel -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I .. -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/startup-notification-1.0 -I /usr/include/mate-menus -I /usr/include/gio-unix-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/dconf -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/dconf -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I . -I . -I ../mate-panel -I ../mate-panel/mate-submodules -I ../mate-panel/libpanel-util -D MATELOCALEDIR="/usr/local/share/locale" -D PANELDATADIR="/usr/local/share/mate-panel" -I /usr/include/gtk-layer-shell -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/gtk-3.0 -I /usr/include/cloudproviders -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/atk-1.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/gio-unix-2.0 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -D PANEL_MODULES_DIR="/usr/local/lib/mate-panel/modules" -D MATEMENU_I_KNOW_THIS_IS_UNSTABLE -I /usr/include/gtk-layer-shell -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/gtk-3.0 -I /usr/include/cloudproviders -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/atk-1.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/gio-unix-2.0 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-18-172109-13286-1 -x c panel-context-menu.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * panel-context-menu.c: context menu for the panels
3 *
4 * Copyright (C) 2004 Vincent Untz
5 * Copyright (C) 2012-2021 MATE Developers
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of the
10 * License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301, USA.
21 *
22 * Most of the original code come from menu.c
23 *
24 * Authors:
25 * Vincent Untz <vincent@vuntz.net>
26 *
27 */
28
29#include <config.h>
30
31#include "panel-context-menu.h"
32
33#include <string.h>
34
35#include <glib/gi18n.h>
36#include <gdk/gdkkeysyms.h>
37
38#include <libpanel-util/panel-error.h>
39#include <libpanel-util/panel-show.h>
40#include <libpanel-util/panel-gtk.h>
41
42#include "panel-util.h"
43#include "panel.h"
44#include "menu.h"
45#include "applet.h"
46#include "panel-config-global.h"
47#include "panel-profile.h"
48#include "panel-properties-dialog.h"
49#include "panel-lockdown.h"
50#include "panel-addto.h"
51#include "panel-icon-names.h"
52#include "panel-reset.h"
53
54static void
55panel_context_menu_show_help (GtkWidget *w,
56 gpointer data)
57{
58 panel_show_help (gtk_widget_get_screen (w),
59 "mate-user-guide", "gospanel-1", NULL((void*)0));
60}
61
62static void
63panel_context_menu_show_about_dialog (GtkWidget *menuitem)
64{
65 static GtkWidget *about = NULL((void*)0);
66 char *authors [] = {
67 /* MATE */
68 "Perberos <perberos@gmail.com>",
69 "Stefano Karapetsas <stefano@karapetsas.com>",
70 "Steve Zesch <stevezesch2@gmail.com>",
71 /* GNOME */
72 "Alex Larsson <alexl@redhat.com>",
73 "Anders Carlsson <andersca@gnu.org>",
74 "Arvind Samptur <arvind.samptur@wipro.com>",
75 "Darin Adler <darin@bentspoon.com>",
76 "Elliot Lee <sopwith@redhat.com>",
77 "Federico Mena <quartic@gimp.org>",
78 "George Lebl <jirka@5z.com>",
79 "Glynn Foster <glynn.foster@sun.com>",
80 "Ian Main <imain@gtk.org>",
81 "Ian McKellar <yakk@yakk.net>",
82 "Jacob Berkman <jberkman@andrew.cmu.edu>",
83 "Mark McLoughlin <mark@skynet.ie>",
84 "Martin Baulig <baulig@suse.de>",
85 "Miguel de Icaza <miguel@kernel.org>",
86 "Owen Taylor <otaylor@redhat.com>",
87 "Padraig O'Briain <padraig.obriain@sun.com>",
88 "Seth Nickell <snickell@stanford.edu>",
89 "Stephen Browne <stephen.browne@sun.com>",
90 "Tom Tromey <tromey@cygnus.com>",
91 "Vincent Untz <vuntz@gnome.org>",
92 N_("And many, many others…")("And many, many others…"),
93 NULL((void*)0)
94 };
95 char *documenters[] = {
96 "Alexander Kirillov <kirillov@math.sunysb.edu>",
97 "Dan Mueth <d-mueth@uchicago.edu>",
98 "Dave Mason <dcm@redhat.com>",
99 NULL((void*)0)
100 };
101 int i;
102
103 if (about) {
104 gtk_window_set_screen (GTK_WINDOW (about)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((about)), ((gtk_window_get_type ()))))))
,
105 menuitem_to_screen (menuitem));
106 gtk_window_present (GTK_WINDOW (about)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((about)), ((gtk_window_get_type ()))))))
);
107 return;
108 }
109
110 for (i = 0; authors [i]; i++)
111 authors [i] = _(authors [i])gettext (authors [i]);
112
113 about = gtk_about_dialog_new ();
114 g_object_set (about,
115 "program-name", _("The MATE Panel")gettext ("The MATE Panel"),
116 "version", VERSION"1.29.0",
117 "copyright", _("Copyright \xc2\xa9 1997-2003 Free Software Foundation, Inc.\n"gettext ("Copyright \xc2\xa9 1997-2003 Free Software Foundation, Inc.\n"
"Copyright \xc2\xa9 2004 Vincent Untz\n" "Copyright \xc2\xa9 2011-2021 MATE developers"
)
118 "Copyright \xc2\xa9 2004 Vincent Untz\n"gettext ("Copyright \xc2\xa9 1997-2003 Free Software Foundation, Inc.\n"
"Copyright \xc2\xa9 2004 Vincent Untz\n" "Copyright \xc2\xa9 2011-2021 MATE developers"
)
119 "Copyright \xc2\xa9 2011-2021 MATE developers")gettext ("Copyright \xc2\xa9 1997-2003 Free Software Foundation, Inc.\n"
"Copyright \xc2\xa9 2004 Vincent Untz\n" "Copyright \xc2\xa9 2011-2021 MATE developers"
)
,
120 "comments", _("This program is responsible for launching other "gettext ("This program is responsible for launching other " "applications and provides useful utilities."
)
121 "applications and provides useful utilities.")gettext ("This program is responsible for launching other " "applications and provides useful utilities."
)
,
122 "authors", authors,
123 "documenters", documenters,
124 "title", _("About the MATE Panel")gettext ("About the MATE Panel"),
125 "translator-credits", _("translator-credits")gettext ("translator-credits"),
126 "logo-icon-name", PANEL_ICON_PANEL"mate-panel",
127 NULL((void*)0));
128
129 gtk_window_set_screen (GTK_WINDOW (about)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((about)), ((gtk_window_get_type ()))))))
,
130 menuitem_to_screen (menuitem));
131 g_signal_connect (about, "destroy",g_signal_connect_data ((about), ("destroy"), (((GCallback) (gtk_widget_destroyed
))), (&about), ((void*)0), (GConnectFlags) 0)
132 G_CALLBACK (gtk_widget_destroyed),g_signal_connect_data ((about), ("destroy"), (((GCallback) (gtk_widget_destroyed
))), (&about), ((void*)0), (GConnectFlags) 0)
133 &about)g_signal_connect_data ((about), ("destroy"), (((GCallback) (gtk_widget_destroyed
))), (&about), ((void*)0), (GConnectFlags) 0)
;
134
135 g_signal_connect (about, "response",g_signal_connect_data ((about), ("response"), (((GCallback) (
gtk_widget_destroy))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
136 G_CALLBACK (gtk_widget_destroy),g_signal_connect_data ((about), ("response"), (((GCallback) (
gtk_widget_destroy))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
137 NULL)g_signal_connect_data ((about), ("response"), (((GCallback) (
gtk_widget_destroy))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
138
139 gtk_widget_show (about);
140}
141
142static void
143panel_context_menu_create_new_panel (GtkWidget *menuitem)
144{
145 panel_profile_create_toplevel (gtk_widget_get_screen (menuitem));
146}
147
148static void
149panel_context_menu_delete_panel (PanelToplevel *toplevel)
150{
151 if (panel_toplevel_is_last_unattached (toplevel)) {
152 panel_error_dialog (GTK_WINDOW (toplevel)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_window_get_type ()))))))
,
153 gtk_window_get_screen (GTK_WINDOW (toplevel)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_window_get_type ()))))))
),
154 "cannot_delete_last_panel", TRUE(!(0)),
155 _("Cannot delete this panel")gettext ("Cannot delete this panel"),
156 _("You must always have at least one panel.")gettext ("You must always have at least one panel."));
157 return;
158 }
159
160 panel_delete (toplevel);
161}
162
163static void
164panel_context_menu_setup_delete_panel_item (GtkWidget *menu,
165 GtkWidget *menuitem)
166{
167 PanelWidget *panel_widget;
168 gboolean sensitive;
169
170 panel_widget = menu_get_panel (menu);
171
172 g_assert (PANEL_IS_TOPLEVEL (panel_widget->toplevel))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((panel_widget->toplevel)); GType __t = ((panel_toplevel_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_assertion_message_expr (((gchar*) 0), "panel-context-menu.c"
, 172, ((const char*) (__func__)), "PANEL_IS_TOPLEVEL (panel_widget->toplevel)"
); } while (0)
;
173
174 sensitive =
175 !panel_toplevel_is_last_unattached (panel_widget->toplevel) &&
176 !panel_lockdown_get_locked_down () &&
177 panel_profile_id_lists_are_writable ();
178
179 gtk_widget_set_sensitive (menuitem, sensitive);
180}
181
182static void
183panel_reset_response (GtkWidget *dialog,
184 int response)
185{
186 if (response == GTK_RESPONSE_OK) {
187 panel_reset ();
188 }
189
190 gtk_widget_destroy (dialog);
191}
192
193static void
194query_panel_reset (PanelToplevel *toplevel)
195{
196 GtkWidget *dialog;
197 char *text1;
198 char *text2;
199
200 text1 = _("Reset all panels?")gettext ("Reset all panels?");
201 text2 = _("When the panels are reset, all \n"gettext ("When the panels are reset, all \n" "custom settings are lost."
)
202 "custom settings are lost.")gettext ("When the panels are reset, all \n" "custom settings are lost."
)
;
203
204 dialog = gtk_message_dialog_new (
205 GTK_WINDOW (toplevel)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_window_get_type ()))))))
,
206 GTK_DIALOG_MODAL,
207 GTK_MESSAGE_WARNING,
208 GTK_BUTTONS_NONE,
209 "%s", text1);
210
211 gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog)((((GtkMessageDialog*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((dialog)), ((gtk_message_dialog_get_type ())
)))))
,
212 "%s", text2);
213 gtk_dialog_add_buttons (GTK_DIALOG (dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_dialog_get_type ()))))))
,
214 _("_Cancel")gettext ("_Cancel"), GTK_RESPONSE_CANCEL,
215 _("_Reset Panels")gettext ("_Reset Panels"), GTK_RESPONSE_OK,
216 NULL((void*)0));
217
218 gtk_dialog_set_default_response (GTK_DIALOG (dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_dialog_get_type ()))))))
, GTK_RESPONSE_CANCEL);
219
220 gtk_window_set_position (GTK_WINDOW (dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_window_get_type ()))))))
, GTK_WIN_POS_CENTER);
221
222 g_signal_connect (dialog, "response",g_signal_connect_data ((dialog), ("response"), (((GCallback) (
panel_reset_response))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
223 G_CALLBACK (panel_reset_response),g_signal_connect_data ((dialog), ("response"), (((GCallback) (
panel_reset_response))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
224 NULL)g_signal_connect_data ((dialog), ("response"), (((GCallback) (
panel_reset_response))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
225
226 gtk_widget_show_all (dialog);
227}
228
229static void
230panel_context_menu_build_edition (PanelWidget *panel_widget,
231 GtkWidget *menu)
232{
233 GtkWidget *menuitem;
234
235 gtk_menu_set_reserve_toggle_size (GTK_MENU (menu)((((GtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((menu)), ((gtk_menu_get_type ()))))))
, FALSE(0));
236
237 menuitem = panel_image_menu_item_new_from_icon ("list-add", _("_Add to Panel…")gettext ("_Add to Panel…"));
238
239 gtk_widget_show (menuitem);
240 gtk_menu_shell_append (GTK_MENU_SHELL (menu)((((GtkMenuShell*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((menu)), ((gtk_menu_shell_get_type ()))))))
, menuitem);
241 g_signal_connect (menuitem, "activate",g_signal_connect_data ((menuitem), ("activate"), (((GCallback
) (panel_addto_present))), (panel_widget), ((void*)0), (GConnectFlags
) 0)
242 G_CALLBACK (panel_addto_present),g_signal_connect_data ((menuitem), ("activate"), (((GCallback
) (panel_addto_present))), (panel_widget), ((void*)0), (GConnectFlags
) 0)
243 panel_widget)g_signal_connect_data ((menuitem), ("activate"), (((GCallback
) (panel_addto_present))), (panel_widget), ((void*)0), (GConnectFlags
) 0)
;
244
245 if (!panel_profile_id_lists_are_writable ())
246 gtk_widget_set_sensitive (menuitem, FALSE(0));
247
248 menuitem = panel_image_menu_item_new_from_icon ("document-properties", _("_Properties")gettext ("_Properties"));
249
250 gtk_widget_show (menuitem);
251 gtk_menu_shell_append (GTK_MENU_SHELL (menu)((((GtkMenuShell*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((menu)), ((gtk_menu_shell_get_type ()))))))
, menuitem);
252 g_signal_connect_swapped (menuitem, "activate",g_signal_connect_data ((menuitem), ("activate"), (((GCallback
) (panel_properties_dialog_present))), (panel_widget->toplevel
), ((void*)0), G_CONNECT_SWAPPED)
253 G_CALLBACK (panel_properties_dialog_present),g_signal_connect_data ((menuitem), ("activate"), (((GCallback
) (panel_properties_dialog_present))), (panel_widget->toplevel
), ((void*)0), G_CONNECT_SWAPPED)
254 panel_widget->toplevel)g_signal_connect_data ((menuitem), ("activate"), (((GCallback
) (panel_properties_dialog_present))), (panel_widget->toplevel
), ((void*)0), G_CONNECT_SWAPPED)
;
255
256 add_menu_separator (menu);
257
258 menuitem = panel_image_menu_item_new_from_icon ("document-revert", _("_Reset All Panels")gettext ("_Reset All Panels"));
259
260 gtk_widget_show (menuitem);
261 gtk_menu_shell_append (GTK_MENU_SHELL (menu)((((GtkMenuShell*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((menu)), ((gtk_menu_shell_get_type ()))))))
, menuitem);
262 g_signal_connect_swapped (menuitem, "activate",g_signal_connect_data ((menuitem), ("activate"), (((GCallback
) (query_panel_reset))), (panel_widget->toplevel), ((void*
)0), G_CONNECT_SWAPPED)
263 G_CALLBACK (query_panel_reset), panel_widget->toplevel)g_signal_connect_data ((menuitem), ("activate"), (((GCallback
) (query_panel_reset))), (panel_widget->toplevel), ((void*
)0), G_CONNECT_SWAPPED)
;
264
265 menuitem = panel_image_menu_item_new_from_icon ("edit-delete", _("_Delete This Panel")gettext ("_Delete This Panel"));
266
267 gtk_widget_show (menuitem);
268 gtk_menu_shell_append (GTK_MENU_SHELL (menu)((((GtkMenuShell*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((menu)), ((gtk_menu_shell_get_type ()))))))
, menuitem);
269 g_signal_connect_swapped (menuitem, "activate",g_signal_connect_data ((menuitem), ("activate"), (((GCallback
) (panel_context_menu_delete_panel))), (panel_widget->toplevel
), ((void*)0), G_CONNECT_SWAPPED)
270 G_CALLBACK (panel_context_menu_delete_panel),g_signal_connect_data ((menuitem), ("activate"), (((GCallback
) (panel_context_menu_delete_panel))), (panel_widget->toplevel
), ((void*)0), G_CONNECT_SWAPPED)
271 panel_widget->toplevel)g_signal_connect_data ((menuitem), ("activate"), (((GCallback
) (panel_context_menu_delete_panel))), (panel_widget->toplevel
), ((void*)0), G_CONNECT_SWAPPED)
;
272 g_signal_connect (menu, "show",g_signal_connect_data ((menu), ("show"), (((GCallback) (panel_context_menu_setup_delete_panel_item
))), (menuitem), ((void*)0), (GConnectFlags) 0)
273 G_CALLBACK (panel_context_menu_setup_delete_panel_item),g_signal_connect_data ((menu), ("show"), (((GCallback) (panel_context_menu_setup_delete_panel_item
))), (menuitem), ((void*)0), (GConnectFlags) 0)
274 menuitem)g_signal_connect_data ((menu), ("show"), (((GCallback) (panel_context_menu_setup_delete_panel_item
))), (menuitem), ((void*)0), (GConnectFlags) 0)
;
275
276 add_menu_separator (menu);
277
278 menuitem = panel_image_menu_item_new_from_icon ("document-new", _("_New Panel")gettext ("_New Panel"));
279
280 gtk_widget_show (menuitem);
281 gtk_menu_shell_append (GTK_MENU_SHELL (menu)((((GtkMenuShell*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((menu)), ((gtk_menu_shell_get_type ()))))))
, menuitem);
282 g_signal_connect (menuitem, "activate",g_signal_connect_data ((menuitem), ("activate"), (((GCallback
) (panel_context_menu_create_new_panel))), (((void*)0)), ((void
*)0), (GConnectFlags) 0)
283 G_CALLBACK (panel_context_menu_create_new_panel),g_signal_connect_data ((menuitem), ("activate"), (((GCallback
) (panel_context_menu_create_new_panel))), (((void*)0)), ((void
*)0), (GConnectFlags) 0)
284 NULL)g_signal_connect_data ((menuitem), ("activate"), (((GCallback
) (panel_context_menu_create_new_panel))), (((void*)0)), ((void
*)0), (GConnectFlags) 0)
;
285 gtk_widget_set_sensitive (menuitem,
286 panel_profile_id_lists_are_writable ());
287
288 add_menu_separator (menu);
289}
290
291GtkWidget *
292panel_context_menu_create (PanelWidget *panel)
293{
294 GtkWidget *retval;
295 GtkWidget *menuitem;
296
297 if (panel->master_widget) {
298 gpointer *pointer;
299 AppletInfo *info;
300
301 pointer = g_object_get_data (G_OBJECT (panel->master_widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((panel->master_widget)), (((GType) ((20) << (2))
))))))
,
302 "applet_info");
303
304 g_assert (pointer != NULL)do { if (pointer != ((void*)0)) ; else g_assertion_message_expr
(((gchar*) 0), "panel-context-menu.c", 304, ((const char*) (
__func__)), "pointer != NULL"); } while (0)
;
305 info = (AppletInfo *) pointer;
Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption
306
307 if (info->menu == NULL((void*)0)) {
308 info->menu = mate_panel_applet_create_menu (info);
309 }
310
311 return info->menu;
312 }
313
314 retval = create_empty_menu ();
315 gtk_widget_set_name (retval, "mate-panel-context-menu");
316
317 if (!panel_lockdown_get_locked_down ())
318 panel_context_menu_build_edition (panel, retval);
319
320 menuitem = panel_image_menu_item_new_from_icon ("help-browser", _("_Help")gettext ("_Help"));
321
322 gtk_widget_show (menuitem);
323 gtk_menu_shell_append (GTK_MENU_SHELL (retval)((((GtkMenuShell*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((retval)), ((gtk_menu_shell_get_type ()))))))
, menuitem);
324 g_signal_connect (menuitem, "activate",g_signal_connect_data ((menuitem), ("activate"), (((GCallback
) (panel_context_menu_show_help))), (((void*)0)), ((void*)0),
(GConnectFlags) 0)
325 G_CALLBACK (panel_context_menu_show_help), NULL)g_signal_connect_data ((menuitem), ("activate"), (((GCallback
) (panel_context_menu_show_help))), (((void*)0)), ((void*)0),
(GConnectFlags) 0)
;
326
327 menuitem = panel_image_menu_item_new_from_icon ("help-about", _("A_bout Panels")gettext ("A_bout Panels"));
328
329 gtk_widget_show (menuitem);
330 gtk_menu_shell_append (GTK_MENU_SHELL (retval)((((GtkMenuShell*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((retval)), ((gtk_menu_shell_get_type ()))))))
, menuitem);
331 g_signal_connect (menuitem, "activate",g_signal_connect_data ((menuitem), ("activate"), (((GCallback
) (panel_context_menu_show_about_dialog))), (((void*)0)), ((void
*)0), (GConnectFlags) 0)
332 G_CALLBACK (panel_context_menu_show_about_dialog),g_signal_connect_data ((menuitem), ("activate"), (((GCallback
) (panel_context_menu_show_about_dialog))), (((void*)0)), ((void
*)0), (GConnectFlags) 0)
333 NULL)g_signal_connect_data ((menuitem), ("activate"), (((GCallback
) (panel_context_menu_show_about_dialog))), (((void*)0)), ((void
*)0), (GConnectFlags) 0)
;
334
335 /* FIXME: can we get rid of this? (needed by menu_get_panel()) */
336 g_object_set_data (G_OBJECT (retval)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((retval)), (((GType) ((20) << (2))))))))
, "menu_panel", panel);
337
338/* Set up theme and transparency support */
339 GtkWidget *toplevel = gtk_widget_get_toplevel (retval);
340/* Fix any failures of compiz/other wm's to communicate with gtk for transparency */
341 GdkScreen *screen = gtk_widget_get_screen(GTK_WIDGET(toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
342 GdkVisual *visual = gdk_screen_get_rgba_visual(screen);
343 gtk_widget_set_visual(GTK_WIDGET(toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
, visual);
344/* Set menu and it's toplevel window to follow panel theme */
345 GtkStyleContext *context;
346 context = gtk_widget_get_style_context (GTK_WIDGET(toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
347 gtk_style_context_add_class(context,"gnome-panel-menu-bar");
348 gtk_style_context_add_class(context,"mate-panel-menu-bar");
349
350 return retval;
351}
diff --git a/2024-06-18-172109-13286-1@e182420b844f_master/report-dcd45f.html b/2024-06-18-172109-13286-1@e182420b844f_master/report-dcd45f.html new file mode 100644 index 00000000..584f2a89 --- /dev/null +++ b/2024-06-18-172109-13286-1@e182420b844f_master/report-dcd45f.html @@ -0,0 +1,6243 @@ + + + +panel-toplevel.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:mate-panel/panel-toplevel.c
Warning:line 2062, column 2
Value stored to 'x' is never read
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name panel-toplevel.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/mate-panel -fcoverage-compilation-dir=/rootdir/mate-panel -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I .. -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/startup-notification-1.0 -I /usr/include/mate-menus -I /usr/include/gio-unix-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/dconf -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/dconf -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I . -I . -I ../mate-panel -I ../mate-panel/mate-submodules -I ../mate-panel/libpanel-util -D MATELOCALEDIR="/usr/local/share/locale" -D PANELDATADIR="/usr/local/share/mate-panel" -I /usr/include/gtk-layer-shell -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/gtk-3.0 -I /usr/include/cloudproviders -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/atk-1.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/gio-unix-2.0 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -D PANEL_MODULES_DIR="/usr/local/lib/mate-panel/modules" -D MATEMENU_I_KNOW_THIS_IS_UNSTABLE -I /usr/include/gtk-layer-shell -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/gtk-3.0 -I /usr/include/cloudproviders -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/atk-1.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/gio-unix-2.0 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-18-172109-13286-1 -x c panel-toplevel.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
2 *
3 * panel-toplevel.c: The panel's toplevel window object.
4 *
5 * Copyright (C) 2003 Sun Microsystems, Inc.
6 * Copyright (C) 2004 Rob Adams
7 * Copyright (C) 2012-2021 MATE Developers
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of the
12 * License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
22 * 02110-1301, USA.
23 *
24 * Authors:
25 * Mark McLoughlin <mark@skynet.ie>
26 */
27
28#include <config.h>
29
30#include "panel-toplevel.h"
31
32#include <stdlib.h>
33#include <string.h>
34
35#include <gtk/gtk.h>
36#include <gdk/gdkkeysyms.h>
37#include <glib/gi18n.h>
38
39#ifdef HAVE_X111
40#include <gdk/gdkx.h>
41#endif
42
43#include "panel-util.h"
44#include "panel-profile.h"
45#include "panel-frame.h"
46#include "panel-multimonitor.h"
47#include "panel-a11y.h"
48#include "panel-typebuiltins.h"
49#include "panel-marshal.h"
50#include "panel-widget.h"
51#include "panel-bindings.h"
52#include "panel-config-global.h"
53#include "panel-lockdown.h"
54#include "panel-schemas.h"
55
56#ifdef HAVE_X111
57#include "xstuff.h"
58#include "panel-xutils.h"
59#include "panel-struts.h"
60#endif
61#ifdef HAVE_WAYLAND1
62#include "wayland-backend.h"
63#endif
64
65#define DEFAULT_SIZE48 48
66#define DEFAULT_AUTO_HIDE_SIZE1 1
67#define DEFAULT_HIDE_DELAY300 300
68#define DEFAULT_UNHIDE_DELAY100 100
69#define DEFAULT_DND_THRESHOLD8 8
70#define MINIMUM_WIDTH100 100
71#define MAXIMUM_SIZE_SCREEN_RATIO5 5
72#define SNAP_TOLERANCE_FACTOR6 6
73#define DEFAULT_ARROW_SIZE20 20
74#define HANDLE_SIZE10 10
75#define N_ATTACH_TOPLEVEL_SIGNALS5 5
76#define N_ATTACH_WIDGET_SIGNALS5 5
77
78typedef enum {
79 PANEL_GRAB_OP_NONE,
80 PANEL_GRAB_OP_MOVE,
81 PANEL_GRAB_OP_RESIZE,
82 PANEL_GRAB_OP_RESIZE_UP,
83 PANEL_GRAB_OP_RESIZE_DOWN,
84 PANEL_GRAB_OP_RESIZE_LEFT,
85 PANEL_GRAB_OP_RESIZE_RIGHT
86} PanelGrabOpType;
87
88struct _PanelToplevelPrivate {
89 gchar *settings_path;
90
91 gboolean expand;
92 PanelOrientation orientation;
93 int size;
94 gint scale;
95
96 /* relative to the monitor origin */
97 int x;
98 int y;
99 /* relative to the bottom right corner, -1 to ignore and use x, y*/
100 int x_right;
101 int y_bottom;
102
103 int monitor;
104 /* this is used when the configured monitor is missing. We keep it so
105 * we can move the toplevel to the right monitor when it becomes
106 * available */
107 int configured_monitor;
108
109 int hide_delay;
110 int unhide_delay;
111 int auto_hide_size;
112 PanelAnimationSpeed animation_speed;
113
114 int snap_tolerance;
115 GtkSettings *gtk_settings;
116
117 PanelState state;
118
119 char *name;
120 char *description;
121
122 guint hide_timeout;
123 guint unhide_timeout;
124
125 GdkRectangle geometry;
126 PanelFrameEdge edges;
127
128 int original_width;
129 int original_height;
130
131 PanelGrabOpType grab_op;
132
133 /* The offset within the panel from which the panel
134 * drag was initiated relative to the screen origin.
135 */
136 int drag_offset_x;
137 int drag_offset_y;
138
139 /* Saved state before for cancelled grab op */
140 int orig_monitor;
141 int orig_x;
142 int orig_y;
143 int orig_x_right;
144 int orig_y_bottom;
145 int orig_size;
146 int orig_orientation;
147
148 /* relative to the monitor origin */
149 int animation_end_x;
150 int animation_end_y;
151 int animation_end_width;
152 int animation_end_height;
153 gint64 animation_start_time; /* monotonic start time in microseconds */
154 GTimeSpan animation_duration_time; /* monotonic duration time in microseconds */
155 guint animation_timeout;
156
157 PanelWidget *panel_widget;
158 PanelFrame *inner_frame;
159 GtkWidget *grid;
160 GtkWidget *hide_button_top;
161 GtkWidget *hide_button_bottom;
162 GtkWidget *hide_button_left;
163 GtkWidget *hide_button_right;
164
165 PanelToplevel *attach_toplevel;
166 gulong attach_toplevel_signals [N_ATTACH_TOPLEVEL_SIGNALS5];
167 GtkWidget *attach_widget;
168 gulong attach_widget_signals [N_ATTACH_WIDGET_SIGNALS5];
169 gint n_autohide_disablers;
170
171 guint auto_hide : 1;
172 guint animate : 1;
173 guint buttons_enabled : 1;
174 guint arrows_enabled : 1;
175
176 /* The co-ordinates are relative to center screen */
177 guint x_centered : 1;
178 guint y_centered : 1;
179
180 /* The panel is not lined up with th screen edge */
181 guint floating : 1;
182
183 /* We are currently animating a hide/show */
184 guint animating : 1;
185
186 /* This is a keyboard initiated grab operation */
187 guint grab_is_keyboard : 1;
188
189 /* The x-y co-ordinates temporarily specify the panel center.
190 * This is used when the panel is rotating, because the width/height
191 * of the toplevel might change, so we need to compute new values for
192 * those. */
193 guint position_centered : 1;
194
195 /* The toplevel is "attached" to another widget */
196 guint attached : 1;
197
198 /* Hidden temporarily because the attach_toplevel was hidden */
199 guint attach_hidden : 1;
200
201 /* More saved grab op state */
202 guint orig_x_centered : 1;
203 guint orig_y_centered : 1;
204
205 /* flag to see if we have already done geometry updating,
206 if not then we're still loading and can ignore many things */
207 guint updated_geometry_initial : 1;
208 /* flag to see if we have done the initial animation */
209 guint initial_animation_done : 1;
210};
211
212enum {
213 HIDE_SIGNAL,
214 UNHIDE_SIGNAL,
215 POPUP_PANEL_MENU_SIGNAL,
216 TOGGLE_EXPAND_SIGNAL,
217 EXPAND_SIGNAL,
218 UNEXPAND_SIGNAL,
219 TOGGLE_HIDDEN_SIGNAL,
220 BEGIN_MOVE_SIGNAL,
221 BEGIN_RESIZE_SIGNAL,
222 LAST_SIGNAL
223};
224
225enum {
226 PROP_0,
227 PROP_NAME,
228 PROP_SETTINGS_PATH,
229 PROP_EXPAND,
230 PROP_ORIENTATION,
231 PROP_SIZE,
232 PROP_X,
233 PROP_X_RIGHT,
234 PROP_X_CENTERED,
235 PROP_Y,
236 PROP_Y_BOTTOM,
237 PROP_Y_CENTERED,
238 PROP_MONITOR,
239 PROP_AUTOHIDE,
240 PROP_HIDE_DELAY,
241 PROP_UNHIDE_DELAY,
242 PROP_AUTOHIDE_SIZE,
243 PROP_ANIMATE,
244 PROP_ANIMATION_SPEED,
245 PROP_BUTTONS_ENABLED,
246 PROP_ARROWS_ENABLED
247};
248
249G_DEFINE_TYPE_WITH_PRIVATE (PanelToplevel, panel_toplevel, GTK_TYPE_WINDOW)static void panel_toplevel_init (PanelToplevel *self); static
void panel_toplevel_class_init (PanelToplevelClass *klass); static
GType panel_toplevel_get_type_once (void); static gpointer panel_toplevel_parent_class
= ((void*)0); static gint PanelToplevel_private_offset; static
void panel_toplevel_class_intern_init (gpointer klass) { panel_toplevel_parent_class
= g_type_class_peek_parent (klass); if (PanelToplevel_private_offset
!= 0) g_type_class_adjust_private_offset (klass, &PanelToplevel_private_offset
); panel_toplevel_class_init ((PanelToplevelClass*) klass); }
__attribute__ ((__unused__)) static inline gpointer panel_toplevel_get_instance_private
(PanelToplevel *self) { return (((gpointer) ((guint8*) (self
) + (glong) (PanelToplevel_private_offset)))); } GType panel_toplevel_get_type
(void) { static GType static_g_define_type_id = 0; if ((__extension__
({ _Static_assert (sizeof *(&static_g_define_type_id) ==
sizeof (gpointer), "Expression evaluates to false"); (void) (
0 ? (gpointer) * (&static_g_define_type_id) : ((void*)0))
; (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter_pointer (
&static_g_define_type_id)); })) ) { GType g_define_type_id
= panel_toplevel_get_type_once (); (__extension__ ({ _Static_assert
(sizeof *(&static_g_define_type_id) == sizeof (gpointer)
, "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id
) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer
((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id
)); })) ; } return static_g_define_type_id; } __attribute__ (
(__noinline__)) static GType panel_toplevel_get_type_once (void
) { GType g_define_type_id = g_type_register_static_simple ((
gtk_window_get_type ()), g_intern_static_string ("PanelToplevel"
), sizeof (PanelToplevelClass), (GClassInitFunc)(void (*)(void
)) panel_toplevel_class_intern_init, sizeof (PanelToplevel), (
GInstanceInitFunc)(void (*)(void)) panel_toplevel_init, (GTypeFlags
) 0); { {{ PanelToplevel_private_offset = g_type_add_instance_private
(g_define_type_id, sizeof (PanelToplevelPrivate)); };} } return
g_define_type_id; }
250
251static guint toplevel_signals[LAST_SIGNAL] = {0};
252static GSList* toplevel_list = NULL((void*)0);
253
254static void panel_toplevel_calculate_animation_end_geometry(PanelToplevel *toplevel);
255
256static void panel_toplevel_update_monitor(PanelToplevel* toplevel);
257static void panel_toplevel_set_monitor_internal(PanelToplevel* toplevel, int monitor, gboolean force_resize);
258
259static void panel_toplevel_drag_threshold_changed (PanelToplevel *toplevel);
260
261static void
262update_style_classes (PanelToplevel *toplevel)
263{
264 GtkStyleContext *context;
265
266 context = gtk_widget_get_style_context (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
267
268 /*ensure the panel BG can always be themed*/
269 /*Without this gtk3.19/20 cannot set the BG color and resetting the bg to system is not immediately applied*/
270 gtk_style_context_add_class(context,"gnome-panel-menu-bar");
271 gtk_style_context_add_class(context,"mate-panel-menu-bar");
272
273 gtk_style_context_remove_class (context, GTK_STYLE_CLASS_HORIZONTAL"horizontal");
274 gtk_style_context_remove_class (context, GTK_STYLE_CLASS_VERTICAL"vertical");
275 gtk_style_context_remove_class (context, GTK_STYLE_CLASS_RIGHT"right");
276 gtk_style_context_remove_class (context, GTK_STYLE_CLASS_LEFT"left");
277 gtk_style_context_remove_class (context, GTK_STYLE_CLASS_TOP"top");
278 gtk_style_context_remove_class (context, GTK_STYLE_CLASS_BOTTOM"bottom");
279
280 switch (toplevel->priv->orientation) {
281 case PANEL_ORIENTATION_TOP:
282 gtk_style_context_add_class (context, GTK_STYLE_CLASS_HORIZONTAL"horizontal");
283 gtk_style_context_add_class (context, GTK_STYLE_CLASS_TOP"top");
284 break;
285
286 case PANEL_ORIENTATION_LEFT:
287 gtk_style_context_add_class (context, GTK_STYLE_CLASS_VERTICAL"vertical");
288 gtk_style_context_add_class (context, GTK_STYLE_CLASS_LEFT"left");
289 break;
290
291 case PANEL_ORIENTATION_BOTTOM:
292 gtk_style_context_add_class (context, GTK_STYLE_CLASS_HORIZONTAL"horizontal");
293 gtk_style_context_add_class (context, GTK_STYLE_CLASS_BOTTOM"bottom");
294 break;
295
296 case PANEL_ORIENTATION_RIGHT:
297 gtk_style_context_add_class (context, GTK_STYLE_CLASS_VERTICAL"vertical");
298 gtk_style_context_add_class (context, GTK_STYLE_CLASS_RIGHT"right");
299 break;
300
301 default:
302 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 302, ((const char*) (__func__)), ((void*)0)); } while (0)
;
303 break;
304 }
305}
306
307GSList* panel_toplevel_list_toplevels(void)
308{
309 return toplevel_list;
310}
311
312/* Is this the last un-attached toplevel? */
313gboolean panel_toplevel_is_last_unattached(PanelToplevel* toplevel)
314{
315 GSList* l;
316
317 if (panel_toplevel_get_is_attached(toplevel))
318 {
319 return FALSE(0);
320 }
321
322 for (l = toplevel_list; l; l = l->next)
323 {
324 PanelToplevel* t = l->data;
325
326 if (t != toplevel && !panel_toplevel_get_is_attached(t))
327 {
328 return FALSE(0);
329 }
330 }
331
332 return TRUE(!(0));
333}
334
335static void panel_toplevel_get_monitor_geometry(PanelToplevel* toplevel, GdkRectangle *geom)
336{
337 g_return_if_fail(PANEL_IS_TOPLEVEL(toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL(toplevel)"); return; } } while
(0)
;
338 g_return_if_fail(geom)do { if ((geom)) { } else { g_return_if_fail_warning (((gchar
*) 0), ((const char*) (__func__)), "geom"); return; } } while
(0)
;
339
340 geom->x = panel_multimonitor_x(toplevel->priv->monitor);
341 geom->y = panel_multimonitor_y(toplevel->priv->monitor);
342 geom->width = panel_multimonitor_width(toplevel->priv->monitor);
343 geom->height = panel_multimonitor_height(toplevel->priv->monitor);
344}
345
346static GdkCursorType panel_toplevel_grab_op_cursor(PanelToplevel* toplevel, PanelGrabOpType grab_op)
347{
348 GdkCursorType retval = -1;
349
350 switch (grab_op) {
351 case PANEL_GRAB_OP_MOVE:
352 case PANEL_GRAB_OP_RESIZE:
353 if (toplevel->priv->grab_is_keyboard)
354 retval = GDK_CROSS;
355 else
356 retval = GDK_FLEUR;
357 break;
358 case PANEL_GRAB_OP_RESIZE_UP:
359 retval = GDK_TOP_SIDE;
360 break;
361 case PANEL_GRAB_OP_RESIZE_DOWN:
362 retval = GDK_BOTTOM_SIDE;
363 break;
364 case PANEL_GRAB_OP_RESIZE_LEFT:
365 retval = GDK_LEFT_SIDE;
366 break;
367 case PANEL_GRAB_OP_RESIZE_RIGHT:
368 retval = GDK_RIGHT_SIDE;
369 break;
370 default:
371 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 371, ((const char*) (__func__)), ((void*)0)); } while (0)
;
372 break;
373 }
374
375 return retval;
376}
377
378#ifdef HAVE_X111
379static void panel_toplevel_init_resize_drag_offsets(PanelToplevel* toplevel, PanelGrabOpType grab_op)
380{
381 g_assert (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel))))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((gtk_widget_get_display (((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((toplevel)), ((gtk_widget_get_type ()))))
))))); GType __t = ((gdk_x11_display_get_type())); gboolean __r
; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))) ; else
g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c", 381
, ((const char*) (__func__)), "GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel)))"
); } while (0)
;
382
383 toplevel->priv->drag_offset_x = 0;
384 toplevel->priv->drag_offset_y = 0;
385
386 switch (grab_op) {
387 case PANEL_GRAB_OP_RESIZE_DOWN:
388 toplevel->priv->drag_offset_y = toplevel->priv->geometry.y;
389 break;
390 case PANEL_GRAB_OP_RESIZE_UP:
391 toplevel->priv->drag_offset_y =
392 toplevel->priv->geometry.y + toplevel->priv->geometry.height;
393 break;
394 case PANEL_GRAB_OP_RESIZE_RIGHT:
395 toplevel->priv->drag_offset_x = toplevel->priv->geometry.x;
396 break;
397 case PANEL_GRAB_OP_RESIZE_LEFT:
398 toplevel->priv->drag_offset_x =
399 toplevel->priv->geometry.x + toplevel->priv->geometry.width;
400 break;
401 default:
402 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 402, ((const char*) (__func__)), ((void*)0)); } while (0)
;
403 break;
404 }
405}
406
407static void panel_toplevel_warp_pointer(PanelToplevel* toplevel)
408{
409 GtkWidget *widget;
410 GdkRectangle geometry;
411 int x, y;
412
413 widget = GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
;
414 g_return_if_fail (GDK_IS_X11_DISPLAY (gtk_widget_get_display (widget)))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((gtk_widget_get_display (widget))); GType __t = ((gdk_x11_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0
), ((const char*) (__func__)), "GDK_IS_X11_DISPLAY (gtk_widget_get_display (widget))"
); return; } } while (0)
;
415
416 geometry = toplevel->priv->geometry;
417
418 x = y = 0;
419
420 switch (toplevel->priv->grab_op) {
421 case PANEL_GRAB_OP_MOVE:
422 case PANEL_GRAB_OP_RESIZE:
423 x = (geometry.width / 2);
424 y = (geometry.height / 2);
425 break;
426 case PANEL_GRAB_OP_RESIZE_UP:
427 x = (geometry.width / 2);
428 break;
429 case PANEL_GRAB_OP_RESIZE_DOWN:
430 x = (geometry.width / 2);
431 y = geometry.height;
432 break;
433 case PANEL_GRAB_OP_RESIZE_LEFT:
434 y = (geometry.height / 2);
435 break;
436 case PANEL_GRAB_OP_RESIZE_RIGHT:
437 x = geometry.width;
438 y = (geometry.height / 2);
439 break;
440 default:
441 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 441, ((const char*) (__func__)), ((void*)0)); } while (0)
;
442 break;
443 }
444
445 if (toplevel->priv->grab_op == PANEL_GRAB_OP_MOVE ||
446 toplevel->priv->grab_op == PANEL_GRAB_OP_RESIZE) {
447 toplevel->priv->drag_offset_x = x;
448 toplevel->priv->drag_offset_y = y;
449 } else
450 panel_toplevel_init_resize_drag_offsets (toplevel, toplevel->priv->grab_op);
451
452 panel_warp_pointer (gtk_widget_get_window (widget), x, y);
453}
454#endif /* HAVE_X11 */
455
456static void panel_toplevel_begin_attached_move(PanelToplevel* toplevel, gboolean is_keyboard, guint32 time_)
457{
458 PanelWidget *attached_panel_widget;
459
460 attached_panel_widget = panel_toplevel_get_panel_widget (toplevel->priv->attach_toplevel);
461
462 panel_widget_applet_drag_start (attached_panel_widget,
463 toplevel->priv->attach_widget,
464 is_keyboard ? PW_DRAG_OFF_CENTER-2 : PW_DRAG_OFF_CURSOR-1,
465 time_);
466}
467
468static void panel_toplevel_begin_grab_op(PanelToplevel* toplevel, PanelGrabOpType op_type, gboolean grab_keyboard, guint32 time_)
469{
470 GtkWidget *widget;
471 GdkWindow *window;
472 GdkCursorType cursor_type;
473 GdkCursor *cursor;
474 GdkDisplay *display;
475 GdkSeat *seat;
476 GdkSeatCapabilities capabilities;
477
478 if (toplevel->priv->state != PANEL_STATE_NORMAL ||
479 toplevel->priv->grab_op != PANEL_GRAB_OP_NONE)
480 return;
481
482 if (panel_lockdown_get_locked_down ())
483 return;
484
485 /* If any of the position/orientation are not writable,
486 then we can't really move freely */
487 if (op_type == PANEL_GRAB_OP_MOVE &&
488 ! panel_profile_can_be_moved_freely (toplevel))
489 return;
490
491 /* If size is not writable, then we can't resize */
492 if ((op_type == PANEL_GRAB_OP_RESIZE ||
493 op_type == PANEL_GRAB_OP_RESIZE_UP ||
494 op_type == PANEL_GRAB_OP_RESIZE_DOWN ||
495 op_type == PANEL_GRAB_OP_RESIZE_LEFT ||
496 op_type == PANEL_GRAB_OP_RESIZE_RIGHT) &&
497 ! panel_profile_key_is_writable (toplevel, PANEL_TOPLEVEL_SIZE_KEY"size"))
498 return;
499
500 if (toplevel->priv->attached && op_type == PANEL_GRAB_OP_MOVE) {
501 panel_toplevel_begin_attached_move (toplevel, grab_keyboard, time_);
502 return;
503 }
504
505 widget = GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
;
506 window = gtk_widget_get_window (widget);
507
508 toplevel->priv->grab_op = op_type;
509 toplevel->priv->grab_is_keyboard = (grab_keyboard != FALSE(0));
510
511 toplevel->priv->orig_monitor = toplevel->priv->monitor;
512 toplevel->priv->orig_x = toplevel->priv->x;
513 toplevel->priv->orig_x_right = toplevel->priv->x_right;
514 toplevel->priv->orig_x_centered = toplevel->priv->x_centered;
515 toplevel->priv->orig_y = toplevel->priv->y;
516 toplevel->priv->orig_y_bottom = toplevel->priv->y_bottom;
517 toplevel->priv->orig_y_centered = toplevel->priv->y_centered;
518 toplevel->priv->orig_size = toplevel->priv->size;
519 toplevel->priv->orig_orientation = toplevel->priv->orientation;
520
521 gtk_grab_add (widget);
522
523#ifdef HAVE_X111
524 if (GDK_IS_X11_DISPLAY (gtk_widget_get_display (widget))(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gtk_widget_get_display (widget))); GType __t = ((gdk_x11_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
&&
525 toplevel->priv->grab_is_keyboard) {
526 panel_toplevel_warp_pointer (toplevel);
527 }
528#endif /* HAVE_X11 */
529
530 cursor_type = panel_toplevel_grab_op_cursor (
531 toplevel, toplevel->priv->grab_op);
532
533 cursor = gdk_cursor_new_for_display (gdk_display_get_default (),
534 cursor_type);
535 display = gdk_window_get_display (window);
536 seat = gdk_display_get_default_seat (display);
537 capabilities = GDK_SEAT_CAPABILITY_POINTER;
538 if (grab_keyboard)
539 capabilities |= GDK_SEAT_CAPABILITY_KEYBOARD;
540
541 gdk_seat_grab (seat, window, capabilities, FALSE(0), cursor,
542 NULL((void*)0), NULL((void*)0), NULL((void*)0));
543
544 g_object_unref (cursor);
545}
546
547static void panel_toplevel_end_grab_op (PanelToplevel* toplevel, guint32 time_)
548{
549 GtkWidget *widget;
550 GdkDisplay *display;
551 GdkSeat *seat;
552
553 g_return_if_fail (toplevel->priv->grab_op != PANEL_GRAB_OP_NONE)do { if ((toplevel->priv->grab_op != PANEL_GRAB_OP_NONE
)) { } else { g_return_if_fail_warning (((gchar*) 0), ((const
char*) (__func__)), "toplevel->priv->grab_op != PANEL_GRAB_OP_NONE"
); return; } } while (0)
;
554
555 widget = GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
;
556
557 toplevel->priv->grab_op = PANEL_GRAB_OP_NONE;
558 toplevel->priv->grab_is_keyboard = FALSE(0);
559
560 gtk_grab_remove (widget);
561
562 display = gtk_widget_get_display (widget);
563 seat = gdk_display_get_default_seat (display);
564
565 gdk_seat_ungrab (seat);
566}
567
568static void panel_toplevel_cancel_grab_op(PanelToplevel* toplevel, guint32 time_)
569{
570 panel_toplevel_set_orientation (toplevel, toplevel->priv->orig_orientation);
571 panel_toplevel_set_monitor (toplevel, toplevel->priv->orig_monitor);
572 panel_toplevel_set_size (toplevel, toplevel->priv->orig_size);
573 panel_toplevel_set_x (toplevel,
574 toplevel->priv->orig_x,
575 toplevel->priv->orig_x_right,
576 toplevel->priv->orig_x_centered);
577 panel_toplevel_set_y (toplevel,
578 toplevel->priv->orig_y,
579 toplevel->priv->orig_y_bottom,
580 toplevel->priv->orig_y_centered);
581}
582
583static void panel_toplevel_resize_to_pointer(PanelToplevel* toplevel, int x, int y)
584{
585 int new_size;
586 int new_x, new_y;
587 int new_x_right, new_y_bottom;
588 int new_x_centered, new_y_centered;
589 GdkRectangle monitor_geom;
590
591 new_size = toplevel->priv->size;
592 new_x = toplevel->priv->x;
593 new_y = toplevel->priv->y;
594 new_x_right = toplevel->priv->x_right;
595 new_y_bottom = toplevel->priv->y_bottom;
596 new_x_centered = toplevel->priv->x_centered;
597 new_y_centered = toplevel->priv->y_centered;
598
599 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
600
601 switch (toplevel->priv->grab_op) {
602 case PANEL_GRAB_OP_RESIZE_UP:
603 new_size = toplevel->priv->drag_offset_y - y;
604 new_size = CLAMP (new_size, 0, monitor_geom.height / 4)(((new_size) > (monitor_geom.height / 4)) ? (monitor_geom.
height / 4) : (((new_size) < (0)) ? (0) : (new_size)))
;
605 new_y -= (new_size - toplevel->priv->size);
606 if (!toplevel->priv->y_centered && (new_y + new_size / 2) > monitor_geom.height / 2)
607 new_y_bottom = monitor_geom.height - (new_y + new_size);
608 else
609 new_y_bottom = -1;
610 break;
611 case PANEL_GRAB_OP_RESIZE_DOWN:
612 new_size = y - toplevel->priv->drag_offset_y;
613 new_size = CLAMP (new_size, 0, monitor_geom.height / 4)(((new_size) > (monitor_geom.height / 4)) ? (monitor_geom.
height / 4) : (((new_size) < (0)) ? (0) : (new_size)))
;
614 if (!toplevel->priv->y_centered && (new_y + new_size / 2) > monitor_geom.height / 2)
615 new_y_bottom = monitor_geom.height - (new_y + new_size);
616 else
617 new_y_bottom = -1;
618 break;
619 case PANEL_GRAB_OP_RESIZE_LEFT:
620 new_size = toplevel->priv->drag_offset_x - x;
621 new_size = CLAMP (new_size, 0, monitor_geom.width / 4)(((new_size) > (monitor_geom.width / 4)) ? (monitor_geom.width
/ 4) : (((new_size) < (0)) ? (0) : (new_size)))
;
622 new_x -= (new_size - toplevel->priv->size);
623 if (!toplevel->priv->x_centered && (new_x + new_size / 2) > monitor_geom.width / 2)
624 new_x_right = monitor_geom.width - (new_x + new_size);
625 else
626 new_x_right = -1;
627 break;
628 case PANEL_GRAB_OP_RESIZE_RIGHT:
629 new_size = x - toplevel->priv->drag_offset_x;
630 new_size = CLAMP (new_size, 0, monitor_geom.width / 4)(((new_size) > (monitor_geom.width / 4)) ? (monitor_geom.width
/ 4) : (((new_size) < (0)) ? (0) : (new_size)))
;
631 if (!toplevel->priv->x_centered && (new_x + new_size / 2) > monitor_geom.width / 2)
632 new_x_right = monitor_geom.width - (new_x + new_size);
633 else
634 new_x_right = -1;
635 break;
636 default:
637 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 637, ((const char*) (__func__)), ((void*)0)); } while (0)
;
638 break;
639 }
640
641 if (new_size == 0)
642 return;
643
644 panel_toplevel_set_x (toplevel, new_x, new_x_right, new_x_centered);
645 panel_toplevel_set_y (toplevel, new_y, new_y_bottom, new_y_centered);
646 panel_toplevel_set_size (toplevel, new_size);
647}
648
649/* this is called for expanded panels that are dragged around */
650static void panel_toplevel_calc_new_orientation(PanelToplevel* toplevel, int pointer_x, int pointer_y)
651{
652 PanelOrientation new_orientation;
653 int hborder, vborder;
654 int monitor;
655 int monitor_width, monitor_height;
656 int new_x, new_y;
657
658 monitor = panel_multimonitor_get_monitor_at_point (pointer_x, pointer_y);
659
660 if (toplevel->priv->geometry.height < toplevel->priv->geometry.width)
661 vborder = hborder = (3 * toplevel->priv->geometry.height) >> 1;
662 else
663 vborder = hborder = (3 * toplevel->priv->geometry.width) >> 1;
664
665 new_x = pointer_x - panel_multimonitor_x (monitor);
666 new_y = pointer_y - panel_multimonitor_y (monitor);
667 monitor_width = panel_multimonitor_width (monitor);
668 monitor_height = panel_multimonitor_height (monitor);
669
670 new_orientation = toplevel->priv->orientation;
671
672 switch (toplevel->priv->orientation) {
673 case PANEL_ORIENTATION_TOP:
674 if (new_y > (monitor_height - hborder))
675 new_orientation = PANEL_ORIENTATION_BOTTOM;
676
677 else if (new_y > hborder) {
678 if (new_x > (monitor_width - vborder))
679 new_orientation = PANEL_ORIENTATION_RIGHT;
680 else if (new_x < vborder)
681 new_orientation = PANEL_ORIENTATION_LEFT;
682 }
683 break;
684 case PANEL_ORIENTATION_BOTTOM:
685 if (new_y < hborder)
686 new_orientation = PANEL_ORIENTATION_TOP;
687
688 else if (new_y < (monitor_height - hborder)) {
689 if (new_x > (monitor_width - vborder))
690 new_orientation = PANEL_ORIENTATION_RIGHT;
691 else if (new_x < vborder)
692 new_orientation = PANEL_ORIENTATION_LEFT;
693 }
694 break;
695 case PANEL_ORIENTATION_LEFT:
696 if (new_x > (monitor_width - vborder))
697 new_orientation = PANEL_ORIENTATION_RIGHT;
698
699 else if (new_x > vborder) {
700 if (new_y > (monitor_height - hborder))
701 new_orientation = PANEL_ORIENTATION_BOTTOM;
702 else if (new_y < hborder)
703 new_orientation = PANEL_ORIENTATION_TOP;
704 }
705 break;
706 case PANEL_ORIENTATION_RIGHT:
707 if (new_x < vborder)
708 new_orientation = PANEL_ORIENTATION_LEFT;
709
710 else if (new_x < (monitor_width - vborder)) {
711 if (new_y > (monitor_height - hborder))
712 new_orientation = PANEL_ORIENTATION_BOTTOM;
713 else if (new_y < hborder)
714 new_orientation = PANEL_ORIENTATION_TOP;
715 }
716 break;
717 default:
718 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 718, ((const char*) (__func__)), ((void*)0)); } while (0)
;
719 break;
720 }
721
722 panel_toplevel_set_monitor (toplevel, monitor);
723 panel_toplevel_set_orientation (toplevel, new_orientation);
724}
725
726static void panel_toplevel_move_to(PanelToplevel* toplevel, int new_x, int new_y)
727{
728 PanelOrientation new_orientation;
729 gboolean x_centered, y_centered;
730 GdkPoint display_min, display_max;
731 GdkRectangle monitor_geom;
732 int width, height;
733 int new_monitor;
734 int x, y, x_right, y_bottom;
735 int snap_tolerance;
736
737 panel_multimonitor_get_bounds (&display_min, &display_max);
738
739 width = toplevel->priv->geometry.width;
740 height = toplevel->priv->geometry.height;
741
742 snap_tolerance = toplevel->priv->snap_tolerance;
743
744 new_x = CLAMP (new_x, 0, display_max.x - width)(((new_x) > (display_max.x - width)) ? (display_max.x - width
) : (((new_x) < (0)) ? (0) : (new_x)))
;
745 new_y = CLAMP (new_y, 0, display_max.y - height)(((new_y) > (display_max.y - height)) ? (display_max.y - height
) : (((new_y) < (0)) ? (0) : (new_y)))
;
746
747 new_orientation = toplevel->priv->orientation;
748
749 if (new_x <= (display_min.x + snap_tolerance) &&
750 toplevel->priv->orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT))
751 new_orientation = PANEL_ORIENTATION_LEFT;
752
753 else if ((new_x + width) >= (display_max.x - snap_tolerance) &&
754 toplevel->priv->orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT))
755 new_orientation = PANEL_ORIENTATION_RIGHT;
756
757 if (new_y <= (display_min.y + snap_tolerance) &&
758 toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM))
759 new_orientation = PANEL_ORIENTATION_TOP;
760
761 else if ((new_y + height) >= (display_max.y - snap_tolerance) &&
762 toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM))
763 new_orientation = PANEL_ORIENTATION_BOTTOM;
764
765 new_monitor = panel_multimonitor_get_monitor_at_point (new_x, new_y);
766
767 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
768
769 x_centered = toplevel->priv->x_centered;
770 y_centered = toplevel->priv->y_centered;
771
772 x = new_x - panel_multimonitor_x (new_monitor);
773 y = new_y - panel_multimonitor_y (new_monitor);
774
775 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)) {
776 if (new_y <= display_min.y + snap_tolerance ||
777 new_y + height >= display_max.y - snap_tolerance)
778 x_centered = abs (x - ((monitor_geom.width - width) / 2))
779 <= snap_tolerance;
780 else
781 x_centered = FALSE(0);
782 } else {
783 if (new_x <= display_min.x + snap_tolerance ||
784 new_x + width >= display_max.x - snap_tolerance)
785 y_centered = abs (y - ((monitor_geom.height - height) / 2))
786 <= snap_tolerance;
787 else
788 y_centered = FALSE(0);
789 }
790
791 if (x_centered)
792 x = (monitor_geom.width - width) / 2;
793 if (y_centered)
794 y = (monitor_geom.height - height) / 2;
795
796 if (!x_centered && (x + width / 2) > monitor_geom.width / 2)
797 x_right = monitor_geom.width - (x + width);
798 else
799 x_right = -1;
800
801 if (!y_centered && (y + height / 2) > monitor_geom.height / 2)
802 y_bottom = monitor_geom.height - (y + height);
803 else
804 y_bottom = -1;
805
806 panel_toplevel_set_monitor (toplevel, new_monitor);
807 panel_toplevel_set_orientation (toplevel, new_orientation);
808 panel_toplevel_set_x (toplevel, x, x_right, x_centered);
809 panel_toplevel_set_y (toplevel, y, y_bottom, y_centered);
810}
811
812static void panel_toplevel_move_to_pointer(PanelToplevel* toplevel, int pointer_x, int pointer_y)
813{
814 int new_x, new_y;
815
816 new_x = pointer_x - toplevel->priv->drag_offset_x;
817 new_y = pointer_y - toplevel->priv->drag_offset_y;
818
819 panel_toplevel_move_to (toplevel, new_x, new_y);
820}
821
822static void panel_toplevel_rotate_to_pointer(PanelToplevel* toplevel, int pointer_x, int pointer_y)
823{
824 int x_diff, y_diff;
825 int x, y;
826 int snap_tolerance;
827
828 x = toplevel->priv->geometry.x;
829 y = toplevel->priv->geometry.y;
830 snap_tolerance = toplevel->priv->snap_tolerance;
831
832 x_diff = pointer_x - (x + toplevel->priv->geometry.width / 2);
833 y_diff = pointer_y - (y + toplevel->priv->geometry.height / 2);
834
835 if (((-y_diff > x_diff + snap_tolerance) && x_diff > 0 && y_diff < 0) ||
836 (( y_diff < x_diff + snap_tolerance) && x_diff < 0 && y_diff < 0))
837 panel_toplevel_set_orientation (toplevel, PANEL_ORIENTATION_RIGHT);
838
839 else if (((-x_diff < y_diff - snap_tolerance) && x_diff > 0 && y_diff < 0) ||
840 (( x_diff > y_diff - snap_tolerance) && x_diff > 0 && y_diff > 0))
841 panel_toplevel_set_orientation (toplevel, PANEL_ORIENTATION_BOTTOM);
842
843 else if ((( y_diff > x_diff + snap_tolerance) && x_diff > 0 && y_diff > 0) ||
844 ((-y_diff < x_diff + snap_tolerance) && x_diff < 0 && y_diff > 0))
845 panel_toplevel_set_orientation (toplevel, PANEL_ORIENTATION_LEFT);
846
847 else if (((-x_diff > y_diff - snap_tolerance) && x_diff < 0 && y_diff > 0) ||
848 (( x_diff < y_diff - snap_tolerance) && x_diff < 0 && y_diff < 0))
849 panel_toplevel_set_orientation (toplevel, PANEL_ORIENTATION_TOP);
850}
851
852#ifdef HAVE_X111
853static gboolean panel_toplevel_warp_pointer_increment(PanelToplevel* toplevel, int keyval, int increment)
854{
855 GdkScreen *screen;
856 GdkWindow *root_window;
857 GdkDevice *device;
858 int new_x, new_y;
859
860 screen = gtk_window_get_screen (GTK_WINDOW (toplevel)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_window_get_type ()))))))
);
861 g_return_val_if_fail (GDK_IS_X11_SCREEN (screen), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((screen)); GType __t = ((gdk_x11_screen_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "GDK_IS_X11_SCREEN (screen)"); return ((0)); }
} while (0)
;
862 root_window = gdk_screen_get_root_window (screen);
863 device = gdk_seat_get_pointer (gdk_display_get_default_seat (gtk_widget_get_display (GTK_WIDGET(root_window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((root_window)), ((gtk_widget_get_type ()))))))
)));
864 gdk_window_get_device_position (gtk_widget_get_window (GTK_WIDGET (root_window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((root_window)), ((gtk_widget_get_type ()))))))
), device, &new_x, &new_y, NULL((void*)0));
865
866 switch (keyval) {
867 case GDK_KEY_Up0xff52:
868 case GDK_KEY_KP_Up0xff97:
869 new_y -= increment;
870 break;
871 case GDK_KEY_Left0xff51:
872 case GDK_KEY_KP_Left0xff96:
873 new_x -= increment;
874 break;
875 case GDK_KEY_Down0xff54:
876 case GDK_KEY_KP_Down0xff99:
877 new_y += increment;
878 break;
879 case GDK_KEY_Right0xff53:
880 case GDK_KEY_KP_Right0xff98:
881 new_x += increment;
882 break;
883 default:
884 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 884, ((const char*) (__func__)), ((void*)0)); } while (0)
;
885 return FALSE(0);
886 }
887
888 panel_warp_pointer (root_window, new_x, new_y);
889
890 return TRUE(!(0));
891}
892
893static gboolean panel_toplevel_move_keyboard_floating(PanelToplevel* toplevel, GdkEventKey* event)
894{
895#define SMALL_INCREMENT 1
896#define NORMAL_INCREMENT 10
897
898 int increment = NORMAL_INCREMENT;
899
900 if ((event->state & gtk_accelerator_get_default_mod_mask ()) == GDK_SHIFT_MASK)
901 increment = SMALL_INCREMENT;
902
903 return panel_toplevel_warp_pointer_increment (
904 toplevel, event->keyval, increment);
905
906#undef SMALL_INCREMENT
907#undef NORMAL_INCREMENT
908}
909
910#endif /* HAVE_X11 */
911
912static gboolean panel_toplevel_move_keyboard_expanded(PanelToplevel* toplevel, GdkEventKey* event)
913{
914 PanelOrientation new_orientation;
915
916 switch (event->keyval) {
917 case GDK_KEY_Up0xff52:
918 case GDK_KEY_KP_Up0xff97:
919 new_orientation = PANEL_ORIENTATION_TOP;
920 break;
921 case GDK_KEY_Left0xff51:
922 case GDK_KEY_KP_Left0xff96:
923 new_orientation = PANEL_ORIENTATION_LEFT;
924 break;
925 case GDK_KEY_Down0xff54:
926 case GDK_KEY_KP_Down0xff99:
927 new_orientation = PANEL_ORIENTATION_BOTTOM;
928 break;
929 case GDK_KEY_Right0xff53:
930 case GDK_KEY_KP_Right0xff98:
931 new_orientation = PANEL_ORIENTATION_RIGHT;
932 break;
933 default:
934 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 934, ((const char*) (__func__)), ((void*)0)); } while (0)
;
935 return FALSE(0);
936 }
937
938 panel_toplevel_set_orientation (toplevel, new_orientation);
939
940 return TRUE(!(0));
941}
942
943static gboolean panel_toplevel_initial_resize_keypress(PanelToplevel* toplevel, GdkEventKey* event)
944{
945 PanelGrabOpType grab_op;
946
947 switch (event->keyval) {
948 case GDK_KEY_Up0xff52:
949 case GDK_KEY_KP_Up0xff97:
950 if (!(toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)))
951 return FALSE(0);
952 grab_op = PANEL_GRAB_OP_RESIZE_UP;
953 break;
954 case GDK_KEY_Left0xff51:
955 case GDK_KEY_KP_Left0xff96:
956 if (!(toplevel->priv->orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT)))
957 return FALSE(0);
958 grab_op = PANEL_GRAB_OP_RESIZE_LEFT;
959 break;
960 case GDK_KEY_Down0xff54:
961 case GDK_KEY_KP_Down0xff99:
962 if (!(toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)))
963 return FALSE(0);
964 grab_op = PANEL_GRAB_OP_RESIZE_DOWN;
965 break;
966 case GDK_KEY_Right0xff53:
967 case GDK_KEY_KP_Right0xff98:
968 if (!(toplevel->priv->orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT)))
969 return FALSE(0);
970 grab_op = PANEL_GRAB_OP_RESIZE_RIGHT;
971 break;
972 default:
973 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 973, ((const char*) (__func__)), ((void*)0)); } while (0)
;
974 return FALSE(0);
975 }
976
977 panel_toplevel_end_grab_op (toplevel, event->time);
978 panel_toplevel_begin_grab_op (toplevel, grab_op, TRUE(!(0)), event->time);
979
980 return TRUE(!(0));
981}
982
983static gboolean panel_toplevel_handle_grab_op_key_event(PanelToplevel* toplevel, GdkEventKey* event)
984{
985 gboolean retval = FALSE(0);
986
987 switch (event->keyval) {
988 case GDK_KEY_Up0xff52:
989 case GDK_KEY_KP_Up0xff97:
990 case GDK_KEY_Left0xff51:
991 case GDK_KEY_KP_Left0xff96:
992 case GDK_KEY_Down0xff54:
993 case GDK_KEY_KP_Down0xff99:
994 case GDK_KEY_Right0xff53:
995 case GDK_KEY_KP_Right0xff98:
996 switch (toplevel->priv->grab_op) {
997 case PANEL_GRAB_OP_MOVE:
998 if (toplevel->priv->expand) {
999 retval = panel_toplevel_move_keyboard_expanded (
1000 toplevel, event);
1001 }
1002#ifdef HAVE_X111
1003 else if (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel)))(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gtk_widget_get_display (((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((toplevel)), ((gtk_widget_get_type ()))))
))))); GType __t = ((gdk_x11_display_get_type())); gboolean __r
; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
) {
1004 retval = panel_toplevel_move_keyboard_floating (
1005 toplevel, event);
1006 }
1007#endif /* HAVE_X11 */
1008 break;
1009 case PANEL_GRAB_OP_RESIZE:
1010 retval = panel_toplevel_initial_resize_keypress (toplevel, event);
1011 break;
1012 case PANEL_GRAB_OP_RESIZE_UP:
1013 case PANEL_GRAB_OP_RESIZE_DOWN:
1014 case PANEL_GRAB_OP_RESIZE_LEFT:
1015 case PANEL_GRAB_OP_RESIZE_RIGHT:
1016#ifdef HAVE_X111
1017 if (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel)))(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gtk_widget_get_display (((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((toplevel)), ((gtk_widget_get_type ()))))
))))); GType __t = ((gdk_x11_display_get_type())); gboolean __r
; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
)
1018 retval = panel_toplevel_warp_pointer_increment (toplevel, event->keyval, 1);
1019#endif /* HAVE_X11 */
1020 break;
1021 default:
1022 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 1022, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1023 break;
1024 }
1025 break;
1026 case GDK_KEY_Escape0xff1b:
1027 panel_toplevel_cancel_grab_op (toplevel, event->time);
1028 case GDK_KEY_Return0xff0d: /* drop through*/
1029 case GDK_KEY_KP_Enter0xff8d:
1030 case GDK_KEY_space0x020:
1031 case GDK_KEY_KP_Space0xff80:
1032 panel_toplevel_end_grab_op (toplevel, event->time);
1033 retval = TRUE(!(0));
1034 default: /* drop through*/
1035 break;
1036 }
1037
1038 return retval;
1039}
1040
1041static gboolean panel_toplevel_handle_grab_op_motion_event(PanelToplevel* toplevel, GdkEventMotion* event)
1042{
1043 switch (toplevel->priv->grab_op) {
1044 case PANEL_GRAB_OP_MOVE:
1045 if (toplevel->priv->expand)
1046 panel_toplevel_calc_new_orientation (
1047 toplevel, event->x_root, event->y_root);
1048
1049 else if ((event->state & gtk_accelerator_get_default_mod_mask ()) == GDK_CONTROL_MASK)
1050 panel_toplevel_rotate_to_pointer (
1051 toplevel, event->x_root, event->y_root);
1052
1053 else
1054 panel_toplevel_move_to_pointer (
1055 toplevel, event->x_root, event->y_root);
1056 return TRUE(!(0));
1057 case PANEL_GRAB_OP_RESIZE_UP:
1058 case PANEL_GRAB_OP_RESIZE_DOWN:
1059 case PANEL_GRAB_OP_RESIZE_LEFT:
1060 case PANEL_GRAB_OP_RESIZE_RIGHT:
1061 panel_toplevel_resize_to_pointer (toplevel, event->x_root, event->y_root);
1062 return TRUE(!(0));
1063 default:
1064 break;
1065 }
1066
1067 return FALSE(0);
1068}
1069
1070static void panel_toplevel_calc_floating(PanelToplevel* toplevel)
1071{
1072 GdkRectangle monitor_geom;
1073 GdkPoint position_on_monitor;
1074 int snap_tolerance;
1075
1076 if (toplevel->priv->expand) {
1077 toplevel->priv->floating = FALSE(0);
1078 return;
1079 }
1080
1081 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
1082
1083 if (toplevel->priv->x_right == -1)
1084 position_on_monitor.x = toplevel->priv->x;
1085 else
1086 position_on_monitor.x = monitor_geom.width - (toplevel->priv->x_right + toplevel->priv->geometry.width);
1087 if (toplevel->priv->y_bottom == -1)
1088 position_on_monitor.y = toplevel->priv->y;
1089 else
1090 position_on_monitor.y = monitor_geom.height - (toplevel->priv->y_bottom + toplevel->priv->geometry.height);
1091
1092 snap_tolerance = toplevel->priv->snap_tolerance;
1093
1094 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM))
1095 toplevel->priv->floating =
1096 (position_on_monitor.y > snap_tolerance) &&
1097 (position_on_monitor.y < (monitor_geom.height - toplevel->priv->geometry.height - snap_tolerance));
1098 else
1099 toplevel->priv->floating =
1100 (position_on_monitor.x > snap_tolerance) &&
1101 (position_on_monitor.x < (monitor_geom.width - toplevel->priv->geometry.width - snap_tolerance));
1102}
1103
1104void panel_toplevel_push_autohide_disabler(PanelToplevel* toplevel)
1105{
1106 g_return_if_fail (toplevel != NULL)do { if ((toplevel != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "toplevel != NULL"
); return; } } while (0)
;
1107
1108 if (!toplevel->priv->n_autohide_disablers++)
1109 panel_toplevel_queue_auto_hide (toplevel);
1110}
1111
1112void panel_toplevel_pop_autohide_disabler(PanelToplevel* toplevel)
1113{
1114 g_return_if_fail (toplevel != NULL)do { if ((toplevel != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "toplevel != NULL"
); return; } } while (0)
;
1115 g_return_if_fail (toplevel->priv->n_autohide_disablers > 0)do { if ((toplevel->priv->n_autohide_disablers > 0))
{ } else { g_return_if_fail_warning (((gchar*) 0), ((const char
*) (__func__)), "toplevel->priv->n_autohide_disablers > 0"
); return; } } while (0)
;
1116
1117 if (!--toplevel->priv->n_autohide_disablers)
1118 panel_toplevel_queue_auto_hide (toplevel);
1119}
1120
1121static gboolean panel_toplevel_get_autohide_disabled(PanelToplevel* toplevel)
1122{
1123 return toplevel->priv->n_autohide_disablers > 0 ? TRUE(!(0)) : FALSE(0);
1124}
1125
1126static gboolean panel_toplevel_hide_button_event(PanelToplevel* toplevel, GdkEventButton* event, GtkButton* button)
1127{
1128 if (event->button == 1)
1129 return FALSE(0);
1130
1131 return gtk_widget_event (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
, (GdkEvent *) event);
1132}
1133
1134static void panel_toplevel_hide_button_clicked(PanelToplevel* toplevel, GtkButton* button)
1135{
1136 GtkArrowType arrow_type;
1137 gboolean ltr;
1138
1139 if (toplevel->priv->animating ||
1140 toplevel->priv->state == PANEL_STATE_AUTO_HIDDEN)
1141 return;
1142
1143 ltr = gtk_widget_get_direction (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
) == GTK_TEXT_DIR_LTR;
1144 arrow_type = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button), "arrow-type"))((gint) (glong) (g_object_get_data (((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((button)), (((GType) ((20) << (2)))
))))), "arrow-type")))
;
1145
1146 if (toplevel->priv->state == PANEL_STATE_NORMAL) {
1147 GtkDirectionType direction;
1148
1149 switch (arrow_type) {
1150 case GTK_ARROW_UP:
1151 direction = GTK_DIR_UP;
1152 break;
1153 case GTK_ARROW_DOWN:
1154 direction = GTK_DIR_DOWN;
1155 break;
1156 case GTK_ARROW_LEFT:
1157 direction = ltr ? GTK_DIR_LEFT : GTK_DIR_RIGHT;
1158 break;
1159 case GTK_ARROW_RIGHT:
1160 direction = ltr ? GTK_DIR_RIGHT : GTK_DIR_LEFT;
1161 break;
1162 default:
1163 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 1163, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1164 break;
1165 }
1166
1167 panel_toplevel_hide (toplevel, FALSE(0), (gint) direction);
1168 } else
1169 panel_toplevel_unhide (toplevel);
1170}
1171
1172static void
1173set_arrow_type (GtkImage *image,
1174 GtkArrowType arrow_type)
1175{
1176 switch (arrow_type)
1177 {
1178 case GTK_ARROW_NONE:
1179 case GTK_ARROW_DOWN:
1180 gtk_image_set_from_icon_name (image, "pan-down-symbolic", GTK_ICON_SIZE_BUTTON);
1181 break;
1182 case GTK_ARROW_UP:
1183 gtk_image_set_from_icon_name (image, "pan-up-symbolic", GTK_ICON_SIZE_BUTTON);
1184 break;
1185 case GTK_ARROW_LEFT:
1186 gtk_image_set_from_icon_name (image, "pan-start-symbolic", GTK_ICON_SIZE_BUTTON);
1187 break;
1188 case GTK_ARROW_RIGHT:
1189 gtk_image_set_from_icon_name (image, "pan-end-symbolic", GTK_ICON_SIZE_BUTTON);
1190 break;
1191 }
1192}
1193
1194static GtkWidget *
1195panel_toplevel_add_hide_button (PanelToplevel *toplevel,
1196 GtkArrowType arrow_type,
1197 int left,
1198 int top)
1199{
1200
1201 GtkWidget *button;
1202 AtkObject *obj;
1203 GtkWidget *arrow;
1204
1205 button = gtk_button_new ();
1206 obj = gtk_widget_get_accessible (button);
1207 atk_object_set_name (obj, _("Hide Panel")gettext ("Hide Panel"));
1208 gtk_widget_set_can_default (button, FALSE(0));
1209
1210 arrow = gtk_image_new ();
1211 set_arrow_type (GTK_IMAGE (arrow)((((GtkImage*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((arrow)), ((gtk_image_get_type ()))))))
, arrow_type);
1212 gtk_container_add (GTK_CONTAINER (button)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), ((gtk_container_get_type ()))))))
, arrow);
1213 gtk_widget_show (arrow);
1214
1215 g_object_set_data (G_OBJECT (button)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), (((GType) ((20) << (2))))))))
,
1216 "arrow-type",
1217 GINT_TO_POINTER (arrow_type)((gpointer) (glong) (arrow_type)));
1218
1219 g_signal_connect_swapped (button, "clicked",g_signal_connect_data ((button), ("clicked"), (((GCallback) (
panel_toplevel_hide_button_clicked))), (toplevel), ((void*)0)
, G_CONNECT_SWAPPED)
1220 G_CALLBACK (panel_toplevel_hide_button_clicked), toplevel)g_signal_connect_data ((button), ("clicked"), (((GCallback) (
panel_toplevel_hide_button_clicked))), (toplevel), ((void*)0)
, G_CONNECT_SWAPPED)
;
1221 g_signal_connect_swapped (button, "button-press-event",g_signal_connect_data ((button), ("button-press-event"), (((GCallback
) (panel_toplevel_hide_button_event))), (toplevel), ((void*)0
), G_CONNECT_SWAPPED)
1222 G_CALLBACK (panel_toplevel_hide_button_event), toplevel)g_signal_connect_data ((button), ("button-press-event"), (((GCallback
) (panel_toplevel_hide_button_event))), (toplevel), ((void*)0
), G_CONNECT_SWAPPED)
;
1223 g_signal_connect_swapped (button, "button-release-event",g_signal_connect_data ((button), ("button-release-event"), ((
(GCallback) (panel_toplevel_hide_button_event))), (toplevel),
((void*)0), G_CONNECT_SWAPPED)
1224 G_CALLBACK (panel_toplevel_hide_button_event), toplevel)g_signal_connect_data ((button), ("button-release-event"), ((
(GCallback) (panel_toplevel_hide_button_event))), (toplevel),
((void*)0), G_CONNECT_SWAPPED)
;
1225
1226 gtk_grid_attach (GTK_GRID (toplevel->priv->grid)((((GtkGrid*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->grid)), ((gtk_grid_get_type ()))))
))
, button, left, top, 1, 1);
1227
1228 return button;
1229}
1230
1231static void panel_toplevel_update_buttons_showing(PanelToplevel* toplevel)
1232{
1233 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)) {
1234 gtk_widget_hide (toplevel->priv->hide_button_top);
1235 gtk_widget_hide (toplevel->priv->hide_button_bottom);
1236 gtk_widget_show (toplevel->priv->hide_button_left);
1237 gtk_widget_show (toplevel->priv->hide_button_right);
1238 } else {
1239 gtk_widget_show (toplevel->priv->hide_button_top);
1240 gtk_widget_show (toplevel->priv->hide_button_bottom);
1241 gtk_widget_hide (toplevel->priv->hide_button_left);
1242 gtk_widget_hide (toplevel->priv->hide_button_right);
1243 }
1244
1245 if (toplevel->priv->attached) {
1246 switch (panel_toplevel_get_orientation (toplevel->priv->attach_toplevel)) {
1247 case PANEL_ORIENTATION_TOP:
1248 gtk_widget_hide (toplevel->priv->hide_button_top);
1249 break;
1250 case PANEL_ORIENTATION_BOTTOM:
1251 gtk_widget_hide (toplevel->priv->hide_button_bottom);
1252 break;
1253 case PANEL_ORIENTATION_LEFT:
1254 gtk_widget_hide (toplevel->priv->hide_button_left);
1255 break;
1256 case PANEL_ORIENTATION_RIGHT:
1257 gtk_widget_hide (toplevel->priv->hide_button_right);
1258 break;
1259 default:
1260 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 1260, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1261 break;
1262 }
1263 }
1264}
1265
1266/* force set hide button size on panel size < 30px */
1267static void panel_toplevel_update_hide_buttons_size (GtkWidget *button, int panel_size)
1268{
1269 GtkCssProvider *css_provider;
1270 GtkStyleContext *context;
1271 GtkWidget *arrow;
1272 GtkSettings *settings;
1273 gchar *gtk_theme_name = NULL((void*)0);
1274
1275 context = gtk_widget_get_style_context (button);
1276 gtk_style_context_add_class (context, "panel-button");
1277
1278 /* get defaults from theme */
1279 settings = gtk_settings_get_default ();
1280 g_object_get (settings, "gtk-theme-name", &gtk_theme_name, NULL((void*)0));
1281 css_provider = gtk_css_provider_get_named (gtk_theme_name, NULL((void*)0));
1282 g_free (gtk_theme_name);
1283
1284 /* set custom css by adding our custom code to the default theme css
1285 *
1286 * NOTE that contriary to the documentation:
1287 * https://developer.gnome.org/gtk3/stable/GtkCssProvider.html#gtk-css-provider-load-from-data
1288 * the previously loaded theme is NOT cleared from the css_provider. (reason unknown)
1289 * In other words, this works exactly, how we need it here.
1290 * ALSO NOTE that using gtk_css_provider_to_string () to convert the theme css data into a string
1291 * and then adding the custom css, then adding this updated css to a css_provider
1292 * with the gtk_css_provider_load_from_data () also works,
1293 * however some themes can't be easily converted to strings, beacuse of the binary data
1294 * they contain. This causes a delay of minutes in loading the mate-panel,
1295 * and so this approach is not viable. */
1296 if (panel_size < 30) {
1297 gtk_css_provider_load_from_data (css_provider, ".panel-button {min-height: 13px; min-width: 13px; padding: 0px;}", -1, NULL((void*)0));
1298 }
1299
1300 gtk_style_context_add_provider (context, GTK_STYLE_PROVIDER (css_provider)((((GtkStyleProvider*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((css_provider)), ((gtk_style_provider_get_type
()))))))
, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION600);
1301
1302 /* get arrow image */
1303 arrow = gtk_bin_get_child (GTK_BIN (button)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), ((gtk_bin_get_type ()))))))
);
1304
1305 /* set image size */
1306 if (panel_size < 20) {
1307 gtk_image_set_pixel_size (GTK_IMAGE (arrow)((((GtkImage*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((arrow)), ((gtk_image_get_type ()))))))
, 12);
1308 } else if (panel_size < 40) {
1309 gtk_image_set_pixel_size (GTK_IMAGE (arrow)((((GtkImage*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((arrow)), ((gtk_image_get_type ()))))))
, 16);
1310 } else if (panel_size < 60) {
1311 gtk_image_set_pixel_size (GTK_IMAGE (arrow)((((GtkImage*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((arrow)), ((gtk_image_get_type ()))))))
, 22);
1312 } else {
1313 gtk_image_set_pixel_size (GTK_IMAGE (arrow)((((GtkImage*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((arrow)), ((gtk_image_get_type ()))))))
, 24);
1314 }
1315}
1316
1317static void panel_toplevel_update_hide_buttons(PanelToplevel* toplevel)
1318{
1319
1320 int panel_size = toplevel->priv->size;
1321
1322 if (toplevel->priv->buttons_enabled) {
1323 panel_toplevel_update_buttons_showing (toplevel);
1324
1325 panel_toplevel_update_hide_buttons_size (toplevel->priv->hide_button_top, panel_size);
1326 panel_toplevel_update_hide_buttons_size (toplevel->priv->hide_button_bottom, panel_size);
1327 panel_toplevel_update_hide_buttons_size (toplevel->priv->hide_button_left, panel_size);
1328 panel_toplevel_update_hide_buttons_size (toplevel->priv->hide_button_right, panel_size);
1329
1330 } else {
1331 g_object_set (
1332 G_OBJECT (toplevel->priv->hide_button_top)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->hide_button_top)), (((GType) ((20)
<< (2))))))))
,
1333 "visible", toplevel->priv->state == PANEL_STATE_HIDDEN_DOWN,
1334 NULL((void*)0));
1335 g_object_set (
1336 G_OBJECT (toplevel->priv->hide_button_bottom)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->hide_button_bottom)), (((GType) ((
20) << (2))))))))
,
1337 "visible", toplevel->priv->state == PANEL_STATE_HIDDEN_UP,
1338 NULL((void*)0));
1339 g_object_set (
1340 G_OBJECT (toplevel->priv->hide_button_left)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->hide_button_left)), (((GType) ((20
) << (2))))))))
,
1341 "visible", toplevel->priv->state == PANEL_STATE_HIDDEN_RIGHT,
1342 NULL((void*)0));
1343 g_object_set (
1344 G_OBJECT (toplevel->priv->hide_button_right)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->hide_button_right)), (((GType) ((20
) << (2))))))))
,
1345 "visible", toplevel->priv->state == PANEL_STATE_HIDDEN_LEFT,
1346 NULL((void*)0));
1347 }
1348
1349 if (toplevel->priv->arrows_enabled) {
1350
1351 gtk_widget_show (gtk_bin_get_child (GTK_BIN (toplevel->priv->hide_button_top)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->hide_button_top)), ((gtk_bin_get_type
()))))))
));
1352 gtk_widget_show (gtk_bin_get_child (GTK_BIN (toplevel->priv->hide_button_bottom)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->hide_button_bottom)), ((gtk_bin_get_type
()))))))
));
1353 gtk_widget_show (gtk_bin_get_child (GTK_BIN (toplevel->priv->hide_button_left)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->hide_button_left)), ((gtk_bin_get_type
()))))))
));
1354 gtk_widget_show (gtk_bin_get_child (GTK_BIN (toplevel->priv->hide_button_right)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->hide_button_right)), ((gtk_bin_get_type
()))))))
));
1355
1356 } else {
1357
1358 gtk_widget_hide (gtk_bin_get_child (GTK_BIN (toplevel->priv->hide_button_top)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->hide_button_top)), ((gtk_bin_get_type
()))))))
));
1359 gtk_widget_hide (gtk_bin_get_child (GTK_BIN (toplevel->priv->hide_button_bottom)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->hide_button_bottom)), ((gtk_bin_get_type
()))))))
));
1360 gtk_widget_hide (gtk_bin_get_child (GTK_BIN (toplevel->priv->hide_button_left)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->hide_button_left)), ((gtk_bin_get_type
()))))))
));
1361 gtk_widget_hide (gtk_bin_get_child (GTK_BIN (toplevel->priv->hide_button_right)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->hide_button_right)), ((gtk_bin_get_type
()))))))
));
1362 }
1363
1364 /* set size after setting the arrow */
1365 if (toplevel->priv->buttons_enabled) {
1366 int hb_size;
1367
1368 if (panel_size < 20)
1369 hb_size = 16;
1370 else if (panel_size < 40)
1371 hb_size = 20;
1372 else if (panel_size < 60)
1373 hb_size = 26;
1374 else
1375 hb_size = 30;
1376
1377 gtk_widget_set_size_request (toplevel->priv->hide_button_top, panel_size, hb_size);
1378 gtk_widget_set_size_request (toplevel->priv->hide_button_bottom, panel_size, hb_size);
1379 gtk_widget_set_size_request (toplevel->priv->hide_button_left, hb_size, panel_size);
1380 gtk_widget_set_size_request (toplevel->priv->hide_button_right, hb_size, panel_size);
1381 }
1382}
1383
1384static gboolean panel_toplevel_contains_pointer(PanelToplevel* toplevel)
1385{
1386 GdkDisplay *display;
1387 GdkScreen *screen;
1388 GtkWidget *widget;
1389 GdkSeat *seat;
1390 GdkDevice *pointer;
1391 int x, y;
1392
1393 display = gdk_display_get_default ();
1394 seat = gdk_display_get_default_seat (display);
1395 pointer = gdk_seat_get_pointer (seat);
1396 widget = GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
;
1397
1398 if (!gtk_widget_get_realized (widget))
1399 return FALSE(0);
1400
1401 screen = NULL((void*)0);
1402 x = y = -1;
1403 gdk_device_get_position (pointer, &screen, &x, &y);
1404
1405 if (screen != gtk_window_get_screen (GTK_WINDOW (toplevel)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_window_get_type ()))))))
))
1406 return FALSE(0);
1407
1408 if (x == -1 || y == -1)
1409 return FALSE(0);
1410
1411 if (x < toplevel->priv->geometry.x || x >= (toplevel->priv->geometry.x + toplevel->priv->geometry.width) ||
1412 y < toplevel->priv->geometry.y || y >= (toplevel->priv->geometry.y + toplevel->priv->geometry.height))
1413 return FALSE(0);
1414
1415 return TRUE(!(0));
1416}
1417
1418static inline int panel_toplevel_get_effective_auto_hide_size(PanelToplevel* toplevel)
1419{
1420 int size;
1421
1422 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM))
1423 size = CLAMP (toplevel->priv->auto_hide_size,(((toplevel->priv->auto_hide_size) > (toplevel->priv
->original_height / 2)) ? (toplevel->priv->original_height
/ 2) : (((toplevel->priv->auto_hide_size) < (1)) ? (
1) : (toplevel->priv->auto_hide_size)))
1424 1, toplevel->priv->original_height / 2)(((toplevel->priv->auto_hide_size) > (toplevel->priv
->original_height / 2)) ? (toplevel->priv->original_height
/ 2) : (((toplevel->priv->auto_hide_size) < (1)) ? (
1) : (toplevel->priv->auto_hide_size)))
;
1425 else
1426 size = CLAMP (toplevel->priv->auto_hide_size,(((toplevel->priv->auto_hide_size) > (toplevel->priv
->original_width / 2)) ? (toplevel->priv->original_width
/ 2) : (((toplevel->priv->auto_hide_size) < (1)) ? (
1) : (toplevel->priv->auto_hide_size)))
1427 1, toplevel->priv->original_width / 2)(((toplevel->priv->auto_hide_size) > (toplevel->priv
->original_width / 2)) ? (toplevel->priv->original_width
/ 2) : (((toplevel->priv->auto_hide_size) < (1)) ? (
1) : (toplevel->priv->auto_hide_size)))
;
1428
1429 /* paranoia */
1430 return (size <= 0) ? DEFAULT_AUTO_HIDE_SIZE1 : size;
1431}
1432
1433static gboolean panel_toplevel_update_struts(PanelToplevel* toplevel, gboolean end_of_animation)
1434{
1435 PanelOrientation orientation;
1436 gboolean geometry_changed = FALSE(0);
1437 int strut, strut_start, strut_end;
1438 int x, y, width, height;
1439 GdkRectangle monitor_geom;
1440
1441 if (!toplevel->priv->updated_geometry_initial)
1442 return FALSE(0);
1443
1444#ifdef HAVE_X111
1445 if (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel)))(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gtk_widget_get_display (((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((toplevel)), ((gtk_widget_get_type ()))))
))))); GType __t = ((gdk_x11_display_get_type())); gboolean __r
; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
&& toplevel->priv->attached) {
1446 panel_struts_unregister_strut (toplevel);
1447 panel_struts_set_window_hint (toplevel);
1448 return FALSE(0);
1449 }
1450#endif /* HAVE_X11 */
1451
1452 /* In the case of the initial animation, we really want the struts to
1453 * represent what is at the end of the animation, to avoid desktop
1454 * icons jumping around. */
1455 if (!toplevel->priv->initial_animation_done) {
1456 end_of_animation = TRUE(!(0));
1457
1458 /* We've not started the animation yet, so we have to compute
1459 * where we want to end. Note that we don't want to compute
1460 * this everytime, since the struts conflict resolution will be
1461 * overridden if we do so */
1462 if (!toplevel->priv->animating)
1463 panel_toplevel_calculate_animation_end_geometry (toplevel);
1464 }
1465
1466 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
1467
1468 if (end_of_animation) {
1469 x = toplevel->priv->animation_end_x;
1470 y = toplevel->priv->animation_end_y;
1471 x += panel_multimonitor_x (toplevel->priv->monitor);
1472 y += panel_multimonitor_y (toplevel->priv->monitor);
1473 if (toplevel->priv->animation_end_width != -1)
1474 width = toplevel->priv->animation_end_width;
1475 else
1476 width = toplevel->priv->geometry.width;
1477 if (toplevel->priv->animation_end_height != -1)
1478 height = toplevel->priv->animation_end_height;
1479 else
1480 height = toplevel->priv->geometry.height;
1481 } else {
1482 x = toplevel->priv->geometry.x;
1483 y = toplevel->priv->geometry.y;
1484 width = toplevel->priv->geometry.width;
1485 height = toplevel->priv->geometry.height;
1486 }
1487
1488 orientation = toplevel->priv->orientation;
1489
1490 strut = strut_start = strut_end = 0;
1491
1492 if (orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)) {
1493 if (y <= monitor_geom.y) {
1494 orientation = PANEL_ORIENTATION_TOP;
1495 strut = y + height - monitor_geom.y;
1496 } else if (y >= monitor_geom.y + monitor_geom.height - height) {
1497 orientation = PANEL_ORIENTATION_BOTTOM;
1498 strut = monitor_geom.y + monitor_geom.height - y;
1499 }
1500
1501 if (strut > 0) {
1502 strut_start = MAX (x, monitor_geom.x)(((x) > (monitor_geom.x)) ? (x) : (monitor_geom.x));
1503 strut_end = MIN (x + width, monitor_geom.x + monitor_geom.width)(((x + width) < (monitor_geom.x + monitor_geom.width)) ? (
x + width) : (monitor_geom.x + monitor_geom.width))
- 1;
1504 }
1505 } else {
1506 if (x <= monitor_geom.x) {
1507 orientation = PANEL_ORIENTATION_LEFT;
1508 strut = x + width - monitor_geom.x;
1509 } else if (x >= monitor_geom.x + monitor_geom.width - width) {
1510 orientation = PANEL_ORIENTATION_RIGHT;
1511 strut = monitor_geom.x + monitor_geom.width - x;
1512 }
1513
1514 if (strut > 0) {
1515 strut_start = MAX (y, monitor_geom.y)(((y) > (monitor_geom.y)) ? (y) : (monitor_geom.y));
1516 strut_end = MIN (y + height, monitor_geom.y + monitor_geom.height)(((y + height) < (monitor_geom.y + monitor_geom.height)) ?
(y + height) : (monitor_geom.y + monitor_geom.height))
- 1;
1517 }
1518 }
1519
1520 if (orientation != toplevel->priv->orientation) {
1521 toplevel->priv->orientation = orientation;
1522 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "orientation");
1523 }
1524
1525 if (toplevel->priv->auto_hide && strut > 0)
1526 strut = panel_toplevel_get_effective_auto_hide_size (toplevel);
1527
1528#ifdef HAVE_X111
1529 if (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel)))(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gtk_widget_get_display (((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((toplevel)), ((gtk_widget_get_type ()))))
))))); GType __t = ((gdk_x11_display_get_type())); gboolean __r
; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
) {
1530 if (strut > 0) {
1531 GdkScreen *screen;
1532 screen = gtk_widget_get_screen (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
1533 geometry_changed = panel_struts_register_strut (toplevel,
1534 screen,
1535 toplevel->priv->monitor,
1536 orientation,
1537 strut,
1538 strut_start,
1539 strut_end);
1540 }
1541 else {
1542 panel_struts_unregister_strut (toplevel);
1543 }
1544
1545 if (toplevel->priv->state == PANEL_STATE_NORMAL ||
1546 toplevel->priv->state == PANEL_STATE_AUTO_HIDDEN ||
1547 toplevel->priv->animating)
1548 panel_struts_set_window_hint (toplevel);
1549 else
1550 panel_struts_unset_window_hint (toplevel);
1551 }
1552#endif /* HAVE_X11 */
1553
1554#ifdef HAVE_WAYLAND1
1555 if (GDK_IS_WAYLAND_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel)))(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gtk_widget_get_display (((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((toplevel)), ((gtk_widget_get_type ()))))
))))); GType __t = ((gdk_wayland_display_get_type())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
) {
1556 wayland_panel_toplevel_update_placement (toplevel);
1557 }
1558#endif /* HAVE_WAYLAND */
1559 return geometry_changed;
1560}
1561
1562void panel_toplevel_update_edges(PanelToplevel* toplevel)
1563{
1564 GtkWidget *widget;
1565 PanelFrameEdge edges;
1566 PanelFrameEdge inner_edges;
1567 PanelFrameEdge outer_edges;
1568 GdkRectangle monitor_geom;
1569 int width, height;
1570 gboolean inner_frame = FALSE(0);
1571
1572 widget = GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
;
1573
1574 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
1575
1576 width = toplevel->priv->geometry.width;
1577 height = toplevel->priv->geometry.height;
1578
1579 edges = PANEL_EDGE_NONE;
1580
1581 /* We don't want any bevels with a color/image background */
1582 if (toplevel->priv->geometry.y > 0)
1583 edges |= PANEL_EDGE_TOP;
1584
1585 if (toplevel->priv->geometry.x > 0)
1586 edges |= PANEL_EDGE_LEFT;
1587
1588 if (toplevel->priv->geometry.y < (monitor_geom.height - height))
1589 edges |= PANEL_EDGE_BOTTOM;
1590
1591 if (toplevel->priv->geometry.x < (monitor_geom.width - width))
1592 edges |= PANEL_EDGE_RIGHT;
1593
1594 /* There is a conflict in the position algorithm when a
1595 * non-expanded centered panel is nearly the size of the
1596 * screen. This is similar to the one we have in
1597 * panel_toplevel_update_position(). A simple solution is
1598 * to keep the bevels in this case. */
1599 if (!toplevel->priv->expand &&
1600 toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM) &&
1601 toplevel->priv->x_centered)
1602 edges |= PANEL_EDGE_LEFT | PANEL_EDGE_RIGHT;
1603
1604 if (!toplevel->priv->expand &&
1605 toplevel->priv->orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT) &&
1606 toplevel->priv->y_centered)
1607 edges |= PANEL_EDGE_TOP | PANEL_EDGE_BOTTOM;
1608
1609 if (gtk_widget_get_visible (toplevel->priv->hide_button_left) ||
1610 gtk_widget_get_visible (toplevel->priv->hide_button_right)) {
1611 inner_frame = TRUE(!(0));
1612 edges |= PANEL_EDGE_LEFT | PANEL_EDGE_RIGHT;
1613 }
1614
1615 if (gtk_widget_get_visible (toplevel->priv->hide_button_top) ||
1616 gtk_widget_get_visible (toplevel->priv->hide_button_bottom)) {
1617 inner_frame = TRUE(!(0));
1618 edges |= PANEL_EDGE_TOP | PANEL_EDGE_BOTTOM;
1619 }
1620
1621 if (!inner_frame) {
1622 inner_edges = PANEL_EDGE_NONE;
1623 outer_edges = edges;
1624 } else {
1625 inner_edges = edges;
1626 outer_edges = PANEL_EDGE_NONE;
1627 }
1628
1629 panel_frame_set_edges (toplevel->priv->inner_frame, inner_edges);
1630
1631 if (toplevel->priv->edges != outer_edges) {
1632 toplevel->priv->edges = outer_edges;
1633 gtk_widget_queue_resize (widget);
1634 }
1635}
1636
1637static const char* panel_toplevel_construct_description(PanelToplevel *toplevel)
1638{
1639 if (toplevel->priv->attached)
1640 return _("Drawer")gettext ("Drawer");
1641
1642 switch (toplevel->priv->orientation) {
1643 case PANEL_ORIENTATION_TOP:
1644 /* translators: these string will be shown in MetaCity's switch window
1645 * popup when you pass the focus to a panel */
1646 return _("Top Panel")gettext ("Top Panel");
1647 case PANEL_ORIENTATION_BOTTOM:
1648 return _("Bottom Panel")gettext ("Bottom Panel");
1649 case PANEL_ORIENTATION_LEFT:
1650 return _("Left Panel")gettext ("Left Panel");
1651 case PANEL_ORIENTATION_RIGHT:
1652 return _("Right Panel")gettext ("Right Panel");
1653 }
1654
1655 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 1655, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1656 return _("Top Panel")gettext ("Top Panel");
1657}
1658
1659static void panel_toplevel_update_description(PanelToplevel* toplevel)
1660{
1661 const char *description;
1662
1663 description = panel_toplevel_construct_description (toplevel);
1664
1665 if (toplevel->priv->description &&
1666 !strcmp (toplevel->priv->description, description))
1667 return;
1668
1669 if (toplevel->priv->description)
1670 g_free (toplevel->priv->description);
1671 toplevel->priv->description = g_strdup (description)g_strdup_inline (description);
1672
1673 if (!toplevel->priv->name)
1674 gtk_window_set_title (GTK_WINDOW (toplevel)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_window_get_type ()))))))
,
1675 toplevel->priv->description);
1676
1677 panel_a11y_set_atk_name_desc (
1678 GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
,
1679 toplevel->priv->name ? toplevel->priv->name :
1680 toplevel->priv->description,
1681 toplevel->priv->description);
1682}
1683
1684static void panel_toplevel_update_attached_position(PanelToplevel* toplevel, gboolean hidden, int* x, int* y, int* w, int* h)
1685{
1686 GtkAllocation attach_allocation;
1687 PanelOrientation attach_orientation;
1688 GdkRectangle toplevel_box;
1689 GdkRectangle parent_box;
1690 GdkRectangle attach_box;
1691 int x_origin = 0, y_origin = 0;
1692 GdkRectangle monitor_geom;
1693
1694 if (!gtk_widget_get_realized (GTK_WIDGET (toplevel->priv->attach_toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->attach_toplevel)), ((gtk_widget_get_type
()))))))
) ||
1695 !gtk_widget_get_realized (toplevel->priv->attach_widget))
1696 return;
1697
1698 gtk_widget_get_allocation (GTK_WIDGET (toplevel->priv->attach_widget)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->attach_widget)), ((gtk_widget_get_type
()))))))
, &attach_allocation);
1699
1700 toplevel_box = toplevel->priv->geometry;
1701 parent_box = toplevel->priv->attach_toplevel->priv->geometry;
1702 attach_box = attach_allocation;
1703
1704 if (attach_box.x != -1) {
1705 gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (toplevel->priv->attach_widget)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->attach_widget)), ((gtk_widget_get_type
()))))))
),
1706 &x_origin, &y_origin);
1707
1708 attach_box.x += x_origin;
1709 attach_box.y += y_origin;
1710 } else {
1711 /* attach_widget isn't allocated. Put the toplevel
1712 * off screen.
1713 */
1714 attach_box.x = -toplevel_box.width;
1715 attach_box.y = -toplevel_box.height;
1716 }
1717
1718 attach_orientation = panel_toplevel_get_orientation (
1719 toplevel->priv->attach_toplevel);
1720
1721 if (attach_orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM))
1722 *x = attach_box.x + attach_box.width / 2 - toplevel_box.width / 2;
1723 else
1724 *y = attach_box.y + attach_box.height / 2 - toplevel_box.height / 2;
1725
1726 switch (attach_orientation) {
1727 case PANEL_ORIENTATION_TOP:
1728 *y = parent_box.y;
1729 if (!hidden)
1730 *y += parent_box.height;
1731 else
1732 *h = parent_box.height;
1733 break;
1734 case PANEL_ORIENTATION_BOTTOM:
1735 *y = parent_box.y;
1736 if (!hidden)
1737 *y -= toplevel_box.height;
1738 else
1739 *h = parent_box.height;
1740 break;
1741 case PANEL_ORIENTATION_LEFT:
1742 *x = parent_box.x;
1743 if (!hidden)
1744 *x += parent_box.width;
1745 else
1746 *w = parent_box.width;
1747 break;
1748 case PANEL_ORIENTATION_RIGHT:
1749 *x = parent_box.x;
1750 if (!hidden)
1751 *x -= toplevel_box.width;
1752 else
1753 *w = parent_box.width;
1754 break;
1755 default:
1756 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 1756, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1757 break;
1758 }
1759
1760 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
1761
1762 *x -= monitor_geom.x;
1763 *y -= monitor_geom.y;
1764
1765 if (toplevel->priv->orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT))
1766 *x = CLAMP (*x, 0, monitor_geom.width - toplevel->priv->original_width)(((*x) > (monitor_geom.width - toplevel->priv->original_width
)) ? (monitor_geom.width - toplevel->priv->original_width
) : (((*x) < (0)) ? (0) : (*x)))
;
1767 else
1768 *y = CLAMP (*y, 0, monitor_geom.height - toplevel->priv->original_height)(((*y) > (monitor_geom.height - toplevel->priv->original_height
)) ? (monitor_geom.height - toplevel->priv->original_height
) : (((*y) < (0)) ? (0) : (*y)))
;
1769}
1770
1771static void panel_toplevel_update_normal_position(PanelToplevel* toplevel, int* x, int* y, int* w, int* h)
1772{
1773 GdkRectangle monitor_geom;
1774 int width, height;
1775 int snap_tolerance;
1776
1777 g_assert (x != NULL && y != NULL)do { if (x != ((void*)0) && y != ((void*)0)) ; else g_assertion_message_expr
(((gchar*) 0), "panel-toplevel.c", 1777, ((const char*) (__func__
)), "x != NULL && y != NULL"); } while (0)
;
1778
1779 if (toplevel->priv->attached) {
1780 panel_toplevel_update_attached_position (toplevel, FALSE(0), x, y, w, h);
1781 return;
1782 }
1783
1784 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
1785
1786 width = toplevel->priv->original_width;
1787 height = toplevel->priv->original_height;
1788 snap_tolerance = toplevel->priv->snap_tolerance;
1789
1790 *x = CLAMP (*x, 0, monitor_geom.width - width)(((*x) > (monitor_geom.width - width)) ? (monitor_geom.width
- width) : (((*x) < (0)) ? (0) : (*x)))
;
1791 *y = CLAMP (*y, 0, monitor_geom.height - height)(((*y) > (monitor_geom.height - height)) ? (monitor_geom.height
- height) : (((*y) < (0)) ? (0) : (*y)))
;
1792
1793 if (toplevel->priv->x <= snap_tolerance &&
1794 toplevel->priv->x_right == -1 &&
1795 !toplevel->priv->x_centered)
1796 *x = 0;
1797 else if (toplevel->priv->x_right != -1 &&
1798 toplevel->priv->x_right <= snap_tolerance &&
1799 !toplevel->priv->x_centered)
1800 *x = monitor_geom.width - width;
1801
1802 if (toplevel->priv->y <= snap_tolerance &&
1803 toplevel->priv->y_bottom == -1 &&
1804 !toplevel->priv->y_centered)
1805 *y = 0;
1806 else if (toplevel->priv->y_bottom != -1 &&
1807 toplevel->priv->y_bottom <= snap_tolerance &&
1808 !toplevel->priv->y_centered)
1809 *y = monitor_geom.height - height;
1810}
1811
1812static void
1813panel_toplevel_update_auto_hide_position (PanelToplevel *toplevel,
1814 int *x,
1815 int *y,
1816 int *w,
1817 int *h,
1818 gboolean for_end_position)
1819{
1820 int width, height;
1821 GdkRectangle monitor_geom;
1822 int auto_hide_size;
1823 int snap_tolerance;
1824
1825 g_assert (x != NULL && y != NULL)do { if (x != ((void*)0) && y != ((void*)0)) ; else g_assertion_message_expr
(((gchar*) 0), "panel-toplevel.c", 1825, ((const char*) (__func__
)), "x != NULL && y != NULL"); } while (0)
;
1826
1827 if (toplevel->priv->floating) {
1828 panel_toplevel_update_normal_position (toplevel, x, y, w, h);
1829 return;
1830 }
1831
1832 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
1833
1834 width = toplevel->priv->original_width;
1835 height = toplevel->priv->original_height;
1836 snap_tolerance = toplevel->priv->snap_tolerance;
1837
1838 /* For the initial animation, we animate from outside the screen, and
1839 * so we don't want the toplevel to be visible at all. But when the
1840 * request is for the end position, then we give the real result (it's
1841 * useful for struts) */
1842 if (for_end_position || toplevel->priv->initial_animation_done) {
1843 auto_hide_size = panel_toplevel_get_effective_auto_hide_size (toplevel);
1844 } else {
1845 auto_hide_size = 0;
1846 }
1847
1848 switch (toplevel->priv->orientation) {
1849 case PANEL_ORIENTATION_TOP:
1850 *y = - (height - auto_hide_size);
1851 break;
1852 case PANEL_ORIENTATION_BOTTOM:
1853 *y = monitor_geom.height - auto_hide_size;
1854 break;
1855 case PANEL_ORIENTATION_LEFT:
1856 *x = - (width - auto_hide_size);
1857 break;
1858 case PANEL_ORIENTATION_RIGHT:
1859 *x = monitor_geom.width - auto_hide_size;
1860 break;
1861 default:
1862 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 1862, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1863 break;
1864 }
1865
1866 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)) {
1867 if (toplevel->priv->x <= snap_tolerance &&
1868 toplevel->priv->x_right == -1 &&
1869 !toplevel->priv->x_centered)
1870 *x = 0;
1871 else if (toplevel->priv->x_right != -1 &&
1872 toplevel->priv->x_right <= snap_tolerance &&
1873 !toplevel->priv->x_centered)
1874 *x = monitor_geom.width - width;
1875 } else /* if (toplevel->priv->orientation & PANEL_VERTICAL_MASK) */ {
1876 if (toplevel->priv->y <= snap_tolerance &&
1877 toplevel->priv->y_bottom == -1 &&
1878 !toplevel->priv->y_centered)
1879 *y = 0;
1880 else if (toplevel->priv->y_bottom != -1 &&
1881 toplevel->priv->y_bottom <= snap_tolerance &&
1882 !toplevel->priv->y_centered)
1883 *y = monitor_geom.height - height;
1884 }
1885}
1886
1887/* FIXME: this is wrong for Xinerama. In the Xinerama case
1888 * I think if hiding it requires it to go onto the
1889 * next monitor then it should just move it on to
1890 * the next monitor and set its state back to normal
1891 */
1892static void
1893panel_toplevel_update_hidden_position (PanelToplevel *toplevel,
1894 int *x,
1895 int *y,
1896 int *w,
1897 int *h)
1898{
1899 int width, height;
1900 int min_hide_size;
1901 GdkRectangle monitor_geom;
1902 GtkAllocation hide_allocation;
1903
1904 g_assert (x != NULL && y != NULL)do { if (x != ((void*)0) && y != ((void*)0)) ; else g_assertion_message_expr
(((gchar*) 0), "panel-toplevel.c", 1904, ((const char*) (__func__
)), "x != NULL && y != NULL"); } while (0)
;
1905
1906 g_assert (toplevel->priv->state == PANEL_STATE_HIDDEN_UP ||do { if (toplevel->priv->state == PANEL_STATE_HIDDEN_UP
|| toplevel->priv->state == PANEL_STATE_HIDDEN_DOWN ||
toplevel->priv->state == PANEL_STATE_HIDDEN_LEFT || toplevel
->priv->state == PANEL_STATE_HIDDEN_RIGHT) ; else g_assertion_message_expr
(((gchar*) 0), "panel-toplevel.c", 1909, ((const char*) (__func__
)), "toplevel->priv->state == PANEL_STATE_HIDDEN_UP || toplevel->priv->state == PANEL_STATE_HIDDEN_DOWN || toplevel->priv->state == PANEL_STATE_HIDDEN_LEFT || toplevel->priv->state == PANEL_STATE_HIDDEN_RIGHT"
); } while (0)
1907 toplevel->priv->state == PANEL_STATE_HIDDEN_DOWN ||do { if (toplevel->priv->state == PANEL_STATE_HIDDEN_UP
|| toplevel->priv->state == PANEL_STATE_HIDDEN_DOWN ||
toplevel->priv->state == PANEL_STATE_HIDDEN_LEFT || toplevel
->priv->state == PANEL_STATE_HIDDEN_RIGHT) ; else g_assertion_message_expr
(((gchar*) 0), "panel-toplevel.c", 1909, ((const char*) (__func__
)), "toplevel->priv->state == PANEL_STATE_HIDDEN_UP || toplevel->priv->state == PANEL_STATE_HIDDEN_DOWN || toplevel->priv->state == PANEL_STATE_HIDDEN_LEFT || toplevel->priv->state == PANEL_STATE_HIDDEN_RIGHT"
); } while (0)
1908 toplevel->priv->state == PANEL_STATE_HIDDEN_LEFT ||do { if (toplevel->priv->state == PANEL_STATE_HIDDEN_UP
|| toplevel->priv->state == PANEL_STATE_HIDDEN_DOWN ||
toplevel->priv->state == PANEL_STATE_HIDDEN_LEFT || toplevel
->priv->state == PANEL_STATE_HIDDEN_RIGHT) ; else g_assertion_message_expr
(((gchar*) 0), "panel-toplevel.c", 1909, ((const char*) (__func__
)), "toplevel->priv->state == PANEL_STATE_HIDDEN_UP || toplevel->priv->state == PANEL_STATE_HIDDEN_DOWN || toplevel->priv->state == PANEL_STATE_HIDDEN_LEFT || toplevel->priv->state == PANEL_STATE_HIDDEN_RIGHT"
); } while (0)
1909 toplevel->priv->state == PANEL_STATE_HIDDEN_RIGHT)do { if (toplevel->priv->state == PANEL_STATE_HIDDEN_UP
|| toplevel->priv->state == PANEL_STATE_HIDDEN_DOWN ||
toplevel->priv->state == PANEL_STATE_HIDDEN_LEFT || toplevel
->priv->state == PANEL_STATE_HIDDEN_RIGHT) ; else g_assertion_message_expr
(((gchar*) 0), "panel-toplevel.c", 1909, ((const char*) (__func__
)), "toplevel->priv->state == PANEL_STATE_HIDDEN_UP || toplevel->priv->state == PANEL_STATE_HIDDEN_DOWN || toplevel->priv->state == PANEL_STATE_HIDDEN_LEFT || toplevel->priv->state == PANEL_STATE_HIDDEN_RIGHT"
); } while (0)
;
1910
1911 if (toplevel->priv->attached) {
1912 panel_toplevel_update_attached_position (toplevel, TRUE(!(0)), x, y, w, h);
1913 return;
1914 }
1915
1916 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
1917
1918 width = toplevel->priv->original_width;
1919 height = toplevel->priv->original_height;
1920
1921 /* FIXME should find a better default */
1922 min_hide_size = DEFAULT_AUTO_HIDE_SIZE1;
1923
1924 switch (toplevel->priv->state) {
1925 case PANEL_STATE_HIDDEN_UP:
1926 gtk_widget_get_allocation (toplevel->priv->hide_button_bottom,
1927 &hide_allocation);
1928 *y = - (height - MAX (hide_allocation.height, min_hide_size)(((hide_allocation.height) > (min_hide_size)) ? (hide_allocation
.height) : (min_hide_size))
);
1929 break;
1930 case PANEL_STATE_HIDDEN_DOWN:
1931 gtk_widget_get_allocation (toplevel->priv->hide_button_top,
1932 &hide_allocation);
1933 *y = monitor_geom.height - MAX (hide_allocation.height, min_hide_size)(((hide_allocation.height) > (min_hide_size)) ? (hide_allocation
.height) : (min_hide_size))
;
1934 break;
1935 case PANEL_STATE_HIDDEN_LEFT:
1936 gtk_widget_get_allocation (toplevel->priv->hide_button_right,
1937 &hide_allocation);
1938 *x = - (width - MAX (hide_allocation.width, min_hide_size)(((hide_allocation.width) > (min_hide_size)) ? (hide_allocation
.width) : (min_hide_size))
);
1939 break;
1940 case PANEL_STATE_HIDDEN_RIGHT:
1941 gtk_widget_get_allocation (toplevel->priv->hide_button_left,
1942 &hide_allocation);
1943 *x = monitor_geom.width - MAX (hide_allocation.width, min_hide_size)(((hide_allocation.width) > (min_hide_size)) ? (hide_allocation
.width) : (min_hide_size))
;
1944 break;
1945 default:
1946 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 1946, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1947 break;
1948 }
1949}
1950
1951/*
1952 * This is "almost" like the double sine movement
1953 * from the original panel except that it uses
1954 * a cubic (twice again). I suppose it looks less
1955 * mathematical now :) -- _v_
1956 */
1957static int
1958get_delta (int src,
1959 int dest,
1960 GTimeSpan elapsed_time,
1961 GTimeSpan duration_time)
1962{
1963 double x, percentage;
1964
1965 if (abs (dest - src) <= 1 || elapsed_time >= duration_time)
1966 return dest - src;
1967
1968 /* The cubic is: p(x) = (-2) x^2 (x-1.5) */
1969 /* running p(p(x)) to make it more "pronounced",
1970 * effectively making it a ninth-degree polynomial */
1971
1972 x = (double)elapsed_time/duration_time;
1973 x = -2 * (x*x) * (x-1.5);
1974 /* run it again */
1975 percentage = -2 * (x*x) * (x-1.5);
1976
1977 percentage = CLAMP (percentage, 0.0, 1.0)(((percentage) > (1.0)) ? (1.0) : (((percentage) < (0.0
)) ? (0.0) : (percentage)))
;
1978
1979 return ((dest - src) * percentage);
1980}
1981
1982static void
1983panel_toplevel_update_animating_position (PanelToplevel *toplevel)
1984{
1985 GTimeSpan animation_elapsed_time;
1986 int deltax, deltay, deltaw = 0, deltah = 0;
1987 int monitor_offset_x, monitor_offset_y;
1988
1989 if ((toplevel->priv->animation_start_time <= 0) ||
1990 (toplevel->priv->animation_duration_time <= 0))
1991 return;
1992
1993 animation_elapsed_time = g_get_monotonic_time () - toplevel->priv->animation_start_time;
1994
1995 monitor_offset_x = panel_multimonitor_x (toplevel->priv->monitor);
1996 monitor_offset_y = panel_multimonitor_y (toplevel->priv->monitor);
1997
1998 if (toplevel->priv->animation_end_width != -1)
1999 deltaw = get_delta (toplevel->priv->geometry.width,
2000 toplevel->priv->animation_end_width,
2001 animation_elapsed_time,
2002 toplevel->priv->animation_duration_time);
2003
2004 if (toplevel->priv->animation_end_height != -1)
2005 deltah = get_delta (toplevel->priv->geometry.height,
2006 toplevel->priv->animation_end_height,
2007 animation_elapsed_time,
2008 toplevel->priv->animation_duration_time);
2009
2010 deltax = get_delta (toplevel->priv->geometry.x - monitor_offset_x,
2011 toplevel->priv->animation_end_x,
2012 animation_elapsed_time,
2013 toplevel->priv->animation_duration_time);
2014
2015 deltay = get_delta (toplevel->priv->geometry.y - monitor_offset_y,
2016 toplevel->priv->animation_end_y,
2017 animation_elapsed_time,
2018 toplevel->priv->animation_duration_time);
2019
2020 if (deltaw != 0 && abs (deltaw) > abs (deltax))
2021 deltax = deltaw;
2022 if (deltah != 0 && abs (deltah) > abs (deltay))
2023 deltay = deltah;
2024
2025 toplevel->priv->geometry.x += deltax;
2026 toplevel->priv->geometry.y += deltay;
2027
2028 toplevel->priv->geometry.width += deltaw;
2029 toplevel->priv->geometry.height += deltah;
2030
2031 if (toplevel->priv->geometry.x - monitor_offset_x == toplevel->priv->animation_end_x &&
2032 toplevel->priv->geometry.y - monitor_offset_y == toplevel->priv->animation_end_y) {
2033 toplevel->priv->animating = FALSE(0);
2034 /* Note: it's important to set initial_animation_done to TRUE
2035 * as soon as possible (hence, here) since we don't want to
2036 * have a wrong value in a size request event */
2037 toplevel->priv->initial_animation_done = TRUE(!(0));
2038
2039 if (toplevel->priv->attached && panel_toplevel_get_is_hidden (toplevel))
2040 gtk_widget_unmap (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
2041 else
2042 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
2043
2044 if (toplevel->priv->state == PANEL_STATE_NORMAL)
2045 g_signal_emit (toplevel, toplevel_signals [UNHIDE_SIGNAL], 0);
2046 }
2047}
2048
2049static void
2050panel_toplevel_update_expanded_position (PanelToplevel *toplevel)
2051{
2052 GdkRectangle monitor_geom;
2053 int x, y;
2054 int x_right, y_bottom;
2055 int monitor;
2056
2057 if (!toplevel->priv->expand)
2058 return;
2059
2060 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
2061
2062 x = -1;
Value stored to 'x' is never read
2063 y = -1;
2064 x_right = -1;
2065 y_bottom = -1;
2066
2067 switch (toplevel->priv->orientation) {
2068 case PANEL_ORIENTATION_TOP:
2069 x = monitor_geom.x;
2070 y = monitor_geom.y;
2071 break;
2072 case PANEL_ORIENTATION_LEFT:
2073 x = monitor_geom.x;
2074 y = monitor_geom.y;
2075 break;
2076 case PANEL_ORIENTATION_BOTTOM:
2077 x = monitor_geom.x;
2078 y = monitor_geom.y + monitor_geom.height - toplevel->priv->geometry.height;
2079 y_bottom = 0;
2080 break;
2081 case PANEL_ORIENTATION_RIGHT:
2082 x = monitor_geom.x + monitor_geom.width - toplevel->priv->geometry.width;
2083 y = monitor_geom.y;
2084 x_right = 0;
2085 break;
2086 default:
2087 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 2087, ((const char*) (__func__)), ((void*)0)); } while (0)
;
2088 break;
2089 }
2090
2091 monitor = panel_multimonitor_get_monitor_at_point (x, y);
2092
2093 panel_toplevel_set_monitor_internal (toplevel, monitor, TRUE(!(0)));
2094
2095 x -= panel_multimonitor_x (monitor);
2096 y -= panel_multimonitor_y (monitor);
2097
2098 g_object_freeze_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
);
2099
2100 if (toplevel->priv->x != x) {
2101 toplevel->priv->x = x;
2102 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "x");
2103 }
2104
2105 if (toplevel->priv->y != y) {
2106 toplevel->priv->y = y;
2107 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "y");
2108 }
2109
2110 if (toplevel->priv->x_right != x_right) {
2111 toplevel->priv->x_right = x_right;
2112 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "x_right");
2113 }
2114
2115 if (toplevel->priv->y_bottom != y_bottom) {
2116 toplevel->priv->y_bottom = y_bottom;
2117 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "y_bottom");
2118 }
2119
2120 g_object_thaw_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
);
2121}
2122
2123static void
2124panel_toplevel_update_position (PanelToplevel *toplevel)
2125{
2126 PanelBackground *background;
2127 int x, y;
2128 int w, h;
2129 GdkRectangle monitor_geom;
2130
2131 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
2132
2133 if (toplevel->priv->animating) {
2134 panel_toplevel_update_animating_position (toplevel);
2135 return;
2136 }
2137
2138 if (toplevel->priv->position_centered) {
2139 toplevel->priv->position_centered = FALSE(0);
2140
2141 g_object_freeze_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
);
2142
2143 if (!toplevel->priv->x_centered) {
2144 int x_right;
2145
2146 toplevel->priv->x -= toplevel->priv->geometry.width / 2;
2147 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "x");
2148
2149 if ((toplevel->priv->x + toplevel->priv->geometry.width / 2) > monitor_geom.width / 2)
2150 x_right = monitor_geom.width - (toplevel->priv->x + toplevel->priv->geometry.width);
2151 else
2152 x_right = -1;
2153 if (toplevel->priv->x_right != x_right) {
2154 toplevel->priv->x_right = x_right;
2155 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
,
2156 "x-right");
2157 }
2158 }
2159
2160 if (!toplevel->priv->y_centered) {
2161 int y_bottom;
2162
2163 toplevel->priv->y -= toplevel->priv->geometry.height / 2;
2164 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "y");
2165
2166 if ((toplevel->priv->y + toplevel->priv->geometry.height / 2) > monitor_geom.height / 2)
2167 y_bottom = monitor_geom.height - (toplevel->priv->y + toplevel->priv->geometry.height);
2168 else
2169 y_bottom = -1;
2170 if (toplevel->priv->y_bottom != y_bottom) {
2171 toplevel->priv->y_bottom = y_bottom;
2172 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
,
2173 "y-bottom");
2174 }
2175 }
2176
2177 g_object_thaw_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
);
2178 }
2179
2180 panel_toplevel_update_expanded_position (toplevel);
2181 panel_toplevel_calc_floating (toplevel); /* FIXME should probably be done after panel_toplevel_update_normal_position() too */
2182
2183 if (toplevel->priv->x_right == -1)
2184 x = toplevel->priv->x;
2185 else
2186 x = monitor_geom.width - (toplevel->priv->x_right + toplevel->priv->geometry.width);
2187 if (toplevel->priv->y_bottom == -1)
2188 y = toplevel->priv->y;
2189 else
2190 y = monitor_geom.height - (toplevel->priv->y_bottom + toplevel->priv->geometry.height);
2191
2192 if (!toplevel->priv->expand) {
2193 if (toplevel->priv->x_centered)
2194 x = (monitor_geom.width - toplevel->priv->geometry.width) / 2;
2195 if (toplevel->priv->y_centered)
2196 y = (monitor_geom.height - toplevel->priv->geometry.height) / 2;
2197 }
2198
2199 w = h = -1;
2200
2201 if (toplevel->priv->state == PANEL_STATE_NORMAL)
2202 panel_toplevel_update_normal_position (toplevel, &x, &y, &w, &h);
2203
2204 else if (toplevel->priv->state == PANEL_STATE_AUTO_HIDDEN)
2205 panel_toplevel_update_auto_hide_position (toplevel, &x, &y, &w, &h, FALSE(0));
2206
2207 else
2208 panel_toplevel_update_hidden_position (toplevel, &x, &y, &w, &h);
2209
2210 if (w != -1)
2211 toplevel->priv->geometry.width = w;
2212 if (h != -1)
2213 toplevel->priv->geometry.height = h;
2214
2215 /* This is some kind of snap: there's a possibility of an infinite loop
2216 * because of the bevels of the frame that are set in
2217 * panel_toplevel_update_edges(). The bevels change the width/height of
2218 * the toplevel. The typical loop is:
2219 * x = 1 => outer bevel => x = 0 => no outer bevel = > x = 1 => ...
2220 * FIXME: maybe the real bug is that we enter into this loop (see bug
2221 * #160748 to learn how to reproduce.) */
2222 background = &toplevel->background;
2223
2224 /* There's no bevels with a color/image background */
2225 if (panel_background_effective_type (background) == PANEL_BACK_NONE) {
2226 GtkStyleContext *context;
2227 GtkStateFlags state;
2228 GdkRectangle *geometry;
2229 GtkBorder padding;
2230 int max_size;
2231
2232 state = gtk_widget_get_state_flags (GTK_WIDGET (toplevel->priv->inner_frame)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->inner_frame)), ((gtk_widget_get_type
()))))))
);
2233 context = gtk_widget_get_style_context (GTK_WIDGET (toplevel->priv->inner_frame)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->inner_frame)), ((gtk_widget_get_type
()))))))
);
2234 gtk_style_context_get_padding (context, state, &padding);
2235 geometry = &toplevel->priv->geometry;
2236
2237 if (x <= padding.left && x > 0 &&
2238 !toplevel->priv->x_centered)
2239 x = 0;
2240
2241 if (y <= padding.top && y > 0 &&
2242 !toplevel->priv->y_centered)
2243 y = 0;
2244
2245 max_size = monitor_geom.width - geometry->width - padding.right;
2246 if (x + padding.left >= max_size && x < max_size &&
2247 !toplevel->priv->x_centered)
2248 x = max_size;
2249
2250 max_size = monitor_geom.height - geometry->height - padding.bottom;
2251 if (y + padding.top >= max_size && y < max_size &&
2252 !toplevel->priv->y_centered)
2253 y = max_size;
2254 }
2255
2256 x += panel_multimonitor_x (toplevel->priv->monitor);
2257 y += panel_multimonitor_y (toplevel->priv->monitor);
2258
2259 toplevel->priv->geometry.x = x;
2260 toplevel->priv->geometry.y = y;
2261}
2262
2263static int
2264calculate_minimum_height (GtkWidget *widget,
2265 PanelOrientation orientation)
2266{
2267 GtkStateFlags state;
2268 GtkStyleContext *style_context;
2269 PangoFontDescription *font_desc;
2270 GtkBorder padding;
2271 PangoContext *pango_context;
2272 PangoFontMetrics *metrics;
2273 int ascent;
2274 int descent;
2275 int thickness;
2276
2277 state = gtk_widget_get_state_flags (widget);
2278 style_context = gtk_widget_get_style_context (widget);
2279 gtk_style_context_get(style_context, state, GTK_STYLE_PROPERTY_FONT"font", &font_desc, NULL((void*)0));
2280
2281 pango_context = gtk_widget_get_pango_context (widget);
2282 metrics = pango_context_get_metrics (pango_context,
2283 font_desc,
2284 pango_context_get_language (pango_context));
2285 gtk_style_context_get_padding (style_context, state, &padding);
2286
2287 ascent = pango_font_metrics_get_ascent (metrics);
2288 descent = pango_font_metrics_get_descent (metrics);
2289
2290 pango_font_description_free (font_desc);
2291 pango_font_metrics_unref (metrics);
2292
2293 thickness = (orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)) ?
2294 padding.top + padding.bottom :
2295 padding.left + padding.right;
2296
2297 return PANGO_PIXELS (ascent + descent)(((int)(ascent + descent) + 512) >> 10) + thickness;
2298}
2299
2300static int
2301panel_toplevel_update_size_from_hints (PanelToplevel *toplevel,
2302 int requisition_size,
2303 int monitor_size,
2304 int non_panel_widget_size)
2305{
2306 int nb_size_hints;
2307 AppletSizeHints *applets_hints;
2308 AppletSizeHintsAlloc *using_hint;
2309
2310 int i;
2311 int total_size;
2312 int full_hints;
2313
2314 /* Scale down the size so that the panel only takes what it needs for the applets it has. */
2315 total_size = non_panel_widget_size + (requisition_size / toplevel->priv->scale);
2316
2317 nb_size_hints = toplevel->priv->panel_widget->nb_applets_size_hints;
2318 if (nb_size_hints <= 0)
2319 return total_size;
2320
2321 applets_hints = toplevel->priv->panel_widget->applets_hints;
2322 using_hint = toplevel->priv->panel_widget->applets_using_hint;
2323
2324 for (i = 0; i < nb_size_hints; i++) {
2325 using_hint[i].index = applets_hints[i].len - 2;
2326 using_hint[i].size = applets_hints[i].hints[applets_hints[i].len - 1];
2327 total_size += using_hint[i].size;
2328 }
2329
2330 if (total_size > monitor_size)
2331 return monitor_size;
2332
2333 full_hints = 0;
2334 while (full_hints != nb_size_hints && total_size < monitor_size) {
2335 int bonus;
2336 int extra_bonus;
2337
2338 bonus = (monitor_size - total_size)
2339 / (nb_size_hints - full_hints);
2340 extra_bonus = (monitor_size - total_size)
2341 % (nb_size_hints - full_hints);
2342 full_hints = 0;
2343
2344 for (i = 0; i < nb_size_hints; i++) {
2345 int new_size;
2346 int current_bonus;
2347
2348 current_bonus = bonus;
2349
2350 while (using_hint[i].index > 0 && applets_hints[i].hints[using_hint[i].index - 1] < using_hint[i].size + current_bonus) {
2351 new_size = applets_hints[i].hints[using_hint[i].index - 1];
2352 current_bonus = using_hint[i].size
2353 + current_bonus - new_size;
2354 total_size = total_size - using_hint[i].size
2355 + new_size;
2356
2357 using_hint[i].index -= 2;
2358 using_hint[i].size = new_size;
2359 }
2360
2361 new_size = MIN (applets_hints[i].hints[using_hint[i].index],(((applets_hints[i].hints[using_hint[i].index]) < (using_hint
[i].size + current_bonus)) ? (applets_hints[i].hints[using_hint
[i].index]) : (using_hint[i].size + current_bonus))
2362 using_hint[i].size + current_bonus)(((applets_hints[i].hints[using_hint[i].index]) < (using_hint
[i].size + current_bonus)) ? (applets_hints[i].hints[using_hint
[i].index]) : (using_hint[i].size + current_bonus))
;
2363 if (new_size > using_hint[i].size) {
2364 total_size += (new_size - using_hint[i].size);
2365 using_hint[i].size = new_size;
2366 }
2367
2368 if (extra_bonus > 0) {
2369 new_size = MIN (applets_hints[i].hints[using_hint[i].index],(((applets_hints[i].hints[using_hint[i].index]) < (using_hint
[i].size + extra_bonus)) ? (applets_hints[i].hints[using_hint
[i].index]) : (using_hint[i].size + extra_bonus))
2370 using_hint[i].size + extra_bonus)(((applets_hints[i].hints[using_hint[i].index]) < (using_hint
[i].size + extra_bonus)) ? (applets_hints[i].hints[using_hint
[i].index]) : (using_hint[i].size + extra_bonus))
;
2371 if (new_size > using_hint[i].size) {
2372 total_size += (new_size
2373 - using_hint[i].size);
2374 extra_bonus -= (new_size
2375 - using_hint[i].size);
2376 using_hint[i].size = new_size;
2377 }
2378 }
2379
2380 if (using_hint[i].size == applets_hints[i].hints[using_hint[i].index])
2381 full_hints++;
2382 }
2383 }
2384
2385 return total_size;
2386}
2387
2388static void
2389panel_toplevel_update_size (PanelToplevel *toplevel,
2390 GtkRequisition *requisition)
2391{
2392 GtkWidget *widget;
2393 GtkStyleContext *context;
2394 GtkStateFlags state;
2395 GtkBorder padding;
2396 GdkRectangle monitor_geom;
2397 int width, height;
2398 int minimum_height;
2399 int non_panel_widget_size;
2400
2401 if (toplevel->priv->animating)
2402 return;
2403
2404 widget = GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
;
2405 context = gtk_widget_get_style_context (widget);
2406 state = gtk_widget_get_state_flags (widget);
2407 gtk_style_context_get_padding (context, state, &padding);
2408
2409 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
2410
2411 width = requisition->width;
2412 height = requisition->height;
2413
2414 if (!toplevel->priv->expand &&
2415 !toplevel->priv->buttons_enabled && !toplevel->priv->attached)
2416 non_panel_widget_size = 2 * HANDLE_SIZE10;
2417 else
2418 non_panel_widget_size = 0;
2419
2420 minimum_height = calculate_minimum_height (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
,
2421 toplevel->priv->orientation);
2422
2423 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)) {
2424
2425 height = MAX (MIN (MAX (height, toplevel->priv->size),(((((((((height) > (toplevel->priv->size)) ? (height
) : (toplevel->priv->size))) < (panel_toplevel_get_maximum_size
(toplevel))) ? ((((height) > (toplevel->priv->size)
) ? (height) : (toplevel->priv->size))) : (panel_toplevel_get_maximum_size
(toplevel)))) > (minimum_height)) ? (((((((height) > (
toplevel->priv->size)) ? (height) : (toplevel->priv->
size))) < (panel_toplevel_get_maximum_size (toplevel))) ? (
(((height) > (toplevel->priv->size)) ? (height) : (toplevel
->priv->size))) : (panel_toplevel_get_maximum_size (toplevel
)))) : (minimum_height))
2426 panel_toplevel_get_maximum_size (toplevel)),(((((((((height) > (toplevel->priv->size)) ? (height
) : (toplevel->priv->size))) < (panel_toplevel_get_maximum_size
(toplevel))) ? ((((height) > (toplevel->priv->size)
) ? (height) : (toplevel->priv->size))) : (panel_toplevel_get_maximum_size
(toplevel)))) > (minimum_height)) ? (((((((height) > (
toplevel->priv->size)) ? (height) : (toplevel->priv->
size))) < (panel_toplevel_get_maximum_size (toplevel))) ? (
(((height) > (toplevel->priv->size)) ? (height) : (toplevel
->priv->size))) : (panel_toplevel_get_maximum_size (toplevel
)))) : (minimum_height))
2427 minimum_height)(((((((((height) > (toplevel->priv->size)) ? (height
) : (toplevel->priv->size))) < (panel_toplevel_get_maximum_size
(toplevel))) ? ((((height) > (toplevel->priv->size)
) ? (height) : (toplevel->priv->size))) : (panel_toplevel_get_maximum_size
(toplevel)))) > (minimum_height)) ? (((((((height) > (
toplevel->priv->size)) ? (height) : (toplevel->priv->
size))) < (panel_toplevel_get_maximum_size (toplevel))) ? (
(((height) > (toplevel->priv->size)) ? (height) : (toplevel
->priv->size))) : (panel_toplevel_get_maximum_size (toplevel
)))) : (minimum_height))
;
2428
2429 if (toplevel->priv->expand)
2430 width = monitor_geom.width;
2431 else {
2432 int max_width;
2433
2434 if (!toplevel->priv->attached)
2435 max_width = monitor_geom.width;
2436 else {
2437 if (panel_toplevel_get_orientation (toplevel->priv->attach_toplevel) == PANEL_ORIENTATION_LEFT)
2438 max_width = monitor_geom.width
2439 - toplevel->priv->geometry.x;
2440 else
2441 max_width = toplevel->priv->geometry.x +
2442 toplevel->priv->geometry.width;
2443 }
2444
2445 width = panel_toplevel_update_size_from_hints (
2446 toplevel,
2447 requisition->width,
2448 max_width,
2449 non_panel_widget_size);
2450 }
2451
2452 width = MAX (MINIMUM_WIDTH, width)(((100) > (width)) ? (100) : (width));
2453 } else {
2454 width = MAX (MIN (MAX (width, toplevel->priv->size),(((((((((width) > (toplevel->priv->size)) ? (width) :
(toplevel->priv->size))) < (panel_toplevel_get_maximum_size
(toplevel))) ? ((((width) > (toplevel->priv->size))
? (width) : (toplevel->priv->size))) : (panel_toplevel_get_maximum_size
(toplevel)))) > (minimum_height)) ? (((((((width) > (toplevel
->priv->size)) ? (width) : (toplevel->priv->size)
)) < (panel_toplevel_get_maximum_size (toplevel))) ? ((((width
) > (toplevel->priv->size)) ? (width) : (toplevel->
priv->size))) : (panel_toplevel_get_maximum_size (toplevel
)))) : (minimum_height))
2455 panel_toplevel_get_maximum_size (toplevel)),(((((((((width) > (toplevel->priv->size)) ? (width) :
(toplevel->priv->size))) < (panel_toplevel_get_maximum_size
(toplevel))) ? ((((width) > (toplevel->priv->size))
? (width) : (toplevel->priv->size))) : (panel_toplevel_get_maximum_size
(toplevel)))) > (minimum_height)) ? (((((((width) > (toplevel
->priv->size)) ? (width) : (toplevel->priv->size)
)) < (panel_toplevel_get_maximum_size (toplevel))) ? ((((width
) > (toplevel->priv->size)) ? (width) : (toplevel->
priv->size))) : (panel_toplevel_get_maximum_size (toplevel
)))) : (minimum_height))
2456 minimum_height)(((((((((width) > (toplevel->priv->size)) ? (width) :
(toplevel->priv->size))) < (panel_toplevel_get_maximum_size
(toplevel))) ? ((((width) > (toplevel->priv->size))
? (width) : (toplevel->priv->size))) : (panel_toplevel_get_maximum_size
(toplevel)))) > (minimum_height)) ? (((((((width) > (toplevel
->priv->size)) ? (width) : (toplevel->priv->size)
)) < (panel_toplevel_get_maximum_size (toplevel))) ? ((((width
) > (toplevel->priv->size)) ? (width) : (toplevel->
priv->size))) : (panel_toplevel_get_maximum_size (toplevel
)))) : (minimum_height))
;
2457
2458 if (toplevel->priv->expand)
2459 height = monitor_geom.height;
2460 else {
2461 int max_height;
2462
2463 if (!toplevel->priv->attached)
2464 max_height = monitor_geom.height;
2465 else {
2466 if (panel_toplevel_get_orientation (toplevel->priv->attach_toplevel) == PANEL_ORIENTATION_TOP)
2467 max_height = monitor_geom.height
2468 - toplevel->priv->geometry.y;
2469 else
2470 max_height = toplevel->priv->geometry.y +
2471 toplevel->priv->geometry.height;
2472 }
2473
2474 height = panel_toplevel_update_size_from_hints (
2475 toplevel,
2476 requisition->height,
2477 max_height,
2478 non_panel_widget_size);
2479 }
2480
2481 height = MAX (MINIMUM_WIDTH, height)(((100) > (height)) ? (100) : (height));
2482 }
2483
2484 if (toplevel->priv->edges & PANEL_EDGE_TOP)
2485 height += padding.top;
2486 if (toplevel->priv->edges & PANEL_EDGE_BOTTOM)
2487 height += padding.bottom;
2488 if (toplevel->priv->edges & PANEL_EDGE_LEFT)
2489 width += padding.left;
2490 if (toplevel->priv->edges & PANEL_EDGE_RIGHT)
2491 width += padding.right;
2492
2493 toplevel->priv->geometry.width = CLAMP (width, 0, monitor_geom.width)(((width) > (monitor_geom.width)) ? (monitor_geom.width) :
(((width) < (0)) ? (0) : (width)))
;
2494 toplevel->priv->geometry.height = CLAMP (height, 0, monitor_geom.height)(((height) > (monitor_geom.height)) ? (monitor_geom.height
) : (((height) < (0)) ? (0) : (height)))
;
2495 toplevel->priv->original_width = toplevel->priv->geometry.width;
2496 toplevel->priv->original_height = toplevel->priv->geometry.height;
2497}
2498
2499static void
2500panel_toplevel_update_geometry (PanelToplevel *toplevel,
2501 GtkRequisition *requisition)
2502{
2503 toplevel->priv->updated_geometry_initial = TRUE(!(0));
2504 panel_toplevel_update_size (toplevel, requisition);
2505 panel_toplevel_update_position (toplevel);
2506
2507 panel_toplevel_update_struts (toplevel, FALSE(0));
2508
2509#ifdef HAVE_X111
2510 if (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel)))(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gtk_widget_get_display (((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((toplevel)), ((gtk_widget_get_type ()))))
))))); GType __t = ((gdk_x11_display_get_type())); gboolean __r
; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
) {
2511 if (toplevel->priv->state == PANEL_STATE_NORMAL ||
2512 toplevel->priv->state != PANEL_STATE_AUTO_HIDDEN) {
2513 panel_struts_update_toplevel_geometry (toplevel,
2514 &toplevel->priv->geometry.x,
2515 &toplevel->priv->geometry.y,
2516 &toplevel->priv->geometry.width,
2517 &toplevel->priv->geometry.height);
2518 } else {
2519 panel_struts_update_toplevel_geometry (toplevel,
2520 &toplevel->priv->geometry.x,
2521 &toplevel->priv->geometry.y,
2522 NULL((void*)0), NULL((void*)0));
2523 }
2524 }
2525#endif /* HAVE_X11 */
2526
2527 panel_toplevel_update_edges (toplevel);
2528 panel_toplevel_update_description (toplevel);
2529}
2530
2531static void
2532panel_toplevel_attach_widget_destroyed (PanelToplevel *toplevel)
2533{
2534 panel_toplevel_detach (toplevel);
2535}
2536
2537static gboolean
2538panel_toplevel_attach_widget_configure (PanelToplevel *toplevel)
2539{
2540 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
2541
2542 return FALSE(0);
2543}
2544
2545static void
2546panel_toplevel_update_attach_orientation (PanelToplevel *toplevel)
2547{
2548 PanelOrientation attach_orientation;
2549 PanelOrientation orientation;
2550
2551 attach_orientation =
2552 panel_toplevel_get_orientation (toplevel->priv->attach_toplevel);
2553
2554 orientation = toplevel->priv->orientation;
2555
2556 switch (attach_orientation) {
2557 case PANEL_ORIENTATION_TOP:
2558 orientation = PANEL_ORIENTATION_LEFT;
2559 break;
2560 case PANEL_ORIENTATION_BOTTOM:
2561 orientation = PANEL_ORIENTATION_RIGHT;
2562 break;
2563 case PANEL_ORIENTATION_LEFT:
2564 orientation = PANEL_ORIENTATION_TOP;
2565 break;
2566 case PANEL_ORIENTATION_RIGHT:
2567 orientation = PANEL_ORIENTATION_BOTTOM;
2568 break;
2569 default:
2570 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 2570, ((const char*) (__func__)), ((void*)0)); } while (0)
;
2571 break;
2572 }
2573
2574 panel_toplevel_set_orientation (toplevel, orientation);
2575}
2576
2577static void
2578panel_toplevel_attach_widget_parent_set (PanelToplevel *toplevel,
2579 GtkWidget *previous_parent,
2580 GtkWidget *attach_widget)
2581{
2582 GtkWidget *panel_widget;
2583
2584 panel_widget = gtk_widget_get_parent (GTK_WIDGET (attach_widget)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((attach_widget)), ((gtk_widget_get_type ()))))))
);
2585 if (!panel_widget)
2586 return;
2587
2588 g_assert (PANEL_IS_WIDGET (panel_widget))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((panel_widget)); GType __t = ((panel_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_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 2588, ((const char*) (__func__)), "PANEL_IS_WIDGET (panel_widget)"
); } while (0)
;
2589
2590 toplevel->priv->attach_toplevel = PANEL_WIDGET (panel_widget)((((PanelWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((panel_widget)), ((panel_widget_get_type()))))))
->toplevel;
2591 panel_toplevel_update_attach_orientation (toplevel);
2592 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
2593}
2594
2595static void
2596panel_toplevel_attach_toplevel_hiding (PanelToplevel *toplevel)
2597{
2598 if (!panel_toplevel_get_is_hidden (toplevel)) {
2599 panel_toplevel_hide (toplevel, FALSE(0), -1);
2600
2601 toplevel->priv->attach_hidden = TRUE(!(0));
2602 }
2603}
2604
2605static void
2606panel_toplevel_attach_toplevel_unhiding (PanelToplevel *toplevel)
2607{
2608 if (!toplevel->priv->attach_hidden)
2609 return;
2610
2611 toplevel->priv->attach_hidden = FALSE(0);
2612
2613 panel_toplevel_unhide (toplevel);
2614}
2615
2616static void
2617panel_toplevel_reverse_arrow (PanelToplevel *toplevel,
2618 GtkWidget *button)
2619{
2620 GtkArrowType arrow_type;
2621
2622 arrow_type = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button), "arrow-type"))((gint) (glong) (g_object_get_data (((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((button)), (((GType) ((20) << (2)))
))))), "arrow-type")))
;
2623
2624 switch (arrow_type) {
2625 case GTK_ARROW_UP:
2626 arrow_type = GTK_ARROW_DOWN;
2627 break;
2628 case GTK_ARROW_DOWN:
2629 arrow_type = GTK_ARROW_UP;
2630 break;
2631 case GTK_ARROW_LEFT:
2632 arrow_type = GTK_ARROW_RIGHT;
2633 break;
2634 case GTK_ARROW_RIGHT:
2635 arrow_type = GTK_ARROW_LEFT;
2636 break;
2637 default:
2638 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 2638, ((const char*) (__func__)), ((void*)0)); } while (0)
;
2639 break;
2640 }
2641
2642 g_object_set_data (G_OBJECT (button)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), (((GType) ((20) << (2))))))))
, "arrow-type", GINT_TO_POINTER (arrow_type)((gpointer) (glong) (arrow_type)));
2643
2644 set_arrow_type (GTK_IMAGE (gtk_bin_get_child (GTK_BIN (button)))((((GtkImage*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_bin_get_child (((((GtkBin*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((button)), ((gtk_bin_get_type ())))))))))
, ((gtk_image_get_type ()))))))
, arrow_type);
2645}
2646
2647static void
2648panel_toplevel_reverse_arrows (PanelToplevel *toplevel)
2649{
2650 panel_toplevel_reverse_arrow (toplevel, toplevel->priv->hide_button_top);
2651 panel_toplevel_reverse_arrow (toplevel, toplevel->priv->hide_button_bottom);
2652 panel_toplevel_reverse_arrow (toplevel, toplevel->priv->hide_button_left);
2653 panel_toplevel_reverse_arrow (toplevel, toplevel->priv->hide_button_right);
2654}
2655
2656static void
2657panel_toplevel_disconnect_attached (PanelToplevel *toplevel)
2658{
2659 guint i;
2660
2661#if GLIB_CHECK_VERSION(2,62,0)(2 > (2) || (2 == (2) && 80 > (62)) || (2 == (2
) && 80 == (62) && 2 >= (0)))
2662 for (i = 0; i < N_ATTACH_TOPLEVEL_SIGNALS5; i++) {
2663 g_clear_signal_handler (&toplevel->priv->attach_toplevel_signals [i],do { gpointer const _instance = (toplevel->priv->attach_toplevel
); gulong *const _handler_id_ptr = (&toplevel->priv->
attach_toplevel_signals [i]); const gulong _handler_id = *_handler_id_ptr
; if (_handler_id > 0) { *_handler_id_ptr = 0; g_signal_handler_disconnect
(_instance, _handler_id); } } while (0)
2664 toplevel->priv->attach_toplevel)do { gpointer const _instance = (toplevel->priv->attach_toplevel
); gulong *const _handler_id_ptr = (&toplevel->priv->
attach_toplevel_signals [i]); const gulong _handler_id = *_handler_id_ptr
; if (_handler_id > 0) { *_handler_id_ptr = 0; g_signal_handler_disconnect
(_instance, _handler_id); } } while (0)
;
2665 }
2666
2667 for (i = 0; i < N_ATTACH_WIDGET_SIGNALS5; i++) {
2668 g_clear_signal_handler (&toplevel->priv->attach_widget_signals [i],do { gpointer const _instance = (toplevel->priv->attach_widget
); gulong *const _handler_id_ptr = (&toplevel->priv->
attach_widget_signals [i]); const gulong _handler_id = *_handler_id_ptr
; if (_handler_id > 0) { *_handler_id_ptr = 0; g_signal_handler_disconnect
(_instance, _handler_id); } } while (0)
2669 toplevel->priv->attach_widget)do { gpointer const _instance = (toplevel->priv->attach_widget
); gulong *const _handler_id_ptr = (&toplevel->priv->
attach_widget_signals [i]); const gulong _handler_id = *_handler_id_ptr
; if (_handler_id > 0) { *_handler_id_ptr = 0; g_signal_handler_disconnect
(_instance, _handler_id); } } while (0)
;
2670 }
2671#else
2672 for (i = 0; i < N_ATTACH_TOPLEVEL_SIGNALS5; i++) {
2673 if (toplevel->priv->attach_toplevel_signals [i] != 0) {
2674 g_signal_handler_disconnect (toplevel->priv->attach_toplevel,
2675 toplevel->priv->attach_toplevel_signals [i]);
2676 toplevel->priv->attach_toplevel_signals [i] = 0;
2677 }
2678 }
2679
2680 for (i = 0; i < N_ATTACH_WIDGET_SIGNALS5; i++) {
2681 if (toplevel->priv->attach_widget_signals [i] != 0) {
2682 g_signal_handler_disconnect (toplevel->priv->attach_widget,
2683 toplevel->priv->attach_widget_signals [i]);
2684 toplevel->priv->attach_widget_signals [i] = 0;
2685 }
2686 }
2687#endif
2688}
2689
2690static void
2691panel_toplevel_connect_attached (PanelToplevel *toplevel)
2692{
2693 gulong *signals;
2694 int i = 0;
2695
2696 signals = toplevel->priv->attach_toplevel_signals;
2697
2698 signals [i++] = g_signal_connect_swapped (g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("destroy"), (((GCallback) (panel_toplevel_attach_widget_destroyed
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2699 toplevel->priv->attach_toplevel, "destroy",g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("destroy"), (((GCallback) (panel_toplevel_attach_widget_destroyed
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2700 G_CALLBACK (panel_toplevel_attach_widget_destroyed), toplevel)g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("destroy"), (((GCallback) (panel_toplevel_attach_widget_destroyed
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
;
2701 signals [i++] = g_signal_connect_swapped (g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("notify::orientation"), (((GCallback) (panel_toplevel_update_attach_orientation
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2702 toplevel->priv->attach_toplevel, "notify::orientation",g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("notify::orientation"), (((GCallback) (panel_toplevel_update_attach_orientation
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2703 G_CALLBACK (panel_toplevel_update_attach_orientation), toplevel)g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("notify::orientation"), (((GCallback) (panel_toplevel_update_attach_orientation
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
;
2704 signals [i++] = g_signal_connect_swapped (g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("configure-event"), (((GCallback) (panel_toplevel_attach_widget_configure
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2705 toplevel->priv->attach_toplevel, "configure-event",g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("configure-event"), (((GCallback) (panel_toplevel_attach_widget_configure
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2706 G_CALLBACK (panel_toplevel_attach_widget_configure), toplevel)g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("configure-event"), (((GCallback) (panel_toplevel_attach_widget_configure
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
;
2707 signals [i++] = g_signal_connect_swapped (g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("hiding"), (((GCallback) (panel_toplevel_attach_toplevel_hiding
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2708 toplevel->priv->attach_toplevel, "hiding",g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("hiding"), (((GCallback) (panel_toplevel_attach_toplevel_hiding
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2709 G_CALLBACK (panel_toplevel_attach_toplevel_hiding), toplevel)g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("hiding"), (((GCallback) (panel_toplevel_attach_toplevel_hiding
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
;
2710 signals [i++] = g_signal_connect_swapped (g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("unhiding"), (((GCallback) (panel_toplevel_attach_toplevel_unhiding
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2711 toplevel->priv->attach_toplevel, "unhiding",g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("unhiding"), (((GCallback) (panel_toplevel_attach_toplevel_unhiding
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2712 G_CALLBACK (panel_toplevel_attach_toplevel_unhiding), toplevel)g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("unhiding"), (((GCallback) (panel_toplevel_attach_toplevel_unhiding
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
;
2713
2714 g_assert (i == N_ATTACH_TOPLEVEL_SIGNALS)do { if (i == 5) ; else g_assertion_message_expr (((gchar*) 0
), "panel-toplevel.c", 2714, ((const char*) (__func__)), "i == N_ATTACH_TOPLEVEL_SIGNALS"
); } while (0)
;
2715
2716 signals = toplevel->priv->attach_widget_signals;
2717 i = 0;
2718
2719 signals [i++] = g_signal_connect_swapped (g_signal_connect_data ((toplevel->priv->attach_widget),
("destroy"), (((GCallback) (panel_toplevel_attach_widget_destroyed
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2720 toplevel->priv->attach_widget, "destroy",g_signal_connect_data ((toplevel->priv->attach_widget),
("destroy"), (((GCallback) (panel_toplevel_attach_widget_destroyed
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2721 G_CALLBACK (panel_toplevel_attach_widget_destroyed), toplevel)g_signal_connect_data ((toplevel->priv->attach_widget),
("destroy"), (((GCallback) (panel_toplevel_attach_widget_destroyed
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
;
2722 signals [i++] = g_signal_connect_swapped (g_signal_connect_data ((toplevel->priv->attach_widget),
("configure-event"), (((GCallback) (panel_toplevel_attach_widget_configure
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2723 toplevel->priv->attach_widget, "configure-event",g_signal_connect_data ((toplevel->priv->attach_widget),
("configure-event"), (((GCallback) (panel_toplevel_attach_widget_configure
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2724 G_CALLBACK (panel_toplevel_attach_widget_configure), toplevel)g_signal_connect_data ((toplevel->priv->attach_widget),
("configure-event"), (((GCallback) (panel_toplevel_attach_widget_configure
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
;
2725 signals [i++] = g_signal_connect_swapped (g_signal_connect_data ((toplevel->priv->attach_widget),
("parent-set"), (((GCallback) (panel_toplevel_attach_widget_parent_set
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2726 toplevel->priv->attach_widget, "parent-set",g_signal_connect_data ((toplevel->priv->attach_widget),
("parent-set"), (((GCallback) (panel_toplevel_attach_widget_parent_set
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2727 G_CALLBACK (panel_toplevel_attach_widget_parent_set), toplevel)g_signal_connect_data ((toplevel->priv->attach_widget),
("parent-set"), (((GCallback) (panel_toplevel_attach_widget_parent_set
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
;
2728 signals [i++] = g_signal_connect_swapped (g_signal_connect_data ((toplevel->priv->attach_widget),
("show"), (((GCallback) (gtk_widget_show))), (toplevel), ((void
*)0), G_CONNECT_SWAPPED)
2729 toplevel->priv->attach_widget, "show",g_signal_connect_data ((toplevel->priv->attach_widget),
("show"), (((GCallback) (gtk_widget_show))), (toplevel), ((void
*)0), G_CONNECT_SWAPPED)
2730 G_CALLBACK (gtk_widget_show), toplevel)g_signal_connect_data ((toplevel->priv->attach_widget),
("show"), (((GCallback) (gtk_widget_show))), (toplevel), ((void
*)0), G_CONNECT_SWAPPED)
;
2731 signals [i++] = g_signal_connect_swapped (g_signal_connect_data ((toplevel->priv->attach_widget),
("hide"), (((GCallback) (gtk_widget_hide))), (toplevel), ((void
*)0), G_CONNECT_SWAPPED)
2732 toplevel->priv->attach_widget, "hide",g_signal_connect_data ((toplevel->priv->attach_widget),
("hide"), (((GCallback) (gtk_widget_hide))), (toplevel), ((void
*)0), G_CONNECT_SWAPPED)
2733 G_CALLBACK (gtk_widget_hide), toplevel)g_signal_connect_data ((toplevel->priv->attach_widget),
("hide"), (((GCallback) (gtk_widget_hide))), (toplevel), ((void
*)0), G_CONNECT_SWAPPED)
;
2734
2735 g_assert (i == N_ATTACH_WIDGET_SIGNALS)do { if (i == 5) ; else g_assertion_message_expr (((gchar*) 0
), "panel-toplevel.c", 2735, ((const char*) (__func__)), "i == N_ATTACH_WIDGET_SIGNALS"
); } while (0)
;
2736}
2737
2738void
2739panel_toplevel_attach_to_widget (PanelToplevel *toplevel,
2740 PanelToplevel *attach_toplevel,
2741 GtkWidget *attach_widget)
2742{
2743 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
2744 g_return_if_fail (PANEL_IS_TOPLEVEL (attach_toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((attach_toplevel)); GType __t = ((panel_toplevel_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0
), ((const char*) (__func__)), "PANEL_IS_TOPLEVEL (attach_toplevel)"
); return; } } while (0)
;
2745 g_return_if_fail (GTK_IS_WIDGET (attach_widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((attach_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 (((gchar*) 0), ((const
char*) (__func__)), "GTK_IS_WIDGET (attach_widget)"); return
; } } while (0)
;
2746
2747 if (toplevel->priv->attached)
2748 panel_toplevel_disconnect_attached (toplevel);
2749
2750 toplevel->priv->attached = TRUE(!(0));
2751
2752 /* Cancelling the initial animation for drawers in
2753 * panel_toplevel_initially_hide() is not enough, since this will
2754 * happen only when the toplevel is realized, which might be too late
2755 * for drawers (since it's realized when the drawer is clicked) */
2756 toplevel->priv->initial_animation_done = TRUE(!(0));
2757
2758 toplevel->priv->attach_toplevel = attach_toplevel;
2759 toplevel->priv->attach_widget = attach_widget;
2760
2761 panel_toplevel_connect_attached (toplevel);
2762
2763 panel_toplevel_reverse_arrows (toplevel);
2764 panel_toplevel_set_expand (toplevel, FALSE(0));
2765 panel_toplevel_update_attach_orientation (toplevel);
2766 panel_toplevel_update_hide_buttons (toplevel);
2767
2768 gtk_window_set_screen (GTK_WINDOW (toplevel)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_window_get_type ()))))))
,
2769 gtk_widget_get_screen (GTK_WIDGET (attach_toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((attach_toplevel)), ((gtk_widget_get_type ()))))))
));
2770 panel_toplevel_set_monitor (toplevel,
2771 panel_toplevel_get_monitor (attach_toplevel));
2772 if (toplevel->priv->state == PANEL_STATE_NORMAL)
2773 panel_toplevel_push_autohide_disabler (toplevel->priv->attach_toplevel);
2774
2775 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
2776}
2777
2778void
2779panel_toplevel_detach (PanelToplevel *toplevel)
2780{
2781 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
2782
2783 if (!toplevel->priv->attached)
2784 return;
2785
2786 if (toplevel->priv->state == PANEL_STATE_NORMAL)
2787 panel_toplevel_pop_autohide_disabler (toplevel->priv->attach_toplevel);
2788
2789 panel_toplevel_disconnect_attached (toplevel);
2790
2791 panel_toplevel_reverse_arrows (toplevel);
2792
2793 toplevel->priv->attached = FALSE(0);
2794
2795 toplevel->priv->attach_toplevel = NULL((void*)0);
2796 toplevel->priv->attach_widget = NULL((void*)0);
2797
2798 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
2799}
2800
2801gboolean
2802panel_toplevel_get_is_attached (PanelToplevel *toplevel)
2803{
2804 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return ((0));
} } while (0)
;
2805
2806 return toplevel->priv->attached;
2807}
2808
2809PanelToplevel *
2810panel_toplevel_get_attach_toplevel (PanelToplevel *toplevel)
2811{
2812 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return (((void
*)0)); } } while (0)
;
2813
2814 return toplevel->priv->attach_toplevel;
2815}
2816
2817GtkWidget *
2818panel_toplevel_get_attach_widget (PanelToplevel *toplevel)
2819{
2820 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return (((void
*)0)); } } while (0)
;
2821
2822 return toplevel->priv->attach_widget;
2823}
2824
2825static gboolean
2826panel_toplevel_popup_panel_menu (PanelToplevel *toplevel)
2827{
2828 gboolean retval = FALSE(0);
2829
2830 g_signal_emit_by_name (toplevel, "popup-menu", &retval);
2831
2832 return retval;
2833}
2834
2835static gboolean
2836panel_toplevel_toggle_expand (PanelToplevel *toplevel)
2837{
2838 panel_toplevel_set_expand (toplevel, !toplevel->priv->expand);
2839
2840 return TRUE(!(0));
2841}
2842
2843static gboolean
2844panel_toplevel_expand (PanelToplevel *toplevel)
2845{
2846 panel_toplevel_set_expand (toplevel, TRUE(!(0)));
2847
2848 return TRUE(!(0));
2849}
2850
2851static gboolean
2852panel_toplevel_unexpand (PanelToplevel *toplevel)
2853{
2854 panel_toplevel_set_expand (toplevel, FALSE(0));
2855
2856 return TRUE(!(0));
2857}
2858
2859static gboolean
2860panel_toplevel_toggle_hidden (PanelToplevel *toplevel)
2861{
2862 if (toplevel->priv->state == PANEL_STATE_NORMAL)
2863 panel_toplevel_hide (toplevel, toplevel->priv->auto_hide, -1);
2864 else
2865 panel_toplevel_unhide (toplevel);
2866
2867 return FALSE(0);
2868}
2869
2870static gboolean
2871panel_toplevel_begin_move (PanelToplevel *toplevel)
2872{
2873 if (toplevel->priv->grab_op != PANEL_GRAB_OP_NONE)
2874 return FALSE(0);
2875
2876 panel_toplevel_begin_grab_op (
2877 toplevel, PANEL_GRAB_OP_MOVE, TRUE(!(0)), GDK_CURRENT_TIME0L);
2878
2879 return TRUE(!(0));
2880}
2881
2882static gboolean
2883panel_toplevel_begin_resize (PanelToplevel *toplevel)
2884{
2885 if (toplevel->priv->grab_op != PANEL_GRAB_OP_NONE)
2886 return FALSE(0);
2887
2888 panel_toplevel_begin_grab_op (
2889 toplevel, PANEL_GRAB_OP_RESIZE, TRUE(!(0)), GDK_CURRENT_TIME0L);
2890
2891 return TRUE(!(0));
2892}
2893
2894static void
2895panel_toplevel_move_resize_window (PanelToplevel *toplevel,
2896 gboolean move,
2897 gboolean resize)
2898{
2899 GtkWidget *widget;
2900
2901 GList *list;
2902 gboolean stick;
2903
2904 widget = GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
;
2905
2906 g_assert (gtk_widget_get_realized (widget))do { if (gtk_widget_get_realized (widget)) ; else g_assertion_message_expr
(((gchar*) 0), "panel-toplevel.c", 2906, ((const char*) (__func__
)), "gtk_widget_get_realized (widget)"); } while (0)
;
2907
2908 if (move && resize)
2909 gdk_window_move_resize (gtk_widget_get_window (widget),
2910 toplevel->priv->geometry.x,
2911 toplevel->priv->geometry.y,
2912 toplevel->priv->geometry.width,
2913 toplevel->priv->geometry.height);
2914 else if (move)
2915 gdk_window_move (gtk_widget_get_window (widget),
2916 toplevel->priv->geometry.x,
2917 toplevel->priv->geometry.y);
2918 else if (resize)
2919 gdk_window_resize (gtk_widget_get_window (widget),
2920 toplevel->priv->geometry.width,
2921 toplevel->priv->geometry.height);
2922
2923 if (resize || move) {
2924 for (list = toplevel->priv->panel_widget->applet_list; list != NULL((void*)0); list = g_list_next (list)((list) ? (((GList *)(list))->next) : ((void*)0))) {
2925 AppletData *ad = list->data;
2926 const char *id = mate_panel_applet_get_id_by_widget (ad->applet);
2927
2928 if (!id)
2929 return;
2930
2931 AppletInfo *info;
2932 info = mate_panel_applet_get_by_id (id);
2933
2934 stick = g_settings_get_boolean (info->settings, PANEL_OBJECT_PANEL_RIGHT_STICK_KEY"panel-right-stick");
2935
2936 if (stick) {
2937 int position = g_settings_get_int (info->settings, PANEL_OBJECT_POSITION_KEY"position");
2938 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)) {
2939 ad->pos = toplevel->priv->geometry.width - position;
2940 } else {
2941 ad->pos = toplevel->priv->geometry.height - position;
2942 }
2943 }
2944 }
2945 }
2946}
2947
2948static void
2949panel_toplevel_initially_hide (PanelToplevel *toplevel)
2950{
2951 if (!toplevel->priv->attached) {
2952 toplevel->priv->initial_animation_done = FALSE(0);
2953
2954 /* We start the panel off hidden until all the applets are
2955 * loaded, and then finally slide it down when it's ready to be
2956 * used */
2957 toplevel->priv->state = PANEL_STATE_AUTO_HIDDEN;
2958 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
2959 } else
2960 toplevel->priv->initial_animation_done = TRUE(!(0));
2961}
2962
2963static void
2964set_background_default_style (GtkWidget *widget)
2965{
2966 PanelToplevel *toplevel;
2967 GtkStyleContext *context;
2968 GtkStateFlags state;
2969 GdkRGBA *bg_color;
2970 cairo_pattern_t *bg_image;
2971
2972 if (!gtk_widget_get_realized (widget))
2973 return;
2974
2975 toplevel = PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
;
2976
2977 context = gtk_widget_get_style_context (widget);
2978 state = gtk_style_context_get_state (context);
2979
2980 gtk_style_context_get (context, state,
2981 "background-color", &bg_color,
2982 "background-image", &bg_image,
2983 NULL((void*)0));
2984
2985 panel_background_set_default_style (&toplevel->background,
2986 bg_color, bg_image);
2987
2988 if (bg_color)
2989 gdk_rgba_free (bg_color);
2990
2991 if (bg_image)
2992 cairo_pattern_destroy (bg_image);
2993}
2994
2995static void
2996panel_toplevel_realize (GtkWidget *widget)
2997{
2998 PanelToplevel *toplevel;
2999 GdkScreen *screen;
3000 GdkVisual *visual;
3001 GdkWindow *window;
3002
3003 toplevel = PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
;
3004
3005 screen = gtk_widget_get_screen (widget);
3006 visual = gdk_screen_get_rgba_visual (screen);
3007
3008 if (visual == NULL((void*)0))
3009 visual = gdk_screen_get_system_visual (screen);
3010
3011 gtk_widget_set_visual (widget, visual);
3012 gtk_window_stick (GTK_WINDOW (widget)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_window_get_type ()))))))
);
3013 gtk_window_set_decorated (GTK_WINDOW (widget)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_window_get_type ()))))))
, FALSE(0));
3014 gtk_window_stick (GTK_WINDOW (widget)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_window_get_type ()))))))
);
3015 gtk_window_set_type_hint (GTK_WINDOW (widget)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_window_get_type ()))))))
, GDK_WINDOW_TYPE_HINT_DOCK);
3016
3017 GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->realize (widget);
3018
3019 window = gtk_widget_get_window (widget);
3020 set_background_default_style (widget);
3021 panel_background_realized (&toplevel->background, window);
3022
3023#ifdef HAVE_X111
3024 if (GDK_IS_X11_WINDOW (window)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(window)); GType __t = ((gdk_x11_window_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
) {
3025 panel_struts_set_window_hint (toplevel);
3026 gdk_window_set_geometry_hints (window, NULL((void*)0), 0);
3027 }
3028#endif /* HAVE_X11 */
3029
3030 gdk_window_set_group (window, window);
3031 panel_toplevel_initially_hide (toplevel);
3032
3033 panel_toplevel_move_resize_window (toplevel, TRUE(!(0)), TRUE(!(0)));
3034}
3035
3036static void
3037panel_toplevel_disconnect_timeouts (PanelToplevel *toplevel)
3038{
3039 if (toplevel->priv->hide_timeout)
3040 g_source_remove (toplevel->priv->hide_timeout);
3041 toplevel->priv->hide_timeout = 0;
3042
3043 if (toplevel->priv->unhide_timeout)
3044 g_source_remove (toplevel->priv->unhide_timeout);
3045 toplevel->priv->unhide_timeout = 0;
3046
3047 if (toplevel->priv->animation_timeout)
3048 g_source_remove (toplevel->priv->animation_timeout);
3049 toplevel->priv->animation_timeout = 0;
3050}
3051
3052static void
3053panel_toplevel_unrealize (GtkWidget *widget)
3054{
3055 PanelToplevel *toplevel;
3056 toplevel = PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
;
3057 panel_toplevel_disconnect_timeouts (toplevel);
3058 panel_background_unrealized (&toplevel->background);
3059 GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->unrealize (widget);
3060}
3061
3062static void
3063panel_toplevel_dispose (GObject *widget)
3064{
3065 PanelToplevel *toplevel = (PanelToplevel *) widget;
3066
3067 g_clear_pointer (&toplevel->priv->settings_path, g_free)do { _Static_assert (sizeof *(&toplevel->priv->settings_path
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
((&toplevel->priv->settings_path)) _pp = (&toplevel
->priv->settings_path); __typeof__ (*(&toplevel->
priv->settings_path)) _ptr = *_pp; *_pp = ((void*)0); if (
_ptr) (g_free) (_ptr); } while (0)
;
3068
3069 if (toplevel->settings) {
3070 g_signal_handlers_disconnect_by_data (toplevel->settings, toplevel)g_signal_handlers_disconnect_matched ((toplevel->settings)
, G_SIGNAL_MATCH_DATA, 0, 0, ((void*)0), ((void*)0), (toplevel
))
;
3071 g_clear_object (&toplevel->settings)do { _Static_assert (sizeof *((&toplevel->settings)) ==
sizeof (gpointer), "Expression evaluates to false"); __typeof__
(((&toplevel->settings))) _pp = ((&toplevel->settings
)); __typeof__ (*((&toplevel->settings))) _ptr = *_pp;
*_pp = ((void*)0); if (_ptr) (g_object_unref) (_ptr); } while
(0)
;
3072 }
3073
3074 g_clear_object (&toplevel->queued_settings)do { _Static_assert (sizeof *((&toplevel->queued_settings
)) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(((&toplevel->queued_settings))) _pp = ((&toplevel
->queued_settings)); __typeof__ (*((&toplevel->queued_settings
))) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (g_object_unref
) (_ptr); } while (0)
;
3075
3076 if (toplevel->background_settings) {
3077 g_signal_handlers_disconnect_by_data (toplevel->background_settings, toplevel)g_signal_handlers_disconnect_matched ((toplevel->background_settings
), G_SIGNAL_MATCH_DATA, 0, 0, ((void*)0), ((void*)0), (toplevel
))
;
3078 g_clear_object (&toplevel->background_settings)do { _Static_assert (sizeof *((&toplevel->background_settings
)) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(((&toplevel->background_settings))) _pp = ((&toplevel
->background_settings)); __typeof__ (*((&toplevel->
background_settings))) _ptr = *_pp; *_pp = ((void*)0); if (_ptr
) (g_object_unref) (_ptr); } while (0)
;
3079 }
3080
3081 if (toplevel->priv->gtk_settings) {
3082 g_signal_handlers_disconnect_by_func (toplevel->priv->gtk_settings,g_signal_handlers_disconnect_matched ((toplevel->priv->
gtk_settings), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (panel_toplevel_drag_threshold_changed
))), (toplevel))
3083 G_CALLBACK (panel_toplevel_drag_threshold_changed),g_signal_handlers_disconnect_matched ((toplevel->priv->
gtk_settings), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (panel_toplevel_drag_threshold_changed
))), (toplevel))
3084 toplevel)g_signal_handlers_disconnect_matched ((toplevel->priv->
gtk_settings), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (panel_toplevel_drag_threshold_changed
))), (toplevel))
;
3085 toplevel->priv->gtk_settings = NULL((void*)0);
3086
3087 panel_background_free (&toplevel->background);
3088 }
3089
3090 if (toplevel->priv->attached) {
3091 panel_toplevel_disconnect_attached (toplevel);
3092 toplevel->priv->attached = FALSE(0);
3093
3094 toplevel->priv->attach_toplevel = NULL((void*)0);
3095 toplevel->priv->attach_widget = NULL((void*)0);
3096 }
3097
3098 g_clear_pointer (&toplevel->priv->description, g_free)do { _Static_assert (sizeof *(&toplevel->priv->description
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
((&toplevel->priv->description)) _pp = (&toplevel
->priv->description); __typeof__ (*(&toplevel->priv
->description)) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (
g_free) (_ptr); } while (0)
;
3099 g_clear_pointer (&toplevel->priv->name, g_free)do { _Static_assert (sizeof *(&toplevel->priv->name
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
((&toplevel->priv->name)) _pp = (&toplevel->
priv->name); __typeof__ (*(&toplevel->priv->name
)) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (g_free) (_ptr);
} while (0)
;
3100
3101 panel_toplevel_disconnect_timeouts (toplevel);
3102
3103 G_OBJECT_CLASS (panel_toplevel_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), (((GType) ((20) << (
2))))))))
->dispose (widget);
3104}
3105
3106static void
3107panel_toplevel_check_resize (GtkContainer *container)
3108{
3109 GtkAllocation allocation;
3110 GtkRequisition requisition;
3111 GtkWidget *widget;
3112
3113 widget = GTK_WIDGET (container)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((container)), ((gtk_widget_get_type ()))))))
;
3114
3115 if (!gtk_widget_get_visible (widget))
3116 return;
3117
3118 requisition.width = -1;
3119 requisition.height = -1;
3120
3121 gtk_widget_get_preferred_size (widget, &requisition, NULL((void*)0));
3122 gtk_widget_get_allocation (widget, &allocation);
3123
3124 allocation.width = requisition.width;
3125 allocation.height = requisition.height;
3126
3127 gtk_widget_size_allocate (widget, &allocation);
3128}
3129
3130static void
3131panel_toplevel_size_request (GtkWidget *widget,
3132 GtkRequisition *requisition)
3133{
3134 PanelToplevel *toplevel;
3135 GtkBin *bin;
3136 GtkWidget *child;
3137 GdkRectangle old_geometry;
3138 int position_changed = FALSE(0);
3139 int size_changed = FALSE(0);
3140
3141 toplevel = PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
;
3142 bin = GTK_BIN (widget)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_bin_get_type ()))))))
;
3143
3144 /* we get a size request when there are new monitors, so first try to
3145 * see if we need to move to a new monitor */
3146 panel_toplevel_update_monitor (toplevel);
3147
3148 child = gtk_bin_get_child (bin);
3149 if (child && gtk_widget_get_visible (child))
3150 gtk_widget_get_preferred_size (child, requisition, NULL((void*)0));
3151
3152 old_geometry = toplevel->priv->geometry;
3153
3154 panel_toplevel_update_geometry (toplevel, requisition);
3155
3156 requisition->width = toplevel->priv->geometry.width;
3157 requisition->height = toplevel->priv->geometry.height;
3158
3159 if (!gtk_widget_get_realized (widget))
3160 return;
3161
3162 if (old_geometry.width != toplevel->priv->geometry.width ||
3163 old_geometry.height != toplevel->priv->geometry.height)
3164 size_changed = TRUE(!(0));
3165
3166 if (old_geometry.x != toplevel->priv->geometry.x ||
3167 old_geometry.y != toplevel->priv->geometry.y)
3168 position_changed = TRUE(!(0));
3169
3170 panel_toplevel_move_resize_window (toplevel, position_changed, size_changed);
3171}
3172
3173static void
3174panel_toplevel_get_preferred_width (GtkWidget *widget,
3175 gint *minimum_width,
3176 gint *natural_width)
3177{
3178 GtkRequisition req;
3179 panel_toplevel_size_request (widget, &req);
3180 *minimum_width = *natural_width = req.width;
3181}
3182
3183static void
3184panel_toplevel_get_preferred_height (GtkWidget *widget,
3185 gint *minimum_height,
3186 gint *natural_height)
3187{
3188 GtkRequisition req;
3189 panel_toplevel_size_request (widget, &req);
3190 *minimum_height = *natural_height = req.height;
3191}
3192
3193static void
3194set_background_region (PanelToplevel *toplevel)
3195{
3196 GtkWidget *widget;
3197 GdkWindow *window;
3198 gint origin_x;
3199 gint origin_y;
3200 GtkAllocation allocation;
3201 GtkOrientation orientation;
3202
3203 widget = GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
;
3204
3205 if (!gtk_widget_get_realized (widget))
3206 return;
3207
3208 window = gtk_widget_get_window (widget);
3209 origin_x = -1;
3210 origin_y = -1;
3211
3212 gdk_window_get_origin (window, &origin_x, &origin_y);
3213 gtk_widget_get_allocation (widget, &allocation);
3214
3215 orientation = GTK_ORIENTATION_HORIZONTAL;
3216 if (toplevel->priv->orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT))
3217 orientation = GTK_ORIENTATION_VERTICAL;
3218
3219 panel_background_change_region (&toplevel->background, orientation,
3220 origin_x, origin_y,
3221 allocation.width, allocation.height);
3222}
3223
3224static void
3225panel_toplevel_size_allocate (GtkWidget *widget,
3226 GtkAllocation *allocation)
3227{
3228 PanelToplevel *toplevel = (PanelToplevel *) widget;
3229 GtkBin *bin = (GtkBin *) widget;
3230 GtkStyleContext *context;
3231 GtkStateFlags state;
3232 GtkBorder padding;
3233 GtkWidget *child;
3234 GtkAllocation challoc;
3235 GtkAllocation child_allocation;
3236
3237 gtk_widget_set_allocation (widget, allocation);
3238
3239 if (toplevel->priv->expand ||
3240 toplevel->priv->buttons_enabled ||
3241 toplevel->priv->attached)
3242 challoc = *allocation;
3243 else {
3244 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)) {
3245 challoc.x = HANDLE_SIZE10;
3246 challoc.y = 0;
3247 challoc.width = allocation->width - 2 * HANDLE_SIZE10;
3248 challoc.height = allocation->height;
3249 } else {
3250 challoc.x = 0;
3251 challoc.y = HANDLE_SIZE10;
3252 challoc.width = allocation->width;
3253 challoc.height = allocation->height - 2 * HANDLE_SIZE10;
3254 }
3255 }
3256
3257 state = gtk_widget_get_state_flags (widget);
3258 context = gtk_widget_get_style_context (widget);
3259 gtk_style_context_get_padding (context, state, &padding);
3260
3261 if (toplevel->priv->edges & PANEL_EDGE_TOP) {
3262 challoc.y += padding.top;
3263 challoc.height -= padding.top;
3264 }
3265
3266 if (toplevel->priv->edges & PANEL_EDGE_LEFT) {
3267 challoc.x += padding.left;
3268 challoc.width -= padding.left;
3269 }
3270
3271 if (toplevel->priv->edges & PANEL_EDGE_BOTTOM)
3272 challoc.height -= padding.bottom;
3273
3274 if (toplevel->priv->edges & PANEL_EDGE_RIGHT)
3275 challoc.width -= padding.right;
3276
3277 challoc.width = MAX (1, challoc.width)(((1) > (challoc.width)) ? (1) : (challoc.width));
3278 challoc.height = MAX (1, challoc.height)(((1) > (challoc.height)) ? (1) : (challoc.height));
3279
3280 child = gtk_bin_get_child (bin);
3281 gtk_widget_get_allocation (child, &child_allocation);
3282
3283 if (gtk_widget_get_mapped (widget) &&
3284 (challoc.x != child_allocation.x ||
3285 challoc.y != child_allocation.y ||
3286 challoc.width != child_allocation.width ||
3287 challoc.height != child_allocation.height)) {
3288 GtkAllocation allocation_to_invalidate;
3289
3290 gtk_widget_get_allocation (widget, &allocation_to_invalidate);
3291 gdk_window_invalidate_rect (gtk_widget_get_window (widget),
3292 &allocation_to_invalidate, FALSE(0));
3293 }
3294
3295 if (child && gtk_widget_get_visible (child))
3296 gtk_widget_size_allocate (child, &challoc);
3297
3298 set_background_region (toplevel);
3299}
3300
3301static gboolean panel_toplevel_draw(GtkWidget* widget, cairo_t* cr)
3302{
3303 PanelToplevel* toplevel = (PanelToplevel*) widget;
3304 PanelFrameEdge edges;
3305 gboolean retval = FALSE(0);
3306 int awidth;
3307 int aheight;
3308 GtkStyleContext *context;
3309 GtkStateFlags state;
3310 GtkBorder padding;
3311
3312 if (!gtk_widget_is_drawable (widget))
3313 return retval;
3314
3315 if (GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->draw)
3316 retval = GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->draw (widget, cr);
3317
3318 edges = toplevel->priv->edges;
3319 panel_frame_draw (widget, cr, edges);
3320
3321 if (toplevel->priv->expand ||
3322 toplevel->priv->buttons_enabled ||
3323 toplevel->priv->attached)
3324 return retval;
3325
3326 state = gtk_widget_get_state_flags (widget);
3327 awidth = gtk_widget_get_allocated_width (widget);
3328 aheight = gtk_widget_get_allocated_height (widget);
3329
3330 context = gtk_widget_get_style_context (widget);
3331 gtk_style_context_get_padding (context, state, &padding);
3332
3333 gtk_style_context_save (context);
3334 gtk_style_context_set_state (context, state);
3335
3336 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)) {
3337 int x, y, width, height;
3338
3339 x = 0;
3340 y = 0;
3341 height = aheight;
3342 width = HANDLE_SIZE10;
3343
3344 if (edges & PANEL_EDGE_TOP) {
3345 y += padding.top;
3346 height -= padding.top;
3347 }
3348 if (edges & PANEL_EDGE_BOTTOM)
3349 height -= padding.bottom;
3350 if (edges & PANEL_EDGE_LEFT)
3351 x += padding.left;
3352
3353 cairo_save (cr);
3354 gtk_render_handle (context, cr, x, y, width, height);
3355 cairo_restore (cr);
3356
3357 x = awidth - HANDLE_SIZE10;
3358 if (edges & PANEL_EDGE_RIGHT)
3359 x -= padding.right;
3360
3361 cairo_save (cr);
3362 gtk_render_handle (context, cr, x, y, width, height);
3363 cairo_restore (cr);
3364 } else {
3365 int x, y, width, height;
3366
3367 x = 0;
3368 y = 0;
3369 width = awidth;
3370 height = HANDLE_SIZE10;
3371
3372 if (edges & PANEL_EDGE_LEFT) {
3373 x += padding.left;
3374 width -= padding.left;
3375 }
3376 if (edges & PANEL_EDGE_RIGHT)
3377 width -= padding.right;
3378 if (edges & PANEL_EDGE_TOP)
3379 y += padding.top;
3380
3381 cairo_save (cr);
3382 gtk_render_handle (context, cr, x, y, width, height);
3383 cairo_restore (cr);
3384
3385 y = aheight - HANDLE_SIZE10;
3386 if (edges & PANEL_EDGE_BOTTOM)
3387 y -= padding.bottom;
3388
3389 cairo_save (cr);
3390 gtk_render_handle (context, cr, x, y, width, height);
3391 cairo_restore (cr);
3392 }
3393
3394 gtk_style_context_restore (context);
3395
3396 return retval;
3397}
3398
3399static gboolean
3400panel_toplevel_button_press_event (GtkWidget *widget,
3401 GdkEventButton *event)
3402{
3403 PanelToplevel *toplevel;
3404 GtkWidget *event_widget;
3405
3406 g_return_val_if_fail (PANEL_IS_TOPLEVEL (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (widget)"); return ((0)); }
} while (0)
;
3407
3408 toplevel = PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
;
3409
3410 if (event->button != 1 && event->button != 2)
3411 return FALSE(0);
3412
3413 if (toplevel->priv->animating)
3414 return FALSE(0);
3415
3416 /* Get the mouse-button modifier from marco so that only intentional
3417 * moves are considered. We don't this for non-expanded panels since we
3418 * only have the handles that the user can grab. */
3419 if ((toplevel->priv->expand || toplevel->priv->attached) &&
3420 (event->state & GDK_MODIFIER_MASK) != panel_bindings_get_mouse_button_modifier_keymask ())
3421 return FALSE(0);
3422
3423 gdk_window_get_user_data (event->window, (gpointer)&event_widget);
3424 g_assert (GTK_IS_WIDGET (event_widget))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((event_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_assertion_message_expr (((gchar*) 0), "panel-toplevel.c", 3424
, ((const char*) (__func__)), "GTK_IS_WIDGET (event_widget)")
; } while (0)
;
3425 gtk_widget_translate_coordinates (event_widget,
3426 widget,
3427 event->x,
3428 event->y,
3429 &toplevel->priv->drag_offset_x,
3430 &toplevel->priv->drag_offset_y);
3431
3432 panel_toplevel_begin_grab_op (toplevel, PANEL_GRAB_OP_MOVE, FALSE(0), event->time);
3433
3434 return TRUE(!(0));
3435}
3436
3437static gboolean
3438panel_toplevel_button_release_event (GtkWidget *widget,
3439 GdkEventButton *event)
3440{
3441 PanelToplevel *toplevel;
3442
3443 if (event->button != 1 && event->button != 2)
3444 return FALSE(0);
3445
3446 toplevel = PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
;
3447
3448 if (toplevel->priv->grab_op == PANEL_GRAB_OP_NONE)
3449 return FALSE(0);
3450
3451 if (toplevel->priv->grab_is_keyboard)
3452 return FALSE(0);
3453
3454 panel_toplevel_end_grab_op (toplevel, event->time);
3455
3456 return TRUE(!(0));
3457}
3458
3459static gboolean
3460panel_toplevel_configure_event (GtkWidget *widget,
3461 GdkEventConfigure *event)
3462{
3463 PanelToplevel *toplevel;
3464
3465 toplevel = PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
;
3466
3467 set_background_region (toplevel);
3468
3469 return TRUE(!(0));
3470}
3471
3472static gboolean
3473panel_toplevel_key_press_event (GtkWidget *widget,
3474 GdkEventKey *event)
3475{
3476 PanelToplevel *toplevel = (PanelToplevel *) widget;
3477
3478 if (toplevel->priv->grab_op != PANEL_GRAB_OP_NONE &&
3479 panel_toplevel_handle_grab_op_key_event (toplevel, event))
3480 return TRUE(!(0));
3481
3482 if (GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->key_press_event)
3483 return GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->key_press_event (widget, event);
3484
3485 return FALSE(0);
3486}
3487
3488static void
3489panel_toplevel_state_flags_changed (GtkWidget *widget,
3490 GtkStateFlags previous_state)
3491{
3492 GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->state_flags_changed (widget,
3493 previous_state);
3494
3495 set_background_default_style (widget);
3496}
3497
3498static gboolean
3499panel_toplevel_motion_notify_event (GtkWidget *widget,
3500 GdkEventMotion *event)
3501{
3502 if (gdk_event_get_screen ((GdkEvent *)event) ==
3503 gtk_window_get_screen (GTK_WINDOW (widget)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_window_get_type ()))))))
))
3504 return panel_toplevel_handle_grab_op_motion_event (
3505 PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
, event);
3506 else
3507 return FALSE(0);
3508}
3509
3510static gboolean
3511panel_toplevel_animation_timeout (PanelToplevel *toplevel)
3512{
3513 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
3514
3515 if (!toplevel->priv->animating) {
3516 toplevel->priv->animation_end_x = 0xdead;
3517 toplevel->priv->animation_end_y = 0xdead;
3518 toplevel->priv->animation_end_width = 0xdead;
3519 toplevel->priv->animation_end_height = 0xdead;
3520 toplevel->priv->animation_start_time = 0xdead;
3521 toplevel->priv->animation_duration_time = 0xdead;
3522 toplevel->priv->animation_timeout = 0;
3523 toplevel->priv->initial_animation_done = TRUE(!(0));
3524 }
3525
3526 return toplevel->priv->animating;
3527}
3528
3529static GTimeSpan
3530panel_toplevel_get_animation_time (PanelToplevel *toplevel)
3531{
3532 /* The number of seconds to complete the animation.
3533 */
3534#define ANIMATION_TIME_FAST 400
3535#define ANIMATION_TIME_MEDIUM 1200
3536#define ANIMATION_TIME_SLOW 2000
3537
3538 GTimeSpan t;
3539
3540 switch (toplevel->priv->animation_speed) {
3541 case PANEL_ANIMATION_SLOW:
3542 t = ANIMATION_TIME_SLOW * G_TIME_SPAN_MILLISECOND((1000L));
3543 break;
3544 case PANEL_ANIMATION_MEDIUM:
3545 t = ANIMATION_TIME_MEDIUM * G_TIME_SPAN_MILLISECOND((1000L));
3546 break;
3547 case PANEL_ANIMATION_FAST:
3548 t = ANIMATION_TIME_FAST * G_TIME_SPAN_MILLISECOND((1000L));
3549 break;
3550 default:
3551 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 3551, ((const char*) (__func__)), ((void*)0)); } while (0)
;
3552 break;
3553 }
3554
3555 return t;
3556
3557#undef ANIMATION_TIME_FAST
3558#undef ANIMATION_TIME_MEDIUM
3559#undef ANIMATION_TIME_SLOW
3560}
3561
3562static void
3563panel_toplevel_calculate_animation_end_geometry (PanelToplevel *toplevel)
3564{
3565 GdkRectangle monitor_geom;
3566
3567 toplevel->priv->animation_end_x = toplevel->priv->x;
3568 toplevel->priv->animation_end_y = toplevel->priv->y;
3569 toplevel->priv->animation_end_width = -1;
3570 toplevel->priv->animation_end_height = -1;
3571
3572 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
3573
3574 if (!toplevel->priv->expand) {
3575
3576 if (toplevel->priv->x_centered)
3577 toplevel->priv->animation_end_x =
3578 (monitor_geom.width - toplevel->priv->geometry.width) / 2;
3579 if (toplevel->priv->y_centered)
3580 toplevel->priv->animation_end_y =
3581 (monitor_geom.height - toplevel->priv->geometry.height) / 2;
3582 }
3583
3584 /* we consider the toplevels which are in the initial animation stage
3585 * as in a normal state */
3586 if (toplevel->priv->state == PANEL_STATE_NORMAL ||
3587 (!toplevel->priv->initial_animation_done &&
3588 !toplevel->priv->auto_hide))
3589 panel_toplevel_update_normal_position (toplevel,
3590 &toplevel->priv->animation_end_x,
3591 &toplevel->priv->animation_end_y,
3592 &toplevel->priv->animation_end_width,
3593 &toplevel->priv->animation_end_height);
3594
3595 else if (toplevel->priv->state == PANEL_STATE_AUTO_HIDDEN)
3596 panel_toplevel_update_auto_hide_position (toplevel,
3597 &toplevel->priv->animation_end_x,
3598 &toplevel->priv->animation_end_y,
3599 &toplevel->priv->animation_end_width,
3600 &toplevel->priv->animation_end_height,
3601 TRUE(!(0)));
3602 else
3603 panel_toplevel_update_hidden_position (toplevel,
3604 &toplevel->priv->animation_end_x,
3605 &toplevel->priv->animation_end_y,
3606 &toplevel->priv->animation_end_width,
3607 &toplevel->priv->animation_end_height);
3608}
3609
3610static void
3611panel_toplevel_start_animation (PanelToplevel *toplevel)
3612{
3613 GtkRequisition requisition;
3614 int deltax, deltay, deltaw = 0, deltah = 0;
3615 int cur_x = -1, cur_y = -1;
3616
3617 panel_toplevel_calculate_animation_end_geometry (toplevel);
3618
3619 toplevel->priv->animating = TRUE(!(0));
3620
3621 panel_toplevel_update_struts (toplevel, TRUE(!(0)));
3622#ifdef HAVE_X111
3623 if (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel)))(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gtk_widget_get_display (((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((toplevel)), ((gtk_widget_get_type ()))))
))))); GType __t = ((gdk_x11_display_get_type())); gboolean __r
; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
) {
3624 panel_struts_update_toplevel_geometry (toplevel,
3625 &toplevel->priv->animation_end_x,
3626 &toplevel->priv->animation_end_y,
3627 &toplevel->priv->animation_end_width,
3628 &toplevel->priv->animation_end_height);
3629 }
3630#endif /* HAVE_X11 */
3631 panel_toplevel_update_struts (toplevel, FALSE(0));
3632
3633 gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
), &cur_x, &cur_y);
3634
3635 cur_x -= panel_multimonitor_x (toplevel->priv->monitor);
3636 cur_y -= panel_multimonitor_y (toplevel->priv->monitor);
3637
3638 deltax = toplevel->priv->animation_end_x - cur_x;
3639 deltay = toplevel->priv->animation_end_y - cur_y;
3640
3641 gtk_widget_get_preferred_size (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
, &requisition, NULL((void*)0));
3642
3643 if (toplevel->priv->animation_end_width != -1)
3644 deltaw = toplevel->priv->animation_end_width - requisition.width;
3645
3646 if (toplevel->priv->animation_end_height != -1)
3647 deltah = toplevel->priv->animation_end_height - requisition.height;
3648
3649 if (deltax == 0 && deltay == 0 && deltaw == 0 && deltah == 0) {
3650 toplevel->priv->animation_end_x = -1;
3651 toplevel->priv->animation_end_y = -1;
3652 toplevel->priv->animation_end_width = -1;
3653 toplevel->priv->animation_end_height = -1;
3654 toplevel->priv->animating = FALSE(0);
3655 return;
3656 }
3657
3658 if (toplevel->priv->attached) {
3659 /* Re-map unmapped attached toplevels */
3660 if (!gtk_widget_get_visible (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
))
3661 gtk_widget_set_visible (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
, TRUE(!(0)));
3662
3663 if (!gtk_widget_get_mapped (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
))
3664 gtk_widget_map (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
3665
3666 gtk_window_present (GTK_WINDOW (toplevel->priv->attach_toplevel)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->attach_toplevel)), ((gtk_window_get_type
()))))))
);
3667 }
3668
3669 toplevel->priv->animation_start_time = g_get_monotonic_time ();
3670 toplevel->priv->animation_duration_time = panel_toplevel_get_animation_time (toplevel);
3671
3672 if (!toplevel->priv->animation_timeout)
3673 toplevel->priv->animation_timeout =
3674 g_timeout_add (20, (GSourceFunc) panel_toplevel_animation_timeout, toplevel);
3675}
3676
3677void
3678panel_toplevel_hide (PanelToplevel *toplevel,
3679 gboolean auto_hide,
3680 gint direction)
3681{
3682 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
3683
3684 if (toplevel->priv->state != PANEL_STATE_NORMAL)
3685 return;
3686
3687 g_signal_emit (toplevel, toplevel_signals [HIDE_SIGNAL], 0);
3688
3689 if (toplevel->priv->attach_toplevel)
3690 panel_toplevel_pop_autohide_disabler (toplevel->priv->attach_toplevel);
3691
3692 if (auto_hide)
3693 toplevel->priv->state = PANEL_STATE_AUTO_HIDDEN;
3694 else {
3695 GtkDirectionType hide_direction;
3696
3697 if (direction == -1) {
3698 if (toplevel->priv->orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT))
3699 hide_direction = GTK_DIR_UP;
3700 else
3701 hide_direction = GTK_DIR_LEFT;
3702 } else {
3703 hide_direction = (GtkDirectionType) direction;
3704 }
3705
3706 switch (hide_direction) {
3707 case GTK_DIR_UP:
3708 g_return_if_fail (toplevel->priv->orientation & PANEL_VERTICAL_MASK)do { if ((toplevel->priv->orientation & (PANEL_ORIENTATION_LEFT
| PANEL_ORIENTATION_RIGHT))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "toplevel->priv->orientation & PANEL_VERTICAL_MASK"
); return; } } while (0)
;
3709 toplevel->priv->state = PANEL_STATE_HIDDEN_UP;
3710 break;
3711 case GTK_DIR_DOWN:
3712 g_return_if_fail (toplevel->priv->orientation & PANEL_VERTICAL_MASK)do { if ((toplevel->priv->orientation & (PANEL_ORIENTATION_LEFT
| PANEL_ORIENTATION_RIGHT))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "toplevel->priv->orientation & PANEL_VERTICAL_MASK"
); return; } } while (0)
;
3713 toplevel->priv->state = PANEL_STATE_HIDDEN_DOWN;
3714 break;
3715 case GTK_DIR_LEFT:
3716 g_return_if_fail (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK)do { if ((toplevel->priv->orientation & (PANEL_ORIENTATION_TOP
| PANEL_ORIENTATION_BOTTOM))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "toplevel->priv->orientation & PANEL_HORIZONTAL_MASK"
); return; } } while (0)
;
3717 toplevel->priv->state = PANEL_STATE_HIDDEN_LEFT;
3718 break;
3719 case GTK_DIR_RIGHT:
3720 g_return_if_fail (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK)do { if ((toplevel->priv->orientation & (PANEL_ORIENTATION_TOP
| PANEL_ORIENTATION_BOTTOM))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "toplevel->priv->orientation & PANEL_HORIZONTAL_MASK"
); return; } } while (0)
;
3721 toplevel->priv->state = PANEL_STATE_HIDDEN_RIGHT;
3722 break;
3723 default:
3724 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 3724, ((const char*) (__func__)), ((void*)0)); } while (0)
;
3725 break;
3726 }
3727
3728 panel_toplevel_update_hide_buttons (toplevel);
3729 }
3730
3731 if (toplevel->priv->animate && gtk_widget_get_realized (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
)) {
3732 panel_toplevel_start_animation (toplevel);
3733 }
3734
3735 /* if the toplevel is attached (-> drawer), hide it after the animation
3736 * this hides the hide button properly as well */
3737 if (toplevel->priv->attached) {
3738 gtk_widget_hide (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
3739 }
3740
3741 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
3742}
3743
3744static gboolean
3745panel_toplevel_auto_hide_timeout_handler (PanelToplevel *toplevel)
3746{
3747 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return ((0));
} } while (0)
;
3748
3749 if (panel_toplevel_get_autohide_disabled (toplevel)) {
3750 toplevel->priv->hide_timeout = 0;
3751 return FALSE(0);
3752 }
3753
3754 /* keep coming back until the animation has finished.
3755 * FIXME: we should really remove the timeout/idle
3756 * completely and re-instate it when the
3757 * animation has finished.
3758 */
3759 if (toplevel->priv->animating)
3760 return TRUE(!(0));
3761
3762 panel_toplevel_hide (toplevel, TRUE(!(0)), -1);
3763
3764 toplevel->priv->hide_timeout = 0;
3765
3766 return FALSE(0);
3767}
3768
3769void
3770panel_toplevel_unhide (PanelToplevel *toplevel)
3771{
3772 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
3773
3774 if (toplevel->priv->state == PANEL_STATE_NORMAL)
3775 return;
3776
3777 toplevel->priv->state = PANEL_STATE_NORMAL;
3778
3779 panel_toplevel_update_hide_buttons (toplevel);
3780
3781 if (toplevel->priv->attach_toplevel)
3782 panel_toplevel_push_autohide_disabler (toplevel->priv->attach_toplevel);
3783
3784 if (toplevel->priv->animate && gtk_widget_get_realized (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
)) {
3785 panel_toplevel_start_animation (toplevel);
3786 }
3787
3788 /* if the toplevel is attached (-> drawer), unhide it after the animation
3789 * (same as for hide) */
3790 if (toplevel->priv->attached) {
3791 gtk_widget_show (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
3792 }
3793
3794 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
3795
3796 if (!toplevel->priv->animate)
3797 g_signal_emit (toplevel, toplevel_signals [UNHIDE_SIGNAL], 0);
3798}
3799
3800static gboolean
3801panel_toplevel_auto_unhide_timeout_handler (PanelToplevel *toplevel)
3802{
3803 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return ((0));
} } while (0)
;
3804
3805 /* keep coming back until the animation has finished.
3806 * FIXME: we should really remove the timeout/idle
3807 * completely and re-instate it when the
3808 * animation has finished.
3809 */
3810 if (toplevel->priv->animating)
3811 return TRUE(!(0));
3812
3813 if (!toplevel->priv->animate)
3814 toplevel->priv->initial_animation_done = TRUE(!(0));
3815
3816 /* initial animation for auto-hidden panels: we need to unhide and hide
3817 * again to get at the right size */
3818 if (!toplevel->priv->initial_animation_done &&
3819 toplevel->priv->auto_hide) {
3820 toplevel->priv->unhide_timeout = 0;
3821 panel_toplevel_unhide (toplevel);
3822 panel_toplevel_hide (toplevel, TRUE(!(0)), -1);
3823 return FALSE(0);
3824 }
3825
3826 if (!panel_toplevel_contains_pointer (toplevel) &&
3827 toplevel->priv->auto_hide) {
3828 toplevel->priv->unhide_timeout = 0;
3829 return FALSE(0);
3830 }
3831
3832 panel_toplevel_unhide (toplevel);
3833
3834 toplevel->priv->unhide_timeout = 0;
3835
3836 return FALSE(0);
3837}
3838
3839void
3840panel_toplevel_queue_auto_hide (PanelToplevel *toplevel)
3841{
3842 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
3843
3844 if (!toplevel->priv->auto_hide ||
3845 panel_toplevel_contains_pointer (toplevel) ||
3846 panel_toplevel_get_autohide_disabled (toplevel))
3847 return;
3848
3849 if (toplevel->priv->unhide_timeout)
3850 g_source_remove (toplevel->priv->unhide_timeout);
3851 toplevel->priv->unhide_timeout = 0;
3852
3853 if (toplevel->priv->hide_timeout ||
3854 toplevel->priv->state != PANEL_STATE_NORMAL)
3855 return;
3856
3857 if (toplevel->priv->hide_delay > 0)
3858 toplevel->priv->hide_timeout =
3859 g_timeout_add (toplevel->priv->hide_delay,
3860 (GSourceFunc) panel_toplevel_auto_hide_timeout_handler,
3861 toplevel);
3862 else
3863 toplevel->priv->hide_timeout =
3864 g_idle_add ((GSourceFunc) panel_toplevel_auto_hide_timeout_handler,
3865 toplevel);
3866}
3867
3868void
3869panel_toplevel_queue_auto_unhide (PanelToplevel *toplevel)
3870{
3871 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
3872
3873 if (toplevel->priv->unhide_timeout)
3874 return;
3875
3876 if (toplevel->priv->hide_timeout)
3877 g_source_remove (toplevel->priv->hide_timeout);
3878 toplevel->priv->hide_timeout = 0;
3879
3880 if (toplevel->priv->state != PANEL_STATE_AUTO_HIDDEN)
3881 return;
3882
3883 if (toplevel->priv->unhide_delay > 0)
3884 toplevel->priv->unhide_timeout =
3885 g_timeout_add (toplevel->priv->unhide_delay,
3886 (GSourceFunc) panel_toplevel_auto_unhide_timeout_handler,
3887 toplevel);
3888 else
3889 toplevel->priv->unhide_timeout =
3890 g_idle_add ((GSourceFunc) panel_toplevel_auto_unhide_timeout_handler,
3891 toplevel);
3892}
3893
3894void
3895panel_toplevel_queue_initial_unhide (PanelToplevel *toplevel)
3896{
3897 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
3898
3899 if (toplevel->priv->initial_animation_done)
3900 return;
3901
3902 if (toplevel->priv->unhide_timeout)
3903 return;
3904
3905 toplevel->priv->unhide_timeout =
3906 g_idle_add ((GSourceFunc) panel_toplevel_auto_unhide_timeout_handler,
3907 toplevel);
3908}
3909
3910static gboolean
3911panel_toplevel_enter_notify_event (GtkWidget *widget,
3912 GdkEventCrossing *event)
3913{
3914 PanelToplevel *toplevel;
3915
3916 g_return_val_if_fail (PANEL_IS_TOPLEVEL (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (widget)"); return ((0)); }
} while (0)
;
3917
3918 toplevel = PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
;
3919
3920 if (toplevel->priv->auto_hide && event->detail != GDK_NOTIFY_INFERIOR)
3921 panel_toplevel_queue_auto_unhide (toplevel);
3922
3923 if (GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->enter_notify_event)
3924 return GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->enter_notify_event (widget, event);
3925
3926 return FALSE(0);
3927}
3928
3929static gboolean
3930panel_toplevel_leave_notify_event (GtkWidget *widget,
3931 GdkEventCrossing *event)
3932{
3933 PanelToplevel *toplevel;
3934
3935 g_return_val_if_fail (PANEL_IS_TOPLEVEL (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (widget)"); return ((0)); }
} while (0)
;
3936
3937 toplevel = PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
;
3938
3939 if (toplevel->priv->auto_hide && event->detail != GDK_NOTIFY_INFERIOR)
3940 panel_toplevel_queue_auto_hide (toplevel);
3941
3942 if (GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->leave_notify_event)
3943 return GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->leave_notify_event (widget, event);
3944
3945 return FALSE(0);
3946}
3947
3948static gboolean
3949panel_toplevel_focus_in_event (GtkWidget *widget,
3950 GdkEventFocus *event)
3951{
3952 PanelToplevel *toplevel = PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
;
3953
3954 if (toplevel->priv->state == PANEL_STATE_AUTO_HIDDEN)
3955 panel_toplevel_unhide (toplevel);
3956
3957 if (GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->focus_in_event)
3958 return GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->focus_in_event (widget, event);
3959
3960 return FALSE(0);
3961}
3962
3963static gboolean
3964panel_toplevel_focus_out_event (GtkWidget *widget,
3965 GdkEventFocus *event)
3966{
3967 PanelToplevel *toplevel = PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
;
3968
3969 /* It appears that sometimes we don't get a leave notify event,
3970 but just a focus in/out, so queue the autohide in that case.
3971 If the pointer is inside the panel then obviously we won't hide */
3972 if (toplevel->priv->auto_hide)
3973 panel_toplevel_queue_auto_hide (toplevel);
3974
3975 if (GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->focus_out_event)
3976 return GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->focus_out_event (widget, event);
3977
3978 return FALSE(0);
3979}
3980
3981static void
3982panel_toplevel_style_updated (GtkWidget *widget)
3983{
3984 panel_toplevel_update_hide_buttons (PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
);
3985
3986 if (GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->style_updated)
3987 GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->style_updated (widget);
3988
3989 set_background_default_style (widget);
3990}
3991
3992static void
3993panel_toplevel_drag_threshold_changed (PanelToplevel *toplevel)
3994{
3995 int threshold;
3996
3997 threshold = 0;
3998 g_object_get (G_OBJECT (toplevel->priv->gtk_settings)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->gtk_settings)), (((GType) ((20) <<
(2))))))))
,
3999 "gtk-dnd-drag-threshold", &threshold,
4000 NULL((void*)0));
4001
4002 if (threshold)
4003 toplevel->priv->snap_tolerance = threshold * SNAP_TOLERANCE_FACTOR6;
4004}
4005
4006static void
4007panel_toplevel_update_gtk_settings (PanelToplevel *toplevel)
4008{
4009 if (toplevel->priv->gtk_settings)
4010 g_signal_handlers_disconnect_by_func (toplevel->priv->gtk_settings,g_signal_handlers_disconnect_matched ((toplevel->priv->
gtk_settings), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (panel_toplevel_drag_threshold_changed
))), (toplevel))
4011 G_CALLBACK (panel_toplevel_drag_threshold_changed),g_signal_handlers_disconnect_matched ((toplevel->priv->
gtk_settings), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (panel_toplevel_drag_threshold_changed
))), (toplevel))
4012 toplevel)g_signal_handlers_disconnect_matched ((toplevel->priv->
gtk_settings), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (panel_toplevel_drag_threshold_changed
))), (toplevel))
;
4013
4014 toplevel->priv->gtk_settings = gtk_widget_get_settings (GTK_WIDGET (toplevel->priv->panel_widget)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->panel_widget)), ((gtk_widget_get_type
()))))))
);
4015
4016 g_signal_connect_swapped (toplevel->priv->gtk_settings, "notify::gtk-dnd-drag-threshold",g_signal_connect_data ((toplevel->priv->gtk_settings), (
"notify::gtk-dnd-drag-threshold"), (((GCallback) (panel_toplevel_drag_threshold_changed
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
4017 G_CALLBACK (panel_toplevel_drag_threshold_changed),g_signal_connect_data ((toplevel->priv->gtk_settings), (
"notify::gtk-dnd-drag-threshold"), (((GCallback) (panel_toplevel_drag_threshold_changed
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
4018 toplevel)g_signal_connect_data ((toplevel->priv->gtk_settings), (
"notify::gtk-dnd-drag-threshold"), (((GCallback) (panel_toplevel_drag_threshold_changed
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
;
4019
4020 panel_toplevel_drag_threshold_changed (toplevel);
4021}
4022
4023static void
4024panel_toplevel_screen_changed (GtkWidget *widget,
4025 GdkScreen *previous_screen)
4026{
4027 panel_toplevel_update_gtk_settings (PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
);
4028
4029 if (GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->screen_changed)
4030 GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->screen_changed (widget, previous_screen);
4031
4032 gtk_widget_queue_resize (widget);
4033}
4034
4035static void
4036panel_toplevel_set_property (GObject *object,
4037 guint prop_id,
4038 const GValue *value,
4039 GParamSpec *pspec)
4040{
4041 PanelToplevel *toplevel;
4042
4043 g_return_if_fail (PANEL_IS_TOPLEVEL (object))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((object)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (object)"); return; } } while
(0)
;
4044
4045 toplevel = PANEL_TOPLEVEL (object)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((panel_toplevel_get_type ()))))))
;
4046
4047 switch (prop_id) {
4048 case PROP_NAME:
4049 panel_toplevel_set_name (toplevel, g_value_get_string (value));
4050 break;
4051 case PROP_SETTINGS_PATH:
4052 panel_toplevel_set_settings_path (toplevel, g_value_get_string (value));
4053 break;
4054 case PROP_EXPAND:
4055 panel_toplevel_set_expand (toplevel, g_value_get_boolean (value));
4056 break;
4057 case PROP_ORIENTATION:
4058 panel_toplevel_set_orientation (toplevel, g_value_get_enum (value));
4059 break;
4060 case PROP_SIZE:
4061 panel_toplevel_set_size (toplevel, g_value_get_int (value));
4062 break;
4063 case PROP_X:
4064 panel_toplevel_set_x (toplevel,
4065 g_value_get_int (value),
4066 toplevel->priv->x_right,
4067 toplevel->priv->x_centered);
4068 break;
4069 case PROP_X_RIGHT:
4070 panel_toplevel_set_x (toplevel,
4071 toplevel->priv->x,
4072 g_value_get_int (value),
4073 toplevel->priv->x_centered);
4074 break;
4075 case PROP_X_CENTERED:
4076 panel_toplevel_set_x (toplevel,
4077 toplevel->priv->x,
4078 toplevel->priv->x_right,
4079 g_value_get_boolean (value));
4080 break;
4081 case PROP_Y:
4082 panel_toplevel_set_y (toplevel,
4083 g_value_get_int (value),
4084 toplevel->priv->y_bottom,
4085 toplevel->priv->y_centered);
4086 break;
4087 case PROP_Y_BOTTOM:
4088 panel_toplevel_set_y (toplevel,
4089 toplevel->priv->y,
4090 g_value_get_int (value),
4091 toplevel->priv->y_centered);
4092 break;
4093 case PROP_Y_CENTERED:
4094 panel_toplevel_set_y (toplevel,
4095 toplevel->priv->y,
4096 toplevel->priv->y_bottom,
4097 g_value_get_boolean (value));
4098 break;
4099 case PROP_MONITOR:
4100 panel_toplevel_set_monitor (toplevel, g_value_get_int (value));
4101 break;
4102 case PROP_AUTOHIDE:
4103 panel_toplevel_set_auto_hide (toplevel, g_value_get_boolean (value));
4104 break;
4105 case PROP_HIDE_DELAY:
4106 panel_toplevel_set_hide_delay (toplevel, g_value_get_int (value));
4107 break;
4108 case PROP_UNHIDE_DELAY:
4109 panel_toplevel_set_unhide_delay (toplevel, g_value_get_int (value));
4110 break;
4111 case PROP_AUTOHIDE_SIZE:
4112 panel_toplevel_set_auto_hide_size (toplevel, g_value_get_int (value));
4113 break;
4114 case PROP_ANIMATE:
4115 panel_toplevel_set_animate (toplevel, g_value_get_boolean (value));
4116 break;
4117 case PROP_ANIMATION_SPEED:
4118 panel_toplevel_set_animation_speed (toplevel, g_value_get_enum (value));
4119 break;
4120 case PROP_BUTTONS_ENABLED:
4121 panel_toplevel_set_enable_buttons (toplevel, g_value_get_boolean (value));
4122 break;
4123 case PROP_ARROWS_ENABLED:
4124 panel_toplevel_set_enable_arrows (toplevel, g_value_get_boolean (value));
4125 break;
4126 default:
4127 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "panel-toplevel.c", 4127, ("property"), _glib__property_id,
_glib__pspec->name, g_type_name ((((((GTypeClass*) (((GTypeInstance
*) (_glib__pspec))->g_class))->g_type)))), (g_type_name
((((((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
4128 break;
4129 }
4130}
4131
4132static void
4133panel_toplevel_get_property (GObject *object,
4134 guint prop_id,
4135 GValue *value,
4136 GParamSpec *pspec)
4137{
4138 PanelToplevel *toplevel;
4139
4140 g_return_if_fail (PANEL_IS_TOPLEVEL (object))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((object)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (object)"); return; } } while
(0)
;
4141
4142 toplevel = PANEL_TOPLEVEL (object)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((panel_toplevel_get_type ()))))))
;
4143
4144 switch (prop_id) {
4145 case PROP_NAME:
4146 g_value_set_string (value, panel_toplevel_get_name (toplevel));
4147 break;
4148 case PROP_SETTINGS_PATH:
4149 g_value_set_string (value, toplevel->priv->settings_path);
4150 break;
4151 case PROP_EXPAND:
4152 g_value_set_boolean (value, toplevel->priv->expand);
4153 break;
4154 case PROP_ORIENTATION:
4155 g_value_set_enum (value, toplevel->priv->orientation);
4156 break;
4157 case PROP_SIZE:
4158 g_value_set_int (value, toplevel->priv->size);
4159 break;
4160 case PROP_X:
4161 g_value_set_int (value, toplevel->priv->x);
4162 break;
4163 case PROP_X_RIGHT:
4164 g_value_set_int (value, toplevel->priv->x_right);
4165 break;
4166 case PROP_X_CENTERED:
4167 g_value_set_boolean (value, toplevel->priv->x_centered);
4168 break;
4169 case PROP_Y:
4170 g_value_set_int (value, toplevel->priv->y);
4171 break;
4172 case PROP_Y_BOTTOM:
4173 g_value_set_int (value, toplevel->priv->y_bottom);
4174 break;
4175 case PROP_Y_CENTERED:
4176 g_value_set_boolean (value, toplevel->priv->y_centered);
4177 break;
4178 case PROP_MONITOR:
4179 g_value_set_int (value, toplevel->priv->monitor);
4180 break;
4181 case PROP_AUTOHIDE:
4182 g_value_set_boolean (value, toplevel->priv->auto_hide);
4183 break;
4184 case PROP_HIDE_DELAY:
4185 g_value_set_int (value, toplevel->priv->hide_delay);
4186 break;
4187 case PROP_UNHIDE_DELAY:
4188 g_value_set_int (value, toplevel->priv->unhide_delay);
4189 break;
4190 case PROP_AUTOHIDE_SIZE:
4191 g_value_set_int (value, toplevel->priv->auto_hide_size);
4192 break;
4193 case PROP_ANIMATE:
4194 g_value_set_boolean (value, toplevel->priv->animate);
4195 break;
4196 case PROP_ANIMATION_SPEED:
4197 g_value_set_enum (value, toplevel->priv->animation_speed);
4198 break;
4199 case PROP_BUTTONS_ENABLED:
4200 g_value_set_boolean (value, toplevel->priv->buttons_enabled);
4201 break;
4202 case PROP_ARROWS_ENABLED:
4203 g_value_set_boolean (value, toplevel->priv->arrows_enabled);
4204 break;
4205 default:
4206 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "panel-toplevel.c", 4206, ("property"), _glib__property_id,
_glib__pspec->name, g_type_name ((((((GTypeClass*) (((GTypeInstance
*) (_glib__pspec))->g_class))->g_type)))), (g_type_name
((((((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
4207 break;
4208 }
4209}
4210
4211static GObject*
4212panel_toplevel_constructor (GType type,
4213 guint n_construct_properties,
4214 GObjectConstructParam *construct_properties)
4215{
4216 GObject *object;
4217
4218 object = G_OBJECT_CLASS (panel_toplevel_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), (((GType) ((20) << (
2))))))))
->constructor (type,
4219 n_construct_properties,
4220 construct_properties);
4221 PanelToplevel *toplevel = PANEL_TOPLEVEL(object)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((panel_toplevel_get_type ()))))))
;
4222 GdkScreen *screen = gtk_widget_get_screen(GTK_WIDGET(toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
4223 GdkVisual *visual = gdk_screen_get_rgba_visual(screen);
4224 gtk_widget_set_visual(GTK_WIDGET(toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
, visual);
4225
4226 return object;
4227}
4228
4229static void
4230panel_toplevel_finalize (GObject *object)
4231{
4232 PanelToplevel *toplevel = (PanelToplevel *) object;
4233
4234#ifdef HAVE_X111
4235 if (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel)))(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gtk_widget_get_display (((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((toplevel)), ((gtk_widget_get_type ()))))
))))); GType __t = ((gdk_x11_display_get_type())); gboolean __r
; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
)
4236 panel_struts_unregister_strut (toplevel);
4237#endif /* HAVE_X11 */
4238
4239 toplevel_list = g_slist_remove (toplevel_list, toplevel);
4240
4241 G_OBJECT_CLASS (panel_toplevel_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), (((GType) ((20) << (
2))))))))
->finalize (object);
4242}
4243
4244static void
4245panel_toplevel_class_init (PanelToplevelClass *klass)
4246{
4247 GObjectClass *gobject_class = (GObjectClass *) klass;
4248 GtkWidgetClass *widget_class = (GtkWidgetClass *) klass;
4249 GtkContainerClass *container_class = (GtkContainerClass *) klass;
4250 GtkBindingSet *binding_set;
4251
4252 binding_set = gtk_binding_set_by_class (klass);
4253
4254 gobject_class->constructor = panel_toplevel_constructor;
4255 gobject_class->set_property = panel_toplevel_set_property;
4256 gobject_class->get_property = panel_toplevel_get_property;
4257 gobject_class->finalize = panel_toplevel_finalize;
4258
4259 gobject_class->dispose = panel_toplevel_dispose;
4260
4261 widget_class->realize = panel_toplevel_realize;
4262 widget_class->unrealize = panel_toplevel_unrealize;
4263 widget_class->state_flags_changed = panel_toplevel_state_flags_changed;
4264 widget_class->draw = panel_toplevel_draw;
4265 widget_class->get_preferred_width = panel_toplevel_get_preferred_width;
4266 widget_class->get_preferred_height = panel_toplevel_get_preferred_height;
4267 widget_class->style_updated = panel_toplevel_style_updated;
4268 widget_class->size_allocate = panel_toplevel_size_allocate;
4269 widget_class->button_press_event = panel_toplevel_button_press_event;
4270 widget_class->button_release_event = panel_toplevel_button_release_event;
4271 widget_class->configure_event = panel_toplevel_configure_event;
4272 widget_class->key_press_event = panel_toplevel_key_press_event;
4273 widget_class->motion_notify_event = panel_toplevel_motion_notify_event;
4274 widget_class->enter_notify_event = panel_toplevel_enter_notify_event;
4275 widget_class->leave_notify_event = panel_toplevel_leave_notify_event;
4276 widget_class->screen_changed = panel_toplevel_screen_changed;
4277 widget_class->focus_in_event = panel_toplevel_focus_in_event;
4278 widget_class->focus_out_event = panel_toplevel_focus_out_event;
4279
4280 gtk_widget_class_set_css_name (widget_class, "PanelToplevel");
4281
4282 container_class->check_resize = panel_toplevel_check_resize;
4283
4284 klass->hiding = NULL((void*)0);
4285 klass->unhiding = NULL((void*)0);
4286 klass->popup_panel_menu = panel_toplevel_popup_panel_menu;
4287 klass->toggle_expand = panel_toplevel_toggle_expand;
4288 klass->expand = panel_toplevel_expand;
4289 klass->unexpand = panel_toplevel_unexpand;
4290 klass->toggle_hidden = panel_toplevel_toggle_hidden;
4291 klass->begin_move = panel_toplevel_begin_move;
4292 klass->begin_resize = panel_toplevel_begin_resize;
4293
4294 g_object_class_install_property (
4295 gobject_class,
4296 PROP_NAME,
4297 g_param_spec_string (
4298 "name",
4299 "Name",
4300 "The name of this panel",
4301 NULL((void*)0),
4302 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4303
4304 g_object_class_install_property (
4305 gobject_class,
4306 PROP_SETTINGS_PATH,
4307 g_param_spec_string (
4308 "settings-path",
4309 "GSettings path",
4310 "The GSettings path used for this panel",
4311 NULL((void*)0),
4312 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4313
4314 g_object_class_install_property (
4315 gobject_class,
4316 PROP_EXPAND,
4317 g_param_spec_boolean (
4318 "expand",
4319 "Expand",
4320 "Expand to take up the full monitor width/height",
4321 TRUE(!(0)),
4322 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4323
4324 g_object_class_install_property (
4325 gobject_class,
4326 PROP_ORIENTATION,
4327 g_param_spec_enum (
4328 "orientation",
4329 "Orientation",
4330 "The orientation of the panel",
4331 PANEL_TYPE_ORIENTATIONpanel_orientation_get_type(),
4332 PANEL_ORIENTATION_TOP,
4333 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4334
4335 g_object_class_install_property (
4336 gobject_class,
4337 PROP_SIZE,
4338 g_param_spec_int (
4339 "size",
4340 "Size",
4341 "The height (or width when vertical) of the panel",
4342 0,
4343 G_MAXINT2147483647,
4344 DEFAULT_SIZE48,
4345 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4346
4347 g_object_class_install_property (
4348 gobject_class,
4349 PROP_X,
4350 g_param_spec_int (
4351 "x",
4352 "X position",
4353 "The X position of the panel",
4354 0,
4355 G_MAXINT2147483647,
4356 0,
4357 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4358
4359 g_object_class_install_property (
4360 gobject_class,
4361 PROP_X_RIGHT,
4362 g_param_spec_int (
4363 "x-right",
4364 "X position, from the right",
4365 "The X position of the panel, starting from the right of the screen",
4366 -1,
4367 G_MAXINT2147483647,
4368 -1,
4369 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4370
4371 g_object_class_install_property (
4372 gobject_class,
4373 PROP_X_CENTERED,
4374 g_param_spec_boolean (
4375 "x-centered",
4376 "X centered",
4377 "The x co-ordinate is relative to center screen",
4378 FALSE(0),
4379 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4380
4381 g_object_class_install_property (
4382 gobject_class,
4383 PROP_Y,
4384 g_param_spec_int (
4385 "y",
4386 "Y position",
4387 "The Y position of the panel",
4388 0,
4389 G_MAXINT2147483647,
4390 0,
4391 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4392
4393 g_object_class_install_property (
4394 gobject_class,
4395 PROP_Y_BOTTOM,
4396 g_param_spec_int (
4397 "y_bottom",
4398 "Y position, from the bottom",
4399 "The Y position of the panel, starting from the bottom of the screen",
4400 -1,
4401 G_MAXINT2147483647,
4402 -1,
4403 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4404
4405 g_object_class_install_property (
4406 gobject_class,
4407 PROP_Y_CENTERED,
4408 g_param_spec_boolean (
4409 "y-centered",
4410 "Y centered",
4411 "The y co-ordinate is relative to center screen",
4412 FALSE(0),
4413 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4414
4415 g_object_class_install_property (
4416 gobject_class,
4417 PROP_MONITOR,
4418 g_param_spec_int (
4419 "monitor",
4420 "Xinerama monitor",
4421 "The monitor (in terms of Xinerama) which the panel is on",
4422 0,
4423 G_MAXINT2147483647,
4424 0,
4425 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4426
4427 g_object_class_install_property (
4428 gobject_class,
4429 PROP_AUTOHIDE,
4430 g_param_spec_boolean (
4431 "auto-hide",
4432 "Auto hide",
4433 "Automatically hide the panel when the mouse leaves the panel",
4434 FALSE(0),
4435 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4436
4437 g_object_class_install_property (
4438 gobject_class,
4439 PROP_HIDE_DELAY,
4440 g_param_spec_int (
4441 "hide-delay",
4442 "Hide delay",
4443 "The number of milliseconds to delay before automatically hiding",
4444 0,
4445 G_MAXINT2147483647,
4446 DEFAULT_HIDE_DELAY300,
4447 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4448
4449 g_object_class_install_property (
4450 gobject_class,
4451 PROP_UNHIDE_DELAY,
4452 g_param_spec_int (
4453 "unhide-delay",
4454 "Un-hide delay",
4455 "The number of milliseconds to delay before automatically un-hiding",
4456 0,
4457 G_MAXINT2147483647,
4458 DEFAULT_UNHIDE_DELAY100,
4459 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4460
4461 g_object_class_install_property (
4462 gobject_class,
4463 PROP_AUTOHIDE_SIZE,
4464 g_param_spec_int (
4465 "auto-hide-size",
4466 "Auto-hide size",
4467 "The number of pixels visible when the panel has been automatically hidden",
4468 1,
4469 G_MAXINT2147483647,
4470 DEFAULT_AUTO_HIDE_SIZE1,
4471 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4472
4473 g_object_class_install_property (
4474 gobject_class,
4475 PROP_ANIMATE,
4476 g_param_spec_boolean (
4477 "animate",
4478 "Animate",
4479 "Enable hiding/showing animations",
4480 TRUE(!(0)),
4481 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4482
4483 g_object_class_install_property (
4484 gobject_class,
4485 PROP_ANIMATION_SPEED,
4486 g_param_spec_enum (
4487 "animation-speed",
4488 "Animation Speed",
4489 "The speed at which to animate panel hiding/showing",
4490 PANEL_TYPE_ANIMATION_SPEEDpanel_animation_speed_get_type(),
4491 PANEL_ANIMATION_MEDIUM,
4492 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4493
4494 g_object_class_install_property (
4495 gobject_class,
4496 PROP_BUTTONS_ENABLED,
4497 g_param_spec_boolean (
4498 "buttons-enabled",
4499 "Buttons Enabled",
4500 "Enable hide/show buttons",
4501 TRUE(!(0)),
4502 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4503
4504 g_object_class_install_property (
4505 gobject_class,
4506 PROP_ARROWS_ENABLED,
4507 g_param_spec_boolean (
4508 "arrows-enabled",
4509 "Arrows Enabled",
4510 "Enable arrows on hide/show buttons",
4511 TRUE(!(0)),
4512 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4513
4514 gtk_widget_class_install_style_property (
4515 widget_class,
4516 g_param_spec_int (
4517 "arrow-size",
4518 "Arrow Size",
4519 "The size of the arrows on the hide/show buttons",
4520 0,
4521 G_MAXINT2147483647,
4522 DEFAULT_ARROW_SIZE20,
4523 G_PARAM_READABLE));
4524
4525 toplevel_signals [HIDE_SIGNAL] =
4526 g_signal_new ("hiding",
4527 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
4528 G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
4529 G_STRUCT_OFFSET (PanelToplevelClass, hiding)((glong) __builtin_offsetof(PanelToplevelClass, hiding)),
4530 NULL((void*)0),
4531 NULL((void*)0),
4532 g_cclosure_marshal_VOID__VOID,
4533 G_TYPE_NONE((GType) ((1) << (2))),
4534 0);
4535
4536 toplevel_signals [UNHIDE_SIGNAL] =
4537 g_signal_new ("unhiding",
4538 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
4539 G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
4540 G_STRUCT_OFFSET (PanelToplevelClass, unhiding)((glong) __builtin_offsetof(PanelToplevelClass, unhiding)),
4541 NULL((void*)0),
4542 NULL((void*)0),
4543 g_cclosure_marshal_VOID__VOID,
4544 G_TYPE_NONE((GType) ((1) << (2))),
4545 0);
4546
4547 toplevel_signals [POPUP_PANEL_MENU_SIGNAL] =
4548 g_signal_new ("popup-panel-menu",
4549 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
4550 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
4551 G_STRUCT_OFFSET (PanelToplevelClass, popup_panel_menu)((glong) __builtin_offsetof(PanelToplevelClass, popup_panel_menu
))
,
4552 NULL((void*)0),
4553 NULL((void*)0),
4554 panel_marshal_BOOLEAN__VOID,
4555 G_TYPE_BOOLEAN((GType) ((5) << (2))),
4556 0);
4557
4558 toplevel_signals [TOGGLE_EXPAND_SIGNAL] =
4559 g_signal_new ("toggle-expand",
4560 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
4561 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
4562 G_STRUCT_OFFSET (PanelToplevelClass, toggle_expand)((glong) __builtin_offsetof(PanelToplevelClass, toggle_expand
))
,
4563 NULL((void*)0),
4564 NULL((void*)0),
4565 panel_marshal_BOOLEAN__VOID,
4566 G_TYPE_BOOLEAN((GType) ((5) << (2))),
4567 0);
4568
4569 toplevel_signals [EXPAND_SIGNAL] =
4570 g_signal_new ("expand",
4571 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
4572 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
4573 G_STRUCT_OFFSET (PanelToplevelClass, expand)((glong) __builtin_offsetof(PanelToplevelClass, expand)),
4574 NULL((void*)0),
4575 NULL((void*)0),
4576 panel_marshal_BOOLEAN__VOID,
4577 G_TYPE_BOOLEAN((GType) ((5) << (2))),
4578 0);
4579
4580 toplevel_signals [UNEXPAND_SIGNAL] =
4581 g_signal_new ("unexpand",
4582 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
4583 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
4584 G_STRUCT_OFFSET (PanelToplevelClass, unexpand)((glong) __builtin_offsetof(PanelToplevelClass, unexpand)),
4585 NULL((void*)0),
4586 NULL((void*)0),
4587 panel_marshal_BOOLEAN__VOID,
4588 G_TYPE_BOOLEAN((GType) ((5) << (2))),
4589 0);
4590
4591 toplevel_signals [TOGGLE_HIDDEN_SIGNAL] =
4592 g_signal_new ("toggle-hidden",
4593 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
4594 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
4595 G_STRUCT_OFFSET (PanelToplevelClass, toggle_hidden)((glong) __builtin_offsetof(PanelToplevelClass, toggle_hidden
))
,
4596 NULL((void*)0),
4597 NULL((void*)0),
4598 panel_marshal_BOOLEAN__VOID,
4599 G_TYPE_BOOLEAN((GType) ((5) << (2))),
4600 0);
4601
4602 toplevel_signals [BEGIN_MOVE_SIGNAL] =
4603 g_signal_new ("begin-move",
4604 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
4605 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
4606 G_STRUCT_OFFSET (PanelToplevelClass, begin_move)((glong) __builtin_offsetof(PanelToplevelClass, begin_move)),
4607 NULL((void*)0),
4608 NULL((void*)0),
4609 panel_marshal_BOOLEAN__VOID,
4610 G_TYPE_BOOLEAN((GType) ((5) << (2))),
4611 0);
4612
4613 toplevel_signals [BEGIN_RESIZE_SIGNAL] =
4614 g_signal_new ("begin-resize",
4615 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
4616 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
4617 G_STRUCT_OFFSET (PanelToplevelClass, begin_resize)((glong) __builtin_offsetof(PanelToplevelClass, begin_resize)
)
,
4618 NULL((void*)0),
4619 NULL((void*)0),
4620 panel_marshal_BOOLEAN__VOID,
4621 G_TYPE_BOOLEAN((GType) ((5) << (2))),
4622 0);
4623
4624 gtk_binding_entry_add_signal (binding_set, GDK_KEY_F100xffc7, GDK_CONTROL_MASK,
4625 "popup_panel_menu", 0);
4626
4627 panel_bindings_set_entries (binding_set);
4628}
4629
4630static void
4631panel_toplevel_setup_widgets (PanelToplevel *toplevel)
4632{
4633 GtkWidget* container;
4634
4635 toplevel->priv->grid = gtk_grid_new ();
4636
4637 toplevel->priv->hide_button_top = panel_toplevel_add_hide_button (toplevel, GTK_ARROW_UP, 1, 0);
4638 toplevel->priv->hide_button_bottom = panel_toplevel_add_hide_button (toplevel, GTK_ARROW_DOWN, 1, 2);
4639 toplevel->priv->hide_button_left = panel_toplevel_add_hide_button (toplevel, GTK_ARROW_LEFT, 0, 1);
4640 toplevel->priv->hide_button_right = panel_toplevel_add_hide_button (toplevel, GTK_ARROW_RIGHT, 2, 1);
4641
4642 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM))
4643 {
4644 gtk_widget_show(toplevel->priv->hide_button_left);
4645 gtk_widget_show(toplevel->priv->hide_button_right);
4646 }
4647 else
4648 {
4649 gtk_widget_show(toplevel->priv->hide_button_top);
4650 gtk_widget_show(toplevel->priv->hide_button_bottom);
4651 }
4652
4653 toplevel->priv->inner_frame = g_object_new(PANEL_TYPE_FRAME(panel_frame_get_type ()), NULL((void*)0));
4654
4655 gtk_widget_set_hexpand (GTK_WIDGET (toplevel->priv->inner_frame)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->inner_frame)), ((gtk_widget_get_type
()))))))
, TRUE(!(0)));
4656 gtk_widget_set_vexpand (GTK_WIDGET (toplevel->priv->inner_frame)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->inner_frame)), ((gtk_widget_get_type
()))))))
, TRUE(!(0)));
4657
4658 gtk_grid_attach (GTK_GRID (toplevel->priv->grid)((((GtkGrid*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->grid)), ((gtk_grid_get_type ()))))
))
, GTK_WIDGET (toplevel->priv->inner_frame)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->inner_frame)), ((gtk_widget_get_type
()))))))
, 1, 1, 1, 1);
4659 gtk_widget_show (GTK_WIDGET (toplevel->priv->inner_frame)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->inner_frame)), ((gtk_widget_get_type
()))))))
);
4660
4661 container = panel_widget_new (toplevel,
4662 !toplevel->priv->expand,
4663 (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)) ?
4664 GTK_ORIENTATION_HORIZONTAL :
4665 GTK_ORIENTATION_VERTICAL,
4666 toplevel->priv->size);
4667
4668 toplevel->priv->panel_widget = PANEL_WIDGET(container)((((PanelWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((container)), ((panel_widget_get_type()))))))
;
4669
4670 gtk_container_add(GTK_CONTAINER(toplevel->priv->inner_frame)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->inner_frame)), ((gtk_container_get_type
()))))))
, container);
4671 gtk_widget_show(container);
4672
4673 gtk_container_add (GTK_CONTAINER (toplevel)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_container_get_type ()))))))
, toplevel->priv->grid);
4674 gtk_widget_show (toplevel->priv->grid);
4675}
4676
4677static void
4678background_changed (PanelBackground *background,
4679 PanelToplevel *toplevel)
4680{
4681 panel_toplevel_update_edges (toplevel);
4682 panel_widget_emit_background_changed (toplevel->priv->panel_widget);
4683}
4684
4685static void
4686panel_toplevel_init (PanelToplevel *toplevel)
4687{
4688 GtkWidget *widget;
4689 int i;
4690
4691 toplevel->priv = panel_toplevel_get_instance_private (toplevel);
4692
4693 toplevel->priv->expand = TRUE(!(0));
4694 toplevel->priv->orientation = PANEL_ORIENTATION_BOTTOM;
4695 toplevel->priv->size = DEFAULT_SIZE48;
4696 toplevel->priv->scale = gtk_widget_get_scale_factor (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
4697 toplevel->priv->x = 0;
4698 toplevel->priv->y = 0;
4699 toplevel->priv->x_right = -1;
4700 toplevel->priv->y_bottom = -1;
4701 toplevel->priv->monitor = 0;
4702 toplevel->priv->configured_monitor = -1;
4703 toplevel->priv->hide_delay = DEFAULT_HIDE_DELAY300;
4704 toplevel->priv->unhide_delay = DEFAULT_UNHIDE_DELAY100;
4705 toplevel->priv->auto_hide_size = DEFAULT_AUTO_HIDE_SIZE1;
4706 toplevel->priv->animation_speed = PANEL_ANIMATION_FAST;
4707
4708 toplevel->priv->snap_tolerance = DEFAULT_DND_THRESHOLD8 * SNAP_TOLERANCE_FACTOR6;
4709 toplevel->priv->gtk_settings = NULL((void*)0);
4710
4711 toplevel->priv->state = PANEL_STATE_NORMAL;
4712
4713 toplevel->priv->name = NULL((void*)0);
4714 toplevel->priv->description = NULL((void*)0);
4715
4716 toplevel->priv->hide_timeout = 0;
4717 toplevel->priv->unhide_timeout = 0;
4718
4719 toplevel->priv->geometry.x = -1;
4720 toplevel->priv->geometry.y = -1;
4721 toplevel->priv->geometry.width = -1;
4722 toplevel->priv->geometry.height = -1;
4723
4724 toplevel->priv->original_width = -1;
4725 toplevel->priv->original_height = -1;
4726
4727 toplevel->priv->grab_op = PANEL_GRAB_OP_NONE;
4728
4729 toplevel->priv->drag_offset_x = 0;
4730 toplevel->priv->drag_offset_y = 0;
4731
4732 toplevel->priv->animation_end_x = 0;
4733 toplevel->priv->animation_end_y = 0;
4734 toplevel->priv->animation_end_width = 0;
4735 toplevel->priv->animation_end_height = 0;
4736 toplevel->priv->animation_start_time = 0;
4737 toplevel->priv->animation_duration_time = 0;
4738 toplevel->priv->animation_timeout = 0;
4739
4740 toplevel->priv->panel_widget = NULL((void*)0);
4741 toplevel->priv->inner_frame = NULL((void*)0);
4742 toplevel->priv->grid = NULL((void*)0);
4743 toplevel->priv->hide_button_top = NULL((void*)0);
4744 toplevel->priv->hide_button_bottom = NULL((void*)0);
4745 toplevel->priv->hide_button_left = NULL((void*)0);
4746 toplevel->priv->hide_button_right = NULL((void*)0);
4747
4748 toplevel->priv->attach_toplevel = NULL((void*)0);
4749 toplevel->priv->attach_widget = NULL((void*)0);
4750 toplevel->priv->n_autohide_disablers = 0;
4751
4752 for (i = 0; i < N_ATTACH_TOPLEVEL_SIGNALS5; i++)
4753 toplevel->priv->attach_toplevel_signals [i] = 0;
4754 for (i = 0; i < N_ATTACH_WIDGET_SIGNALS5; i++)
4755 toplevel->priv->attach_widget_signals [i] = 0;
4756
4757 toplevel->priv->auto_hide = FALSE(0);
4758 toplevel->priv->buttons_enabled = TRUE(!(0));
4759 toplevel->priv->arrows_enabled = TRUE(!(0));
4760 toplevel->priv->x_centered = FALSE(0);
4761 toplevel->priv->y_centered = FALSE(0);
4762 toplevel->priv->animating = FALSE(0);
4763 toplevel->priv->grab_is_keyboard = FALSE(0);
4764 toplevel->priv->position_centered = FALSE(0);
4765 toplevel->priv->attached = FALSE(0);
4766 toplevel->priv->attach_hidden = FALSE(0);
4767 toplevel->priv->updated_geometry_initial = FALSE(0);
4768 toplevel->priv->initial_animation_done = FALSE(0);
4769
4770 widget = GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
;
4771 gtk_widget_add_events (widget,
4772 GDK_BUTTON_PRESS_MASK |
4773 GDK_BUTTON_RELEASE_MASK |
4774 GDK_POINTER_MOTION_MASK |
4775 GDK_ENTER_NOTIFY_MASK |
4776 GDK_LEAVE_NOTIFY_MASK);
4777
4778 gtk_widget_set_app_paintable (widget, TRUE(!(0)));
4779
4780 panel_toplevel_setup_widgets (toplevel);
4781 panel_toplevel_update_description (toplevel);
4782 panel_toplevel_update_gtk_settings (toplevel);
4783
4784 toplevel_list = g_slist_prepend (toplevel_list, toplevel);
4785
4786 /* Prevent the window from being deleted via Alt+F4 by accident. This
4787 * happens with "alternative" window managers such as Sawfish or XFWM4.
4788 */
4789 g_signal_connect (toplevel, "delete-event", G_CALLBACK(gtk_true), NULL)g_signal_connect_data ((toplevel), ("delete-event"), (((GCallback
) (gtk_true))), (((void*)0)), ((void*)0), (GConnectFlags) 0)
;
4790
4791 panel_background_init (&toplevel->background,
4792 (PanelBackgroundChangedNotify) background_changed,
4793 toplevel);
4794
4795 update_style_classes (toplevel);
4796
4797#ifdef HAVE_WAYLAND1
4798 if (GDK_IS_WAYLAND_DISPLAY (gdk_display_get_default ())(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gdk_display_get_default ())); GType __t = ((gdk_wayland_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
) {
4799 wayland_panel_toplevel_init (toplevel);
4800 }
4801#endif /* HAVE_WAYLAND */
4802}
4803
4804PanelWidget *
4805panel_toplevel_get_panel_widget (PanelToplevel *toplevel)
4806{
4807
4808 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return (((void
*)0)); } } while (0)
;
4809
4810 return toplevel->priv->panel_widget;
4811}
4812
4813static void
4814panel_toplevel_update_name (PanelToplevel *toplevel)
4815{
4816 char *title;
4817
4818 g_assert (toplevel->priv->description != NULL)do { if (toplevel->priv->description != ((void*)0)) ; else
g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c", 4818
, ((const char*) (__func__)), "toplevel->priv->description != NULL"
); } while (0)
;
4819
4820 title = toplevel->priv->name ? toplevel->priv->name : toplevel->priv->description;
4821
4822 gtk_window_set_title (GTK_WINDOW (toplevel)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_window_get_type ()))))))
, title);
4823
4824 panel_a11y_set_atk_name_desc (
4825 GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
,
4826 title, toplevel->priv->description);
4827}
4828
4829void
4830panel_toplevel_set_name (PanelToplevel *toplevel,
4831 const char *name)
4832{
4833 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
4834
4835 if (!toplevel->priv->name && (!name || !name [0]))
4836 return;
4837
4838 if (toplevel->priv->name && name && name [0] &&
4839 !strcmp (toplevel->priv->name, name))
4840 return;
4841
4842 g_free (toplevel->priv->name);
4843 if (name && name [0])
4844 toplevel->priv->name = g_strdup (name)g_strdup_inline (name);
4845 else
4846 toplevel->priv->name = NULL((void*)0);
4847
4848 panel_toplevel_update_name (toplevel);
4849
4850 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "name");
4851}
4852
4853void
4854panel_toplevel_set_settings_path (PanelToplevel *toplevel,
4855 const char *settings_path)
4856{
4857 toplevel->priv->settings_path = g_strdup (settings_path)g_strdup_inline (settings_path);
4858}
4859
4860const char* panel_toplevel_get_name(PanelToplevel* toplevel)
4861{
4862 g_return_val_if_fail(PANEL_IS_TOPLEVEL(toplevel), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL(toplevel)"); return (((void
*)0)); } } while (0)
;
4863
4864 return toplevel->priv->name;
4865}
4866
4867const char* panel_toplevel_get_description(PanelToplevel* toplevel)
4868{
4869 g_return_val_if_fail(PANEL_IS_TOPLEVEL(toplevel), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL(toplevel)"); return (((void
*)0)); } } while (0)
;
4870
4871 return toplevel->priv->description;
4872}
4873
4874void
4875panel_toplevel_set_expand (PanelToplevel *toplevel,
4876 gboolean expand)
4877{
4878 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
4879
4880 if (toplevel->priv->attached && expand) {
4881 g_warning ("attempt to expand attached toplevel; ignoring");
4882 return;
4883 }
4884
4885 expand = expand != FALSE(0);
4886
4887 if (toplevel->priv->expand == expand)
4888 return;
4889
4890 toplevel->priv->expand = expand;
4891
4892 if (!toplevel->priv->expand && toplevel->priv->updated_geometry_initial) {
4893 switch (toplevel->priv->orientation) {
4894 case PANEL_ORIENTATION_TOP:
4895 panel_toplevel_set_x (toplevel, 0, -1, TRUE(!(0)));
4896 break;
4897 case PANEL_ORIENTATION_BOTTOM:
4898 panel_toplevel_set_x (toplevel, 0, 0, TRUE(!(0)));
4899 break;
4900 case PANEL_ORIENTATION_LEFT:
4901 panel_toplevel_set_y (toplevel, 0, -1, TRUE(!(0)));
4902 break;
4903 case PANEL_ORIENTATION_RIGHT:
4904 panel_toplevel_set_y (toplevel, 0, 0, TRUE(!(0)));
4905 break;
4906 default:
4907 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 4907, ((const char*) (__func__)), ((void*)0)); } while (0)
;
4908 break;
4909 }
4910 }
4911
4912 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
4913
4914 panel_widget_set_packed (toplevel->priv->panel_widget, !toplevel->priv->expand);
4915
4916 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "expand");
4917}
4918
4919gboolean
4920panel_toplevel_get_expand (PanelToplevel *toplevel)
4921{
4922 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), TRUE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return ((!(0)
)); } } while (0)
;
4923
4924 return toplevel->priv->expand;
4925}
4926
4927gboolean
4928panel_toplevel_get_is_floating (PanelToplevel *toplevel)
4929{
4930 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), TRUE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return ((!(0)
)); } } while (0)
;
4931
4932 return toplevel->priv->floating;
4933}
4934
4935void
4936panel_toplevel_set_orientation (PanelToplevel *toplevel,
4937 PanelOrientation orientation)
4938{
4939 gboolean rotate;
4940 GdkRectangle monitor_geom;
4941
4942 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
4943
4944 if (toplevel->priv->orientation == orientation)
4945 return;
4946
4947 g_object_freeze_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
);
4948
4949 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
4950
4951 /* Un-snap from center if no longer along screen edge */
4952 if (toplevel->priv->x_centered &&
4953 (orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT))) {
4954 toplevel->priv->x_centered = FALSE(0);
4955 toplevel->priv->x = (monitor_geom.width - toplevel->priv->geometry.width) / 2;
4956 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "x");
4957 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "x-centered");
4958
4959 if (toplevel->priv->x_right != -1) {
4960 toplevel->priv->x_right = -1;
4961 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "x-right");
4962 }
4963 }
4964
4965 if (toplevel->priv->y_centered &&
4966 (orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM))) {
4967 toplevel->priv->y_centered = FALSE(0);
4968 toplevel->priv->y = (monitor_geom.height - toplevel->priv->geometry.height) / 2;
4969 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "y");
4970 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "y-centered");
4971
4972 if (toplevel->priv->y_bottom != -1) {
4973 toplevel->priv->y_bottom = -1;
4974 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "y-bottom");
4975 }
4976 }
4977
4978 rotate = FALSE(0);
4979 if ((orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)) &&
4980 (toplevel->priv->orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT)))
4981 rotate = TRUE(!(0));
4982 else if ((orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT)) &&
4983 (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)))
4984 rotate = TRUE(!(0));
4985
4986 /* rotate around the center */
4987 if (rotate && !toplevel->priv->position_centered && !toplevel->priv->expand &&
4988 toplevel->priv->updated_geometry_initial) {
4989 toplevel->priv->position_centered = TRUE(!(0));
4990
4991 /* x, y temporary refer to the panel center, so we don't care
4992 * about x_right, y_bottom. Those will get updated in
4993 * panel_toplevel_update_position() accordingly. */
4994 if (!toplevel->priv->x_centered) {
4995 toplevel->priv->x += toplevel->priv->geometry.width / 2;
4996 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "x");
4997 }
4998
4999 if (!toplevel->priv->y_centered) {
5000 toplevel->priv->y += toplevel->priv->geometry.height / 2;
5001 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "y");
5002 }
5003
5004 }
5005
5006 toplevel->priv->orientation = orientation;
5007 update_style_classes (toplevel);
5008
5009 gtk_widget_reset_style (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
5010
5011 panel_toplevel_update_hide_buttons (toplevel);
5012
5013 panel_widget_set_orientation (
5014 toplevel->priv->panel_widget,
5015 (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)) ?
5016 GTK_ORIENTATION_HORIZONTAL :
5017 GTK_ORIENTATION_VERTICAL);
5018
5019 switch (toplevel->priv->state) {
5020 case PANEL_STATE_HIDDEN_UP:
5021 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM))
5022 toplevel->priv->state = PANEL_STATE_HIDDEN_LEFT;
5023 break;
5024 case PANEL_STATE_HIDDEN_DOWN:
5025 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM))
5026 toplevel->priv->state = PANEL_STATE_HIDDEN_RIGHT;
5027 break;
5028 case PANEL_STATE_HIDDEN_LEFT:
5029 if (toplevel->priv->orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT))
5030 toplevel->priv->state = PANEL_STATE_HIDDEN_UP;
5031 break;
5032 case PANEL_STATE_HIDDEN_RIGHT:
5033 if (toplevel->priv->orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT))
5034 toplevel->priv->state = PANEL_STATE_HIDDEN_DOWN;
5035 break;
5036 default:
5037 break;
5038 }
5039
5040 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
5041
5042 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "orientation");
5043
5044 g_object_thaw_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
);
5045
5046#ifdef HAVE_WAYLAND1
5047 if (GDK_IS_WAYLAND_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel)))(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gtk_widget_get_display (((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((toplevel)), ((gtk_widget_get_type ()))))
))))); GType __t = ((gdk_wayland_display_get_type())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
) {
5048 wayland_panel_toplevel_update_placement (toplevel);
5049 }
5050#endif /* HAVE_WAYLAND */
5051}
5052
5053PanelOrientation
5054panel_toplevel_get_orientation (PanelToplevel *toplevel)
5055{
5056 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), PANEL_ORIENTATION_TOP)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return (PANEL_ORIENTATION_TOP
); } } while (0)
;
5057
5058 return toplevel->priv->orientation;
5059}
5060
5061void
5062panel_toplevel_set_size (PanelToplevel *toplevel,
5063 int size)
5064{
5065 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
5066 g_return_if_fail (size >= 0)do { if ((size >= 0)) { } else { g_return_if_fail_warning (
((gchar*) 0), ((const char*) (__func__)), "size >= 0"); return
; } } while (0)
;
5067
5068 if (toplevel->priv->size == size)
5069 return;
5070
5071 toplevel->priv->size = size;
5072
5073 panel_widget_set_size (toplevel->priv->panel_widget, toplevel->priv->size);
5074
5075 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
5076
5077 panel_toplevel_update_hide_buttons (toplevel);
5078
5079 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "size");
5080}
5081
5082int
5083panel_toplevel_get_size (PanelToplevel *toplevel)
5084{
5085 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), DEFAULT_SIZE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return (48); }
} while (0)
;
5086
5087 return toplevel->priv->size;
5088}
5089
5090void
5091panel_toplevel_set_auto_hide_size (PanelToplevel *toplevel,
5092 int auto_hide_size)
5093{
5094 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
5095
5096 if (toplevel->priv->auto_hide_size == auto_hide_size)
5097 return;
5098
5099 toplevel->priv->auto_hide_size = auto_hide_size;
5100
5101 if (toplevel->priv->state == PANEL_STATE_AUTO_HIDDEN) {
5102 if (panel_toplevel_update_struts (toplevel, FALSE(0))) {
5103 if (toplevel->priv->animate) {
5104 panel_toplevel_unhide (toplevel);
5105 panel_toplevel_hide (toplevel, TRUE(!(0)), -1);
5106 } else
5107 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
5108 }
5109 }
5110
5111 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "auto-hide-size");
5112}
5113
5114int
5115panel_toplevel_get_auto_hide_size (PanelToplevel *toplevel)
5116{
5117 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), DEFAULT_AUTO_HIDE_SIZE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return (1); }
} while (0)
;
5118
5119 return toplevel->priv->auto_hide_size;
5120}
5121
5122void
5123panel_toplevel_set_x (PanelToplevel *toplevel,
5124 int x,
5125 int x_right,
5126 gboolean x_centered)
5127{
5128 gboolean changed = FALSE(0);
5129
5130 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
5131
5132 x_centered = x_centered != FALSE(0);
5133
5134 g_object_freeze_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
);
5135
5136 if (toplevel->priv->x != x) {
5137 toplevel->priv->x = x;
5138 changed = TRUE(!(0));
5139 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "x");
5140 }
5141
5142 if (toplevel->priv->x_right != x_right) {
5143 toplevel->priv->x_right = x_right;
5144 changed = TRUE(!(0));
5145 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "x-right");
5146 }
5147
5148 if (toplevel->priv->x_centered != x_centered) {
5149 toplevel->priv->x_centered = (x_centered != FALSE(0));
5150 changed = TRUE(!(0));
5151 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "x-centered");
5152 }
5153
5154 if (changed)
5155 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
5156
5157 g_object_thaw_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
);
5158}
5159
5160void
5161panel_toplevel_set_y (PanelToplevel *toplevel,
5162 int y,
5163 int y_bottom,
5164 gboolean y_centered)
5165{
5166 gboolean changed = FALSE(0);
5167
5168 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
5169
5170 y_centered = y_centered != FALSE(0);
5171
5172 g_object_freeze_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
);
5173
5174 if (toplevel->priv->y != y) {
5175 toplevel->priv->y = y;
5176 changed = TRUE(!(0));
5177 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "y");
5178 }
5179
5180 if (toplevel->priv->y_bottom != y_bottom) {
5181 toplevel->priv->y_bottom = y_bottom;
5182 changed = TRUE(!(0));
5183 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "y-bottom");
5184 }
5185
5186 if (toplevel->priv->y_centered != y_centered) {
5187 toplevel->priv->y_centered = (y_centered != FALSE(0));
5188 changed = TRUE(!(0));
5189 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "y-centered");
5190 }
5191
5192 if (changed)
5193 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
5194
5195 g_object_thaw_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
);
5196}
5197
5198void
5199panel_toplevel_get_position (PanelToplevel *toplevel,
5200 int *x,
5201 int *x_right,
5202 int *y,
5203 int *y_bottom)
5204{
5205 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
5206
5207 if (x)
5208 *x = toplevel->priv->x;
5209
5210 if (y)
5211 *y = toplevel->priv->y;
5212
5213 if (x_right)
5214 *x_right = toplevel->priv->x_right;
5215
5216 if (y_bottom)
5217 *y_bottom = toplevel->priv->y_bottom;
5218}
5219
5220gboolean
5221panel_toplevel_get_x_centered (PanelToplevel *toplevel)
5222{
5223 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return ((0));
} } while (0)
;
5224
5225 return toplevel->priv->x_centered;
5226}
5227
5228gboolean
5229panel_toplevel_get_y_centered (PanelToplevel *toplevel)
5230{
5231 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return ((0));
} } while (0)
;
5232
5233 return toplevel->priv->y_centered;
5234}
5235
5236/**
5237 * panel_toplevel_set_monitor_internal:
5238 *
5239 * Sets the monitor of the toplevel, but only the internal state. We need to
5240 * make the difference between the internal state and the configuration of the
5241 * user because internal constraints might affect the monitor of the toplevel.
5242 *
5243 * panel_toplevel_set_monitor_internal() won't update the configuration of the
5244 * user.
5245 **/
5246static void
5247panel_toplevel_set_monitor_internal (PanelToplevel *toplevel,
5248 int monitor,
5249 gboolean force_resize)
5250{
5251 if (toplevel->priv->monitor == monitor)
5252 return;
5253
5254 toplevel->priv->monitor = monitor;
5255
5256 if (force_resize)
5257 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
5258}
5259
5260/**
5261 * panel_toplevel_update_monitor:
5262 *
5263 * Moves the toplevel to its configured monitor or the first one, if needed.
5264 * This generally happens when the configured monitor was non-existing before,
5265 * and it appeared at runtime, or if it was existing and disappeared.
5266 *
5267 * This must only be called at the beginning of the size request of the
5268 * toplevel because it doesn't queue a size request.
5269 **/
5270static void
5271panel_toplevel_update_monitor (PanelToplevel *toplevel)
5272{
5273 /* If we were not using the configured monitor, can we use it now? */
5274 if ((toplevel->priv->configured_monitor != -1) &&
5275 (toplevel->priv->configured_monitor != toplevel->priv->monitor) &&
5276 toplevel->priv->configured_monitor < panel_multimonitor_monitors ()) {
5277 panel_toplevel_set_monitor_internal (toplevel,
5278 toplevel->priv->configured_monitor,
5279 FALSE(0));
5280
5281 /* else, can we still use the monitor we were using? */
5282 } else if (toplevel->priv->monitor >= panel_multimonitor_monitors ()) {
5283 panel_toplevel_set_monitor_internal (toplevel,
5284 0,
5285 FALSE(0));
5286 }
5287}
5288
5289void
5290panel_toplevel_set_monitor (PanelToplevel *toplevel,
5291 int monitor)
5292{
5293 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
5294
5295 if (toplevel->priv->configured_monitor == monitor)
5296 return;
5297
5298 toplevel->priv->configured_monitor = monitor;
5299
5300 /* Only use the configured monitor if it's existing. Else, we ignore
5301 * the non-existing monitor, and keep the old one. The main use case is
5302 * when logging in after having used a multimonitor environment.
5303 * We will put the panel on the monitor 0 for this session, and it will
5304 * move back to the right monitor next time. */
5305 if (monitor < panel_multimonitor_monitors ())
5306 panel_toplevel_set_monitor_internal (toplevel, monitor, TRUE(!(0)));
5307
5308 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "monitor");
5309}
5310
5311int
5312panel_toplevel_get_monitor (PanelToplevel *toplevel)
5313{
5314 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), -1)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return (-1); }
} while (0)
;
5315
5316 return toplevel->priv->monitor;
5317}
5318
5319void
5320panel_toplevel_set_auto_hide (PanelToplevel *toplevel,
5321 gboolean auto_hide)
5322{
5323 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
5324
5325 auto_hide = auto_hide != FALSE(0);
5326
5327 if (toplevel->priv->auto_hide == auto_hide)
5328 return;
5329
5330 toplevel->priv->auto_hide = (auto_hide != FALSE(0));
5331
5332 if (toplevel->priv->auto_hide)
5333 panel_toplevel_queue_auto_hide (toplevel);
5334 else
5335 panel_toplevel_queue_auto_unhide (toplevel);
5336
5337 if (panel_toplevel_update_struts (toplevel, FALSE(0)))
5338 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
5339
5340 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "auto-hide");
5341}
5342
5343gboolean
5344panel_toplevel_get_auto_hide (PanelToplevel *toplevel)
5345{
5346 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return ((0));
} } while (0)
;
5347
5348 return toplevel->priv->auto_hide;
5349}
5350
5351void
5352panel_toplevel_set_hide_delay (PanelToplevel *toplevel,
5353 int hide_delay)
5354{
5355 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
5356
5357 if (toplevel->priv->hide_delay == hide_delay)
5358 return;
5359
5360 toplevel->priv->hide_delay = hide_delay;
5361
5362 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "hide-delay");
5363}
5364
5365int
5366panel_toplevel_get_hide_delay (PanelToplevel *toplevel)
5367{
5368 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), -1)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return (-1); }
} while (0)
;
5369
5370 return toplevel->priv->hide_delay;
5371}
5372
5373void
5374panel_toplevel_set_unhide_delay (PanelToplevel *toplevel,
5375 int unhide_delay)
5376{
5377 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
5378
5379 if (toplevel->priv->unhide_delay == unhide_delay)
5380 return;
5381
5382 toplevel->priv->unhide_delay = unhide_delay;
5383
5384 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "unhide-delay");
5385}
5386
5387int
5388panel_toplevel_get_unhide_delay (PanelToplevel *toplevel)
5389{
5390 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), -1)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return (-1); }
} while (0)
;
5391
5392 return toplevel->priv->unhide_delay;
5393}
5394
5395void
5396panel_toplevel_set_animate (PanelToplevel *toplevel,
5397 gboolean animate)
5398{
5399 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
5400
5401 animate = animate != FALSE(0);
5402
5403 if (toplevel->priv->animate == animate)
5404 return;
5405
5406 toplevel->priv->animate = (animate != FALSE(0));
5407
5408 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "animate");
5409}
5410
5411gboolean
5412panel_toplevel_get_animate (PanelToplevel *toplevel)
5413{
5414 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return ((0));
} } while (0)
;
5415
5416 return toplevel->priv->animate;
5417}
5418
5419void
5420panel_toplevel_set_animation_speed (PanelToplevel *toplevel,
5421 PanelAnimationSpeed animation_speed)
5422{
5423 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
5424
5425 if (toplevel->priv->animation_speed == animation_speed)
5426 return;
5427
5428 toplevel->priv->animation_speed = animation_speed;
5429
5430 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "animation-speed");
5431}
5432
5433PanelAnimationSpeed
5434panel_toplevel_get_animation_speed (PanelToplevel *toplevel)
5435{
5436 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), 0)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return (0); }
} while (0)
;
5437
5438 return toplevel->priv->animation_speed;
5439}
5440
5441void
5442panel_toplevel_set_enable_buttons (PanelToplevel *toplevel,
5443 gboolean enable_buttons)
5444{
5445 enable_buttons = enable_buttons != FALSE(0);
5446
5447 if (toplevel->priv->buttons_enabled == enable_buttons)
5448 return;
5449
5450 toplevel->priv->buttons_enabled = enable_buttons;
5451
5452 panel_toplevel_update_hide_buttons (toplevel);
5453
5454 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "buttons-enabled");
5455}
5456
5457gboolean
5458panel_toplevel_get_enable_buttons (PanelToplevel *toplevel)
5459{
5460 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return ((0));
} } while (0)
;
5461
5462 return toplevel->priv->buttons_enabled;
5463}
5464
5465void
5466panel_toplevel_set_enable_arrows (PanelToplevel *toplevel,
5467 gboolean enable_arrows)
5468{
5469 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
5470
5471 enable_arrows = enable_arrows != FALSE(0);
5472
5473 if (toplevel->priv->arrows_enabled == enable_arrows)
5474 return;
5475
5476 toplevel->priv->arrows_enabled = (enable_arrows != FALSE(0));
5477
5478 panel_toplevel_update_hide_buttons (toplevel);
5479
5480 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "arrows-enabled");
5481}
5482
5483gboolean
5484panel_toplevel_get_enable_arrows (PanelToplevel *toplevel)
5485{
5486 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return ((0));
} } while (0)
;
5487
5488 return toplevel->priv->arrows_enabled;
5489}
5490
5491void
5492panel_toplevel_rotate (PanelToplevel *toplevel,
5493 gboolean clockwise)
5494{
5495 PanelOrientation orientation;
5496
5497 /* Relies on PanelOrientation definition:
5498 *
5499 * typedef enum {
5500 * PANEL_ORIENTATION_TOP = 1 << 0,
5501 * PANEL_ORIENTATION_RIGHT = 1 << 1,
5502 * PANEL_ORIENTATION_BOTTOM = 1 << 2,
5503 * PANEL_ORIENTATION_LEFT = 1 << 3
5504 * } PanelOrientation;
5505 */
5506
5507 orientation = toplevel->priv->orientation;
5508
5509 if (clockwise)
5510 orientation <<= 1;
5511 else
5512 orientation >>= 1;
5513
5514 if (orientation == 0)
5515 orientation = PANEL_ORIENTATION_LEFT;
5516
5517 else if (orientation > PANEL_ORIENTATION_LEFT)
5518 orientation = PANEL_ORIENTATION_TOP;
5519
5520 panel_toplevel_set_orientation (toplevel, orientation);
5521}
5522
5523PanelState
5524panel_toplevel_get_state (PanelToplevel *toplevel)
5525{
5526 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), 0)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return (0); }
} while (0)
;
5527
5528 return toplevel->priv->state;
5529}
5530
5531gboolean
5532panel_toplevel_get_is_hidden (PanelToplevel *toplevel)
5533{
5534 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return ((0));
} } while (0)
;
5535
5536 if (toplevel->priv->state == PANEL_STATE_HIDDEN_UP ||
5537 toplevel->priv->state == PANEL_STATE_HIDDEN_DOWN ||
5538 toplevel->priv->state == PANEL_STATE_HIDDEN_LEFT ||
5539 toplevel->priv->state == PANEL_STATE_HIDDEN_RIGHT)
5540 return TRUE(!(0));
5541
5542 return FALSE(0);
5543}
5544
5545int
5546panel_toplevel_get_minimum_size (PanelToplevel *toplevel)
5547{
5548 return calculate_minimum_height (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
,
5549 toplevel->priv->orientation);
5550}
5551
5552int
5553panel_toplevel_get_maximum_size (PanelToplevel *toplevel)
5554{
5555 GdkRectangle monitor_geom;
5556
5557 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
5558
5559 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM))
5560 return monitor_geom.height / MAXIMUM_SIZE_SCREEN_RATIO5;
5561 else
5562 return monitor_geom.width / MAXIMUM_SIZE_SCREEN_RATIO5;
5563}
diff --git a/2024-06-18-172109-13286-1@e182420b844f_master/report-e04d58.html b/2024-06-18-172109-13286-1@e182420b844f_master/report-e04d58.html new file mode 100644 index 00000000..f86b6218 --- /dev/null +++ b/2024-06-18-172109-13286-1@e182420b844f_master/report-e04d58.html @@ -0,0 +1,6243 @@ + + + +panel-toplevel.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:mate-panel/panel-toplevel.c
Warning:line 591, column 2
Value stored to 'new_size' is never read
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name panel-toplevel.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/mate-panel -fcoverage-compilation-dir=/rootdir/mate-panel -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I .. -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/startup-notification-1.0 -I /usr/include/mate-menus -I /usr/include/gio-unix-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/dconf -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/dconf -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I . -I . -I ../mate-panel -I ../mate-panel/mate-submodules -I ../mate-panel/libpanel-util -D MATELOCALEDIR="/usr/local/share/locale" -D PANELDATADIR="/usr/local/share/mate-panel" -I /usr/include/gtk-layer-shell -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/gtk-3.0 -I /usr/include/cloudproviders -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/atk-1.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/gio-unix-2.0 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -D PANEL_MODULES_DIR="/usr/local/lib/mate-panel/modules" -D MATEMENU_I_KNOW_THIS_IS_UNSTABLE -I /usr/include/gtk-layer-shell -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/gtk-3.0 -I /usr/include/cloudproviders -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/atk-1.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/gio-unix-2.0 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-18-172109-13286-1 -x c panel-toplevel.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
2 *
3 * panel-toplevel.c: The panel's toplevel window object.
4 *
5 * Copyright (C) 2003 Sun Microsystems, Inc.
6 * Copyright (C) 2004 Rob Adams
7 * Copyright (C) 2012-2021 MATE Developers
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of the
12 * License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
22 * 02110-1301, USA.
23 *
24 * Authors:
25 * Mark McLoughlin <mark@skynet.ie>
26 */
27
28#include <config.h>
29
30#include "panel-toplevel.h"
31
32#include <stdlib.h>
33#include <string.h>
34
35#include <gtk/gtk.h>
36#include <gdk/gdkkeysyms.h>
37#include <glib/gi18n.h>
38
39#ifdef HAVE_X111
40#include <gdk/gdkx.h>
41#endif
42
43#include "panel-util.h"
44#include "panel-profile.h"
45#include "panel-frame.h"
46#include "panel-multimonitor.h"
47#include "panel-a11y.h"
48#include "panel-typebuiltins.h"
49#include "panel-marshal.h"
50#include "panel-widget.h"
51#include "panel-bindings.h"
52#include "panel-config-global.h"
53#include "panel-lockdown.h"
54#include "panel-schemas.h"
55
56#ifdef HAVE_X111
57#include "xstuff.h"
58#include "panel-xutils.h"
59#include "panel-struts.h"
60#endif
61#ifdef HAVE_WAYLAND1
62#include "wayland-backend.h"
63#endif
64
65#define DEFAULT_SIZE48 48
66#define DEFAULT_AUTO_HIDE_SIZE1 1
67#define DEFAULT_HIDE_DELAY300 300
68#define DEFAULT_UNHIDE_DELAY100 100
69#define DEFAULT_DND_THRESHOLD8 8
70#define MINIMUM_WIDTH100 100
71#define MAXIMUM_SIZE_SCREEN_RATIO5 5
72#define SNAP_TOLERANCE_FACTOR6 6
73#define DEFAULT_ARROW_SIZE20 20
74#define HANDLE_SIZE10 10
75#define N_ATTACH_TOPLEVEL_SIGNALS5 5
76#define N_ATTACH_WIDGET_SIGNALS5 5
77
78typedef enum {
79 PANEL_GRAB_OP_NONE,
80 PANEL_GRAB_OP_MOVE,
81 PANEL_GRAB_OP_RESIZE,
82 PANEL_GRAB_OP_RESIZE_UP,
83 PANEL_GRAB_OP_RESIZE_DOWN,
84 PANEL_GRAB_OP_RESIZE_LEFT,
85 PANEL_GRAB_OP_RESIZE_RIGHT
86} PanelGrabOpType;
87
88struct _PanelToplevelPrivate {
89 gchar *settings_path;
90
91 gboolean expand;
92 PanelOrientation orientation;
93 int size;
94 gint scale;
95
96 /* relative to the monitor origin */
97 int x;
98 int y;
99 /* relative to the bottom right corner, -1 to ignore and use x, y*/
100 int x_right;
101 int y_bottom;
102
103 int monitor;
104 /* this is used when the configured monitor is missing. We keep it so
105 * we can move the toplevel to the right monitor when it becomes
106 * available */
107 int configured_monitor;
108
109 int hide_delay;
110 int unhide_delay;
111 int auto_hide_size;
112 PanelAnimationSpeed animation_speed;
113
114 int snap_tolerance;
115 GtkSettings *gtk_settings;
116
117 PanelState state;
118
119 char *name;
120 char *description;
121
122 guint hide_timeout;
123 guint unhide_timeout;
124
125 GdkRectangle geometry;
126 PanelFrameEdge edges;
127
128 int original_width;
129 int original_height;
130
131 PanelGrabOpType grab_op;
132
133 /* The offset within the panel from which the panel
134 * drag was initiated relative to the screen origin.
135 */
136 int drag_offset_x;
137 int drag_offset_y;
138
139 /* Saved state before for cancelled grab op */
140 int orig_monitor;
141 int orig_x;
142 int orig_y;
143 int orig_x_right;
144 int orig_y_bottom;
145 int orig_size;
146 int orig_orientation;
147
148 /* relative to the monitor origin */
149 int animation_end_x;
150 int animation_end_y;
151 int animation_end_width;
152 int animation_end_height;
153 gint64 animation_start_time; /* monotonic start time in microseconds */
154 GTimeSpan animation_duration_time; /* monotonic duration time in microseconds */
155 guint animation_timeout;
156
157 PanelWidget *panel_widget;
158 PanelFrame *inner_frame;
159 GtkWidget *grid;
160 GtkWidget *hide_button_top;
161 GtkWidget *hide_button_bottom;
162 GtkWidget *hide_button_left;
163 GtkWidget *hide_button_right;
164
165 PanelToplevel *attach_toplevel;
166 gulong attach_toplevel_signals [N_ATTACH_TOPLEVEL_SIGNALS5];
167 GtkWidget *attach_widget;
168 gulong attach_widget_signals [N_ATTACH_WIDGET_SIGNALS5];
169 gint n_autohide_disablers;
170
171 guint auto_hide : 1;
172 guint animate : 1;
173 guint buttons_enabled : 1;
174 guint arrows_enabled : 1;
175
176 /* The co-ordinates are relative to center screen */
177 guint x_centered : 1;
178 guint y_centered : 1;
179
180 /* The panel is not lined up with th screen edge */
181 guint floating : 1;
182
183 /* We are currently animating a hide/show */
184 guint animating : 1;
185
186 /* This is a keyboard initiated grab operation */
187 guint grab_is_keyboard : 1;
188
189 /* The x-y co-ordinates temporarily specify the panel center.
190 * This is used when the panel is rotating, because the width/height
191 * of the toplevel might change, so we need to compute new values for
192 * those. */
193 guint position_centered : 1;
194
195 /* The toplevel is "attached" to another widget */
196 guint attached : 1;
197
198 /* Hidden temporarily because the attach_toplevel was hidden */
199 guint attach_hidden : 1;
200
201 /* More saved grab op state */
202 guint orig_x_centered : 1;
203 guint orig_y_centered : 1;
204
205 /* flag to see if we have already done geometry updating,
206 if not then we're still loading and can ignore many things */
207 guint updated_geometry_initial : 1;
208 /* flag to see if we have done the initial animation */
209 guint initial_animation_done : 1;
210};
211
212enum {
213 HIDE_SIGNAL,
214 UNHIDE_SIGNAL,
215 POPUP_PANEL_MENU_SIGNAL,
216 TOGGLE_EXPAND_SIGNAL,
217 EXPAND_SIGNAL,
218 UNEXPAND_SIGNAL,
219 TOGGLE_HIDDEN_SIGNAL,
220 BEGIN_MOVE_SIGNAL,
221 BEGIN_RESIZE_SIGNAL,
222 LAST_SIGNAL
223};
224
225enum {
226 PROP_0,
227 PROP_NAME,
228 PROP_SETTINGS_PATH,
229 PROP_EXPAND,
230 PROP_ORIENTATION,
231 PROP_SIZE,
232 PROP_X,
233 PROP_X_RIGHT,
234 PROP_X_CENTERED,
235 PROP_Y,
236 PROP_Y_BOTTOM,
237 PROP_Y_CENTERED,
238 PROP_MONITOR,
239 PROP_AUTOHIDE,
240 PROP_HIDE_DELAY,
241 PROP_UNHIDE_DELAY,
242 PROP_AUTOHIDE_SIZE,
243 PROP_ANIMATE,
244 PROP_ANIMATION_SPEED,
245 PROP_BUTTONS_ENABLED,
246 PROP_ARROWS_ENABLED
247};
248
249G_DEFINE_TYPE_WITH_PRIVATE (PanelToplevel, panel_toplevel, GTK_TYPE_WINDOW)static void panel_toplevel_init (PanelToplevel *self); static
void panel_toplevel_class_init (PanelToplevelClass *klass); static
GType panel_toplevel_get_type_once (void); static gpointer panel_toplevel_parent_class
= ((void*)0); static gint PanelToplevel_private_offset; static
void panel_toplevel_class_intern_init (gpointer klass) { panel_toplevel_parent_class
= g_type_class_peek_parent (klass); if (PanelToplevel_private_offset
!= 0) g_type_class_adjust_private_offset (klass, &PanelToplevel_private_offset
); panel_toplevel_class_init ((PanelToplevelClass*) klass); }
__attribute__ ((__unused__)) static inline gpointer panel_toplevel_get_instance_private
(PanelToplevel *self) { return (((gpointer) ((guint8*) (self
) + (glong) (PanelToplevel_private_offset)))); } GType panel_toplevel_get_type
(void) { static GType static_g_define_type_id = 0; if ((__extension__
({ _Static_assert (sizeof *(&static_g_define_type_id) ==
sizeof (gpointer), "Expression evaluates to false"); (void) (
0 ? (gpointer) * (&static_g_define_type_id) : ((void*)0))
; (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter_pointer (
&static_g_define_type_id)); })) ) { GType g_define_type_id
= panel_toplevel_get_type_once (); (__extension__ ({ _Static_assert
(sizeof *(&static_g_define_type_id) == sizeof (gpointer)
, "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id
) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer
((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id
)); })) ; } return static_g_define_type_id; } __attribute__ (
(__noinline__)) static GType panel_toplevel_get_type_once (void
) { GType g_define_type_id = g_type_register_static_simple ((
gtk_window_get_type ()), g_intern_static_string ("PanelToplevel"
), sizeof (PanelToplevelClass), (GClassInitFunc)(void (*)(void
)) panel_toplevel_class_intern_init, sizeof (PanelToplevel), (
GInstanceInitFunc)(void (*)(void)) panel_toplevel_init, (GTypeFlags
) 0); { {{ PanelToplevel_private_offset = g_type_add_instance_private
(g_define_type_id, sizeof (PanelToplevelPrivate)); };} } return
g_define_type_id; }
250
251static guint toplevel_signals[LAST_SIGNAL] = {0};
252static GSList* toplevel_list = NULL((void*)0);
253
254static void panel_toplevel_calculate_animation_end_geometry(PanelToplevel *toplevel);
255
256static void panel_toplevel_update_monitor(PanelToplevel* toplevel);
257static void panel_toplevel_set_monitor_internal(PanelToplevel* toplevel, int monitor, gboolean force_resize);
258
259static void panel_toplevel_drag_threshold_changed (PanelToplevel *toplevel);
260
261static void
262update_style_classes (PanelToplevel *toplevel)
263{
264 GtkStyleContext *context;
265
266 context = gtk_widget_get_style_context (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
267
268 /*ensure the panel BG can always be themed*/
269 /*Without this gtk3.19/20 cannot set the BG color and resetting the bg to system is not immediately applied*/
270 gtk_style_context_add_class(context,"gnome-panel-menu-bar");
271 gtk_style_context_add_class(context,"mate-panel-menu-bar");
272
273 gtk_style_context_remove_class (context, GTK_STYLE_CLASS_HORIZONTAL"horizontal");
274 gtk_style_context_remove_class (context, GTK_STYLE_CLASS_VERTICAL"vertical");
275 gtk_style_context_remove_class (context, GTK_STYLE_CLASS_RIGHT"right");
276 gtk_style_context_remove_class (context, GTK_STYLE_CLASS_LEFT"left");
277 gtk_style_context_remove_class (context, GTK_STYLE_CLASS_TOP"top");
278 gtk_style_context_remove_class (context, GTK_STYLE_CLASS_BOTTOM"bottom");
279
280 switch (toplevel->priv->orientation) {
281 case PANEL_ORIENTATION_TOP:
282 gtk_style_context_add_class (context, GTK_STYLE_CLASS_HORIZONTAL"horizontal");
283 gtk_style_context_add_class (context, GTK_STYLE_CLASS_TOP"top");
284 break;
285
286 case PANEL_ORIENTATION_LEFT:
287 gtk_style_context_add_class (context, GTK_STYLE_CLASS_VERTICAL"vertical");
288 gtk_style_context_add_class (context, GTK_STYLE_CLASS_LEFT"left");
289 break;
290
291 case PANEL_ORIENTATION_BOTTOM:
292 gtk_style_context_add_class (context, GTK_STYLE_CLASS_HORIZONTAL"horizontal");
293 gtk_style_context_add_class (context, GTK_STYLE_CLASS_BOTTOM"bottom");
294 break;
295
296 case PANEL_ORIENTATION_RIGHT:
297 gtk_style_context_add_class (context, GTK_STYLE_CLASS_VERTICAL"vertical");
298 gtk_style_context_add_class (context, GTK_STYLE_CLASS_RIGHT"right");
299 break;
300
301 default:
302 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 302, ((const char*) (__func__)), ((void*)0)); } while (0)
;
303 break;
304 }
305}
306
307GSList* panel_toplevel_list_toplevels(void)
308{
309 return toplevel_list;
310}
311
312/* Is this the last un-attached toplevel? */
313gboolean panel_toplevel_is_last_unattached(PanelToplevel* toplevel)
314{
315 GSList* l;
316
317 if (panel_toplevel_get_is_attached(toplevel))
318 {
319 return FALSE(0);
320 }
321
322 for (l = toplevel_list; l; l = l->next)
323 {
324 PanelToplevel* t = l->data;
325
326 if (t != toplevel && !panel_toplevel_get_is_attached(t))
327 {
328 return FALSE(0);
329 }
330 }
331
332 return TRUE(!(0));
333}
334
335static void panel_toplevel_get_monitor_geometry(PanelToplevel* toplevel, GdkRectangle *geom)
336{
337 g_return_if_fail(PANEL_IS_TOPLEVEL(toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL(toplevel)"); return; } } while
(0)
;
338 g_return_if_fail(geom)do { if ((geom)) { } else { g_return_if_fail_warning (((gchar
*) 0), ((const char*) (__func__)), "geom"); return; } } while
(0)
;
339
340 geom->x = panel_multimonitor_x(toplevel->priv->monitor);
341 geom->y = panel_multimonitor_y(toplevel->priv->monitor);
342 geom->width = panel_multimonitor_width(toplevel->priv->monitor);
343 geom->height = panel_multimonitor_height(toplevel->priv->monitor);
344}
345
346static GdkCursorType panel_toplevel_grab_op_cursor(PanelToplevel* toplevel, PanelGrabOpType grab_op)
347{
348 GdkCursorType retval = -1;
349
350 switch (grab_op) {
351 case PANEL_GRAB_OP_MOVE:
352 case PANEL_GRAB_OP_RESIZE:
353 if (toplevel->priv->grab_is_keyboard)
354 retval = GDK_CROSS;
355 else
356 retval = GDK_FLEUR;
357 break;
358 case PANEL_GRAB_OP_RESIZE_UP:
359 retval = GDK_TOP_SIDE;
360 break;
361 case PANEL_GRAB_OP_RESIZE_DOWN:
362 retval = GDK_BOTTOM_SIDE;
363 break;
364 case PANEL_GRAB_OP_RESIZE_LEFT:
365 retval = GDK_LEFT_SIDE;
366 break;
367 case PANEL_GRAB_OP_RESIZE_RIGHT:
368 retval = GDK_RIGHT_SIDE;
369 break;
370 default:
371 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 371, ((const char*) (__func__)), ((void*)0)); } while (0)
;
372 break;
373 }
374
375 return retval;
376}
377
378#ifdef HAVE_X111
379static void panel_toplevel_init_resize_drag_offsets(PanelToplevel* toplevel, PanelGrabOpType grab_op)
380{
381 g_assert (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel))))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((gtk_widget_get_display (((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((toplevel)), ((gtk_widget_get_type ()))))
))))); GType __t = ((gdk_x11_display_get_type())); gboolean __r
; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))) ; else
g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c", 381
, ((const char*) (__func__)), "GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel)))"
); } while (0)
;
382
383 toplevel->priv->drag_offset_x = 0;
384 toplevel->priv->drag_offset_y = 0;
385
386 switch (grab_op) {
387 case PANEL_GRAB_OP_RESIZE_DOWN:
388 toplevel->priv->drag_offset_y = toplevel->priv->geometry.y;
389 break;
390 case PANEL_GRAB_OP_RESIZE_UP:
391 toplevel->priv->drag_offset_y =
392 toplevel->priv->geometry.y + toplevel->priv->geometry.height;
393 break;
394 case PANEL_GRAB_OP_RESIZE_RIGHT:
395 toplevel->priv->drag_offset_x = toplevel->priv->geometry.x;
396 break;
397 case PANEL_GRAB_OP_RESIZE_LEFT:
398 toplevel->priv->drag_offset_x =
399 toplevel->priv->geometry.x + toplevel->priv->geometry.width;
400 break;
401 default:
402 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 402, ((const char*) (__func__)), ((void*)0)); } while (0)
;
403 break;
404 }
405}
406
407static void panel_toplevel_warp_pointer(PanelToplevel* toplevel)
408{
409 GtkWidget *widget;
410 GdkRectangle geometry;
411 int x, y;
412
413 widget = GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
;
414 g_return_if_fail (GDK_IS_X11_DISPLAY (gtk_widget_get_display (widget)))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((gtk_widget_get_display (widget))); GType __t = ((gdk_x11_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0
), ((const char*) (__func__)), "GDK_IS_X11_DISPLAY (gtk_widget_get_display (widget))"
); return; } } while (0)
;
415
416 geometry = toplevel->priv->geometry;
417
418 x = y = 0;
419
420 switch (toplevel->priv->grab_op) {
421 case PANEL_GRAB_OP_MOVE:
422 case PANEL_GRAB_OP_RESIZE:
423 x = (geometry.width / 2);
424 y = (geometry.height / 2);
425 break;
426 case PANEL_GRAB_OP_RESIZE_UP:
427 x = (geometry.width / 2);
428 break;
429 case PANEL_GRAB_OP_RESIZE_DOWN:
430 x = (geometry.width / 2);
431 y = geometry.height;
432 break;
433 case PANEL_GRAB_OP_RESIZE_LEFT:
434 y = (geometry.height / 2);
435 break;
436 case PANEL_GRAB_OP_RESIZE_RIGHT:
437 x = geometry.width;
438 y = (geometry.height / 2);
439 break;
440 default:
441 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 441, ((const char*) (__func__)), ((void*)0)); } while (0)
;
442 break;
443 }
444
445 if (toplevel->priv->grab_op == PANEL_GRAB_OP_MOVE ||
446 toplevel->priv->grab_op == PANEL_GRAB_OP_RESIZE) {
447 toplevel->priv->drag_offset_x = x;
448 toplevel->priv->drag_offset_y = y;
449 } else
450 panel_toplevel_init_resize_drag_offsets (toplevel, toplevel->priv->grab_op);
451
452 panel_warp_pointer (gtk_widget_get_window (widget), x, y);
453}
454#endif /* HAVE_X11 */
455
456static void panel_toplevel_begin_attached_move(PanelToplevel* toplevel, gboolean is_keyboard, guint32 time_)
457{
458 PanelWidget *attached_panel_widget;
459
460 attached_panel_widget = panel_toplevel_get_panel_widget (toplevel->priv->attach_toplevel);
461
462 panel_widget_applet_drag_start (attached_panel_widget,
463 toplevel->priv->attach_widget,
464 is_keyboard ? PW_DRAG_OFF_CENTER-2 : PW_DRAG_OFF_CURSOR-1,
465 time_);
466}
467
468static void panel_toplevel_begin_grab_op(PanelToplevel* toplevel, PanelGrabOpType op_type, gboolean grab_keyboard, guint32 time_)
469{
470 GtkWidget *widget;
471 GdkWindow *window;
472 GdkCursorType cursor_type;
473 GdkCursor *cursor;
474 GdkDisplay *display;
475 GdkSeat *seat;
476 GdkSeatCapabilities capabilities;
477
478 if (toplevel->priv->state != PANEL_STATE_NORMAL ||
479 toplevel->priv->grab_op != PANEL_GRAB_OP_NONE)
480 return;
481
482 if (panel_lockdown_get_locked_down ())
483 return;
484
485 /* If any of the position/orientation are not writable,
486 then we can't really move freely */
487 if (op_type == PANEL_GRAB_OP_MOVE &&
488 ! panel_profile_can_be_moved_freely (toplevel))
489 return;
490
491 /* If size is not writable, then we can't resize */
492 if ((op_type == PANEL_GRAB_OP_RESIZE ||
493 op_type == PANEL_GRAB_OP_RESIZE_UP ||
494 op_type == PANEL_GRAB_OP_RESIZE_DOWN ||
495 op_type == PANEL_GRAB_OP_RESIZE_LEFT ||
496 op_type == PANEL_GRAB_OP_RESIZE_RIGHT) &&
497 ! panel_profile_key_is_writable (toplevel, PANEL_TOPLEVEL_SIZE_KEY"size"))
498 return;
499
500 if (toplevel->priv->attached && op_type == PANEL_GRAB_OP_MOVE) {
501 panel_toplevel_begin_attached_move (toplevel, grab_keyboard, time_);
502 return;
503 }
504
505 widget = GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
;
506 window = gtk_widget_get_window (widget);
507
508 toplevel->priv->grab_op = op_type;
509 toplevel->priv->grab_is_keyboard = (grab_keyboard != FALSE(0));
510
511 toplevel->priv->orig_monitor = toplevel->priv->monitor;
512 toplevel->priv->orig_x = toplevel->priv->x;
513 toplevel->priv->orig_x_right = toplevel->priv->x_right;
514 toplevel->priv->orig_x_centered = toplevel->priv->x_centered;
515 toplevel->priv->orig_y = toplevel->priv->y;
516 toplevel->priv->orig_y_bottom = toplevel->priv->y_bottom;
517 toplevel->priv->orig_y_centered = toplevel->priv->y_centered;
518 toplevel->priv->orig_size = toplevel->priv->size;
519 toplevel->priv->orig_orientation = toplevel->priv->orientation;
520
521 gtk_grab_add (widget);
522
523#ifdef HAVE_X111
524 if (GDK_IS_X11_DISPLAY (gtk_widget_get_display (widget))(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gtk_widget_get_display (widget))); GType __t = ((gdk_x11_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
&&
525 toplevel->priv->grab_is_keyboard) {
526 panel_toplevel_warp_pointer (toplevel);
527 }
528#endif /* HAVE_X11 */
529
530 cursor_type = panel_toplevel_grab_op_cursor (
531 toplevel, toplevel->priv->grab_op);
532
533 cursor = gdk_cursor_new_for_display (gdk_display_get_default (),
534 cursor_type);
535 display = gdk_window_get_display (window);
536 seat = gdk_display_get_default_seat (display);
537 capabilities = GDK_SEAT_CAPABILITY_POINTER;
538 if (grab_keyboard)
539 capabilities |= GDK_SEAT_CAPABILITY_KEYBOARD;
540
541 gdk_seat_grab (seat, window, capabilities, FALSE(0), cursor,
542 NULL((void*)0), NULL((void*)0), NULL((void*)0));
543
544 g_object_unref (cursor);
545}
546
547static void panel_toplevel_end_grab_op (PanelToplevel* toplevel, guint32 time_)
548{
549 GtkWidget *widget;
550 GdkDisplay *display;
551 GdkSeat *seat;
552
553 g_return_if_fail (toplevel->priv->grab_op != PANEL_GRAB_OP_NONE)do { if ((toplevel->priv->grab_op != PANEL_GRAB_OP_NONE
)) { } else { g_return_if_fail_warning (((gchar*) 0), ((const
char*) (__func__)), "toplevel->priv->grab_op != PANEL_GRAB_OP_NONE"
); return; } } while (0)
;
554
555 widget = GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
;
556
557 toplevel->priv->grab_op = PANEL_GRAB_OP_NONE;
558 toplevel->priv->grab_is_keyboard = FALSE(0);
559
560 gtk_grab_remove (widget);
561
562 display = gtk_widget_get_display (widget);
563 seat = gdk_display_get_default_seat (display);
564
565 gdk_seat_ungrab (seat);
566}
567
568static void panel_toplevel_cancel_grab_op(PanelToplevel* toplevel, guint32 time_)
569{
570 panel_toplevel_set_orientation (toplevel, toplevel->priv->orig_orientation);
571 panel_toplevel_set_monitor (toplevel, toplevel->priv->orig_monitor);
572 panel_toplevel_set_size (toplevel, toplevel->priv->orig_size);
573 panel_toplevel_set_x (toplevel,
574 toplevel->priv->orig_x,
575 toplevel->priv->orig_x_right,
576 toplevel->priv->orig_x_centered);
577 panel_toplevel_set_y (toplevel,
578 toplevel->priv->orig_y,
579 toplevel->priv->orig_y_bottom,
580 toplevel->priv->orig_y_centered);
581}
582
583static void panel_toplevel_resize_to_pointer(PanelToplevel* toplevel, int x, int y)
584{
585 int new_size;
586 int new_x, new_y;
587 int new_x_right, new_y_bottom;
588 int new_x_centered, new_y_centered;
589 GdkRectangle monitor_geom;
590
591 new_size = toplevel->priv->size;
Value stored to 'new_size' is never read
592 new_x = toplevel->priv->x;
593 new_y = toplevel->priv->y;
594 new_x_right = toplevel->priv->x_right;
595 new_y_bottom = toplevel->priv->y_bottom;
596 new_x_centered = toplevel->priv->x_centered;
597 new_y_centered = toplevel->priv->y_centered;
598
599 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
600
601 switch (toplevel->priv->grab_op) {
602 case PANEL_GRAB_OP_RESIZE_UP:
603 new_size = toplevel->priv->drag_offset_y - y;
604 new_size = CLAMP (new_size, 0, monitor_geom.height / 4)(((new_size) > (monitor_geom.height / 4)) ? (monitor_geom.
height / 4) : (((new_size) < (0)) ? (0) : (new_size)))
;
605 new_y -= (new_size - toplevel->priv->size);
606 if (!toplevel->priv->y_centered && (new_y + new_size / 2) > monitor_geom.height / 2)
607 new_y_bottom = monitor_geom.height - (new_y + new_size);
608 else
609 new_y_bottom = -1;
610 break;
611 case PANEL_GRAB_OP_RESIZE_DOWN:
612 new_size = y - toplevel->priv->drag_offset_y;
613 new_size = CLAMP (new_size, 0, monitor_geom.height / 4)(((new_size) > (monitor_geom.height / 4)) ? (monitor_geom.
height / 4) : (((new_size) < (0)) ? (0) : (new_size)))
;
614 if (!toplevel->priv->y_centered && (new_y + new_size / 2) > monitor_geom.height / 2)
615 new_y_bottom = monitor_geom.height - (new_y + new_size);
616 else
617 new_y_bottom = -1;
618 break;
619 case PANEL_GRAB_OP_RESIZE_LEFT:
620 new_size = toplevel->priv->drag_offset_x - x;
621 new_size = CLAMP (new_size, 0, monitor_geom.width / 4)(((new_size) > (monitor_geom.width / 4)) ? (monitor_geom.width
/ 4) : (((new_size) < (0)) ? (0) : (new_size)))
;
622 new_x -= (new_size - toplevel->priv->size);
623 if (!toplevel->priv->x_centered && (new_x + new_size / 2) > monitor_geom.width / 2)
624 new_x_right = monitor_geom.width - (new_x + new_size);
625 else
626 new_x_right = -1;
627 break;
628 case PANEL_GRAB_OP_RESIZE_RIGHT:
629 new_size = x - toplevel->priv->drag_offset_x;
630 new_size = CLAMP (new_size, 0, monitor_geom.width / 4)(((new_size) > (monitor_geom.width / 4)) ? (monitor_geom.width
/ 4) : (((new_size) < (0)) ? (0) : (new_size)))
;
631 if (!toplevel->priv->x_centered && (new_x + new_size / 2) > monitor_geom.width / 2)
632 new_x_right = monitor_geom.width - (new_x + new_size);
633 else
634 new_x_right = -1;
635 break;
636 default:
637 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 637, ((const char*) (__func__)), ((void*)0)); } while (0)
;
638 break;
639 }
640
641 if (new_size == 0)
642 return;
643
644 panel_toplevel_set_x (toplevel, new_x, new_x_right, new_x_centered);
645 panel_toplevel_set_y (toplevel, new_y, new_y_bottom, new_y_centered);
646 panel_toplevel_set_size (toplevel, new_size);
647}
648
649/* this is called for expanded panels that are dragged around */
650static void panel_toplevel_calc_new_orientation(PanelToplevel* toplevel, int pointer_x, int pointer_y)
651{
652 PanelOrientation new_orientation;
653 int hborder, vborder;
654 int monitor;
655 int monitor_width, monitor_height;
656 int new_x, new_y;
657
658 monitor = panel_multimonitor_get_monitor_at_point (pointer_x, pointer_y);
659
660 if (toplevel->priv->geometry.height < toplevel->priv->geometry.width)
661 vborder = hborder = (3 * toplevel->priv->geometry.height) >> 1;
662 else
663 vborder = hborder = (3 * toplevel->priv->geometry.width) >> 1;
664
665 new_x = pointer_x - panel_multimonitor_x (monitor);
666 new_y = pointer_y - panel_multimonitor_y (monitor);
667 monitor_width = panel_multimonitor_width (monitor);
668 monitor_height = panel_multimonitor_height (monitor);
669
670 new_orientation = toplevel->priv->orientation;
671
672 switch (toplevel->priv->orientation) {
673 case PANEL_ORIENTATION_TOP:
674 if (new_y > (monitor_height - hborder))
675 new_orientation = PANEL_ORIENTATION_BOTTOM;
676
677 else if (new_y > hborder) {
678 if (new_x > (monitor_width - vborder))
679 new_orientation = PANEL_ORIENTATION_RIGHT;
680 else if (new_x < vborder)
681 new_orientation = PANEL_ORIENTATION_LEFT;
682 }
683 break;
684 case PANEL_ORIENTATION_BOTTOM:
685 if (new_y < hborder)
686 new_orientation = PANEL_ORIENTATION_TOP;
687
688 else if (new_y < (monitor_height - hborder)) {
689 if (new_x > (monitor_width - vborder))
690 new_orientation = PANEL_ORIENTATION_RIGHT;
691 else if (new_x < vborder)
692 new_orientation = PANEL_ORIENTATION_LEFT;
693 }
694 break;
695 case PANEL_ORIENTATION_LEFT:
696 if (new_x > (monitor_width - vborder))
697 new_orientation = PANEL_ORIENTATION_RIGHT;
698
699 else if (new_x > vborder) {
700 if (new_y > (monitor_height - hborder))
701 new_orientation = PANEL_ORIENTATION_BOTTOM;
702 else if (new_y < hborder)
703 new_orientation = PANEL_ORIENTATION_TOP;
704 }
705 break;
706 case PANEL_ORIENTATION_RIGHT:
707 if (new_x < vborder)
708 new_orientation = PANEL_ORIENTATION_LEFT;
709
710 else if (new_x < (monitor_width - vborder)) {
711 if (new_y > (monitor_height - hborder))
712 new_orientation = PANEL_ORIENTATION_BOTTOM;
713 else if (new_y < hborder)
714 new_orientation = PANEL_ORIENTATION_TOP;
715 }
716 break;
717 default:
718 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 718, ((const char*) (__func__)), ((void*)0)); } while (0)
;
719 break;
720 }
721
722 panel_toplevel_set_monitor (toplevel, monitor);
723 panel_toplevel_set_orientation (toplevel, new_orientation);
724}
725
726static void panel_toplevel_move_to(PanelToplevel* toplevel, int new_x, int new_y)
727{
728 PanelOrientation new_orientation;
729 gboolean x_centered, y_centered;
730 GdkPoint display_min, display_max;
731 GdkRectangle monitor_geom;
732 int width, height;
733 int new_monitor;
734 int x, y, x_right, y_bottom;
735 int snap_tolerance;
736
737 panel_multimonitor_get_bounds (&display_min, &display_max);
738
739 width = toplevel->priv->geometry.width;
740 height = toplevel->priv->geometry.height;
741
742 snap_tolerance = toplevel->priv->snap_tolerance;
743
744 new_x = CLAMP (new_x, 0, display_max.x - width)(((new_x) > (display_max.x - width)) ? (display_max.x - width
) : (((new_x) < (0)) ? (0) : (new_x)))
;
745 new_y = CLAMP (new_y, 0, display_max.y - height)(((new_y) > (display_max.y - height)) ? (display_max.y - height
) : (((new_y) < (0)) ? (0) : (new_y)))
;
746
747 new_orientation = toplevel->priv->orientation;
748
749 if (new_x <= (display_min.x + snap_tolerance) &&
750 toplevel->priv->orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT))
751 new_orientation = PANEL_ORIENTATION_LEFT;
752
753 else if ((new_x + width) >= (display_max.x - snap_tolerance) &&
754 toplevel->priv->orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT))
755 new_orientation = PANEL_ORIENTATION_RIGHT;
756
757 if (new_y <= (display_min.y + snap_tolerance) &&
758 toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM))
759 new_orientation = PANEL_ORIENTATION_TOP;
760
761 else if ((new_y + height) >= (display_max.y - snap_tolerance) &&
762 toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM))
763 new_orientation = PANEL_ORIENTATION_BOTTOM;
764
765 new_monitor = panel_multimonitor_get_monitor_at_point (new_x, new_y);
766
767 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
768
769 x_centered = toplevel->priv->x_centered;
770 y_centered = toplevel->priv->y_centered;
771
772 x = new_x - panel_multimonitor_x (new_monitor);
773 y = new_y - panel_multimonitor_y (new_monitor);
774
775 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)) {
776 if (new_y <= display_min.y + snap_tolerance ||
777 new_y + height >= display_max.y - snap_tolerance)
778 x_centered = abs (x - ((monitor_geom.width - width) / 2))
779 <= snap_tolerance;
780 else
781 x_centered = FALSE(0);
782 } else {
783 if (new_x <= display_min.x + snap_tolerance ||
784 new_x + width >= display_max.x - snap_tolerance)
785 y_centered = abs (y - ((monitor_geom.height - height) / 2))
786 <= snap_tolerance;
787 else
788 y_centered = FALSE(0);
789 }
790
791 if (x_centered)
792 x = (monitor_geom.width - width) / 2;
793 if (y_centered)
794 y = (monitor_geom.height - height) / 2;
795
796 if (!x_centered && (x + width / 2) > monitor_geom.width / 2)
797 x_right = monitor_geom.width - (x + width);
798 else
799 x_right = -1;
800
801 if (!y_centered && (y + height / 2) > monitor_geom.height / 2)
802 y_bottom = monitor_geom.height - (y + height);
803 else
804 y_bottom = -1;
805
806 panel_toplevel_set_monitor (toplevel, new_monitor);
807 panel_toplevel_set_orientation (toplevel, new_orientation);
808 panel_toplevel_set_x (toplevel, x, x_right, x_centered);
809 panel_toplevel_set_y (toplevel, y, y_bottom, y_centered);
810}
811
812static void panel_toplevel_move_to_pointer(PanelToplevel* toplevel, int pointer_x, int pointer_y)
813{
814 int new_x, new_y;
815
816 new_x = pointer_x - toplevel->priv->drag_offset_x;
817 new_y = pointer_y - toplevel->priv->drag_offset_y;
818
819 panel_toplevel_move_to (toplevel, new_x, new_y);
820}
821
822static void panel_toplevel_rotate_to_pointer(PanelToplevel* toplevel, int pointer_x, int pointer_y)
823{
824 int x_diff, y_diff;
825 int x, y;
826 int snap_tolerance;
827
828 x = toplevel->priv->geometry.x;
829 y = toplevel->priv->geometry.y;
830 snap_tolerance = toplevel->priv->snap_tolerance;
831
832 x_diff = pointer_x - (x + toplevel->priv->geometry.width / 2);
833 y_diff = pointer_y - (y + toplevel->priv->geometry.height / 2);
834
835 if (((-y_diff > x_diff + snap_tolerance) && x_diff > 0 && y_diff < 0) ||
836 (( y_diff < x_diff + snap_tolerance) && x_diff < 0 && y_diff < 0))
837 panel_toplevel_set_orientation (toplevel, PANEL_ORIENTATION_RIGHT);
838
839 else if (((-x_diff < y_diff - snap_tolerance) && x_diff > 0 && y_diff < 0) ||
840 (( x_diff > y_diff - snap_tolerance) && x_diff > 0 && y_diff > 0))
841 panel_toplevel_set_orientation (toplevel, PANEL_ORIENTATION_BOTTOM);
842
843 else if ((( y_diff > x_diff + snap_tolerance) && x_diff > 0 && y_diff > 0) ||
844 ((-y_diff < x_diff + snap_tolerance) && x_diff < 0 && y_diff > 0))
845 panel_toplevel_set_orientation (toplevel, PANEL_ORIENTATION_LEFT);
846
847 else if (((-x_diff > y_diff - snap_tolerance) && x_diff < 0 && y_diff > 0) ||
848 (( x_diff < y_diff - snap_tolerance) && x_diff < 0 && y_diff < 0))
849 panel_toplevel_set_orientation (toplevel, PANEL_ORIENTATION_TOP);
850}
851
852#ifdef HAVE_X111
853static gboolean panel_toplevel_warp_pointer_increment(PanelToplevel* toplevel, int keyval, int increment)
854{
855 GdkScreen *screen;
856 GdkWindow *root_window;
857 GdkDevice *device;
858 int new_x, new_y;
859
860 screen = gtk_window_get_screen (GTK_WINDOW (toplevel)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_window_get_type ()))))))
);
861 g_return_val_if_fail (GDK_IS_X11_SCREEN (screen), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((screen)); GType __t = ((gdk_x11_screen_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "GDK_IS_X11_SCREEN (screen)"); return ((0)); }
} while (0)
;
862 root_window = gdk_screen_get_root_window (screen);
863 device = gdk_seat_get_pointer (gdk_display_get_default_seat (gtk_widget_get_display (GTK_WIDGET(root_window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((root_window)), ((gtk_widget_get_type ()))))))
)));
864 gdk_window_get_device_position (gtk_widget_get_window (GTK_WIDGET (root_window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((root_window)), ((gtk_widget_get_type ()))))))
), device, &new_x, &new_y, NULL((void*)0));
865
866 switch (keyval) {
867 case GDK_KEY_Up0xff52:
868 case GDK_KEY_KP_Up0xff97:
869 new_y -= increment;
870 break;
871 case GDK_KEY_Left0xff51:
872 case GDK_KEY_KP_Left0xff96:
873 new_x -= increment;
874 break;
875 case GDK_KEY_Down0xff54:
876 case GDK_KEY_KP_Down0xff99:
877 new_y += increment;
878 break;
879 case GDK_KEY_Right0xff53:
880 case GDK_KEY_KP_Right0xff98:
881 new_x += increment;
882 break;
883 default:
884 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 884, ((const char*) (__func__)), ((void*)0)); } while (0)
;
885 return FALSE(0);
886 }
887
888 panel_warp_pointer (root_window, new_x, new_y);
889
890 return TRUE(!(0));
891}
892
893static gboolean panel_toplevel_move_keyboard_floating(PanelToplevel* toplevel, GdkEventKey* event)
894{
895#define SMALL_INCREMENT 1
896#define NORMAL_INCREMENT 10
897
898 int increment = NORMAL_INCREMENT;
899
900 if ((event->state & gtk_accelerator_get_default_mod_mask ()) == GDK_SHIFT_MASK)
901 increment = SMALL_INCREMENT;
902
903 return panel_toplevel_warp_pointer_increment (
904 toplevel, event->keyval, increment);
905
906#undef SMALL_INCREMENT
907#undef NORMAL_INCREMENT
908}
909
910#endif /* HAVE_X11 */
911
912static gboolean panel_toplevel_move_keyboard_expanded(PanelToplevel* toplevel, GdkEventKey* event)
913{
914 PanelOrientation new_orientation;
915
916 switch (event->keyval) {
917 case GDK_KEY_Up0xff52:
918 case GDK_KEY_KP_Up0xff97:
919 new_orientation = PANEL_ORIENTATION_TOP;
920 break;
921 case GDK_KEY_Left0xff51:
922 case GDK_KEY_KP_Left0xff96:
923 new_orientation = PANEL_ORIENTATION_LEFT;
924 break;
925 case GDK_KEY_Down0xff54:
926 case GDK_KEY_KP_Down0xff99:
927 new_orientation = PANEL_ORIENTATION_BOTTOM;
928 break;
929 case GDK_KEY_Right0xff53:
930 case GDK_KEY_KP_Right0xff98:
931 new_orientation = PANEL_ORIENTATION_RIGHT;
932 break;
933 default:
934 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 934, ((const char*) (__func__)), ((void*)0)); } while (0)
;
935 return FALSE(0);
936 }
937
938 panel_toplevel_set_orientation (toplevel, new_orientation);
939
940 return TRUE(!(0));
941}
942
943static gboolean panel_toplevel_initial_resize_keypress(PanelToplevel* toplevel, GdkEventKey* event)
944{
945 PanelGrabOpType grab_op;
946
947 switch (event->keyval) {
948 case GDK_KEY_Up0xff52:
949 case GDK_KEY_KP_Up0xff97:
950 if (!(toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)))
951 return FALSE(0);
952 grab_op = PANEL_GRAB_OP_RESIZE_UP;
953 break;
954 case GDK_KEY_Left0xff51:
955 case GDK_KEY_KP_Left0xff96:
956 if (!(toplevel->priv->orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT)))
957 return FALSE(0);
958 grab_op = PANEL_GRAB_OP_RESIZE_LEFT;
959 break;
960 case GDK_KEY_Down0xff54:
961 case GDK_KEY_KP_Down0xff99:
962 if (!(toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)))
963 return FALSE(0);
964 grab_op = PANEL_GRAB_OP_RESIZE_DOWN;
965 break;
966 case GDK_KEY_Right0xff53:
967 case GDK_KEY_KP_Right0xff98:
968 if (!(toplevel->priv->orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT)))
969 return FALSE(0);
970 grab_op = PANEL_GRAB_OP_RESIZE_RIGHT;
971 break;
972 default:
973 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 973, ((const char*) (__func__)), ((void*)0)); } while (0)
;
974 return FALSE(0);
975 }
976
977 panel_toplevel_end_grab_op (toplevel, event->time);
978 panel_toplevel_begin_grab_op (toplevel, grab_op, TRUE(!(0)), event->time);
979
980 return TRUE(!(0));
981}
982
983static gboolean panel_toplevel_handle_grab_op_key_event(PanelToplevel* toplevel, GdkEventKey* event)
984{
985 gboolean retval = FALSE(0);
986
987 switch (event->keyval) {
988 case GDK_KEY_Up0xff52:
989 case GDK_KEY_KP_Up0xff97:
990 case GDK_KEY_Left0xff51:
991 case GDK_KEY_KP_Left0xff96:
992 case GDK_KEY_Down0xff54:
993 case GDK_KEY_KP_Down0xff99:
994 case GDK_KEY_Right0xff53:
995 case GDK_KEY_KP_Right0xff98:
996 switch (toplevel->priv->grab_op) {
997 case PANEL_GRAB_OP_MOVE:
998 if (toplevel->priv->expand) {
999 retval = panel_toplevel_move_keyboard_expanded (
1000 toplevel, event);
1001 }
1002#ifdef HAVE_X111
1003 else if (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel)))(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gtk_widget_get_display (((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((toplevel)), ((gtk_widget_get_type ()))))
))))); GType __t = ((gdk_x11_display_get_type())); gboolean __r
; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
) {
1004 retval = panel_toplevel_move_keyboard_floating (
1005 toplevel, event);
1006 }
1007#endif /* HAVE_X11 */
1008 break;
1009 case PANEL_GRAB_OP_RESIZE:
1010 retval = panel_toplevel_initial_resize_keypress (toplevel, event);
1011 break;
1012 case PANEL_GRAB_OP_RESIZE_UP:
1013 case PANEL_GRAB_OP_RESIZE_DOWN:
1014 case PANEL_GRAB_OP_RESIZE_LEFT:
1015 case PANEL_GRAB_OP_RESIZE_RIGHT:
1016#ifdef HAVE_X111
1017 if (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel)))(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gtk_widget_get_display (((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((toplevel)), ((gtk_widget_get_type ()))))
))))); GType __t = ((gdk_x11_display_get_type())); gboolean __r
; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
)
1018 retval = panel_toplevel_warp_pointer_increment (toplevel, event->keyval, 1);
1019#endif /* HAVE_X11 */
1020 break;
1021 default:
1022 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 1022, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1023 break;
1024 }
1025 break;
1026 case GDK_KEY_Escape0xff1b:
1027 panel_toplevel_cancel_grab_op (toplevel, event->time);
1028 case GDK_KEY_Return0xff0d: /* drop through*/
1029 case GDK_KEY_KP_Enter0xff8d:
1030 case GDK_KEY_space0x020:
1031 case GDK_KEY_KP_Space0xff80:
1032 panel_toplevel_end_grab_op (toplevel, event->time);
1033 retval = TRUE(!(0));
1034 default: /* drop through*/
1035 break;
1036 }
1037
1038 return retval;
1039}
1040
1041static gboolean panel_toplevel_handle_grab_op_motion_event(PanelToplevel* toplevel, GdkEventMotion* event)
1042{
1043 switch (toplevel->priv->grab_op) {
1044 case PANEL_GRAB_OP_MOVE:
1045 if (toplevel->priv->expand)
1046 panel_toplevel_calc_new_orientation (
1047 toplevel, event->x_root, event->y_root);
1048
1049 else if ((event->state & gtk_accelerator_get_default_mod_mask ()) == GDK_CONTROL_MASK)
1050 panel_toplevel_rotate_to_pointer (
1051 toplevel, event->x_root, event->y_root);
1052
1053 else
1054 panel_toplevel_move_to_pointer (
1055 toplevel, event->x_root, event->y_root);
1056 return TRUE(!(0));
1057 case PANEL_GRAB_OP_RESIZE_UP:
1058 case PANEL_GRAB_OP_RESIZE_DOWN:
1059 case PANEL_GRAB_OP_RESIZE_LEFT:
1060 case PANEL_GRAB_OP_RESIZE_RIGHT:
1061 panel_toplevel_resize_to_pointer (toplevel, event->x_root, event->y_root);
1062 return TRUE(!(0));
1063 default:
1064 break;
1065 }
1066
1067 return FALSE(0);
1068}
1069
1070static void panel_toplevel_calc_floating(PanelToplevel* toplevel)
1071{
1072 GdkRectangle monitor_geom;
1073 GdkPoint position_on_monitor;
1074 int snap_tolerance;
1075
1076 if (toplevel->priv->expand) {
1077 toplevel->priv->floating = FALSE(0);
1078 return;
1079 }
1080
1081 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
1082
1083 if (toplevel->priv->x_right == -1)
1084 position_on_monitor.x = toplevel->priv->x;
1085 else
1086 position_on_monitor.x = monitor_geom.width - (toplevel->priv->x_right + toplevel->priv->geometry.width);
1087 if (toplevel->priv->y_bottom == -1)
1088 position_on_monitor.y = toplevel->priv->y;
1089 else
1090 position_on_monitor.y = monitor_geom.height - (toplevel->priv->y_bottom + toplevel->priv->geometry.height);
1091
1092 snap_tolerance = toplevel->priv->snap_tolerance;
1093
1094 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM))
1095 toplevel->priv->floating =
1096 (position_on_monitor.y > snap_tolerance) &&
1097 (position_on_monitor.y < (monitor_geom.height - toplevel->priv->geometry.height - snap_tolerance));
1098 else
1099 toplevel->priv->floating =
1100 (position_on_monitor.x > snap_tolerance) &&
1101 (position_on_monitor.x < (monitor_geom.width - toplevel->priv->geometry.width - snap_tolerance));
1102}
1103
1104void panel_toplevel_push_autohide_disabler(PanelToplevel* toplevel)
1105{
1106 g_return_if_fail (toplevel != NULL)do { if ((toplevel != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "toplevel != NULL"
); return; } } while (0)
;
1107
1108 if (!toplevel->priv->n_autohide_disablers++)
1109 panel_toplevel_queue_auto_hide (toplevel);
1110}
1111
1112void panel_toplevel_pop_autohide_disabler(PanelToplevel* toplevel)
1113{
1114 g_return_if_fail (toplevel != NULL)do { if ((toplevel != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "toplevel != NULL"
); return; } } while (0)
;
1115 g_return_if_fail (toplevel->priv->n_autohide_disablers > 0)do { if ((toplevel->priv->n_autohide_disablers > 0))
{ } else { g_return_if_fail_warning (((gchar*) 0), ((const char
*) (__func__)), "toplevel->priv->n_autohide_disablers > 0"
); return; } } while (0)
;
1116
1117 if (!--toplevel->priv->n_autohide_disablers)
1118 panel_toplevel_queue_auto_hide (toplevel);
1119}
1120
1121static gboolean panel_toplevel_get_autohide_disabled(PanelToplevel* toplevel)
1122{
1123 return toplevel->priv->n_autohide_disablers > 0 ? TRUE(!(0)) : FALSE(0);
1124}
1125
1126static gboolean panel_toplevel_hide_button_event(PanelToplevel* toplevel, GdkEventButton* event, GtkButton* button)
1127{
1128 if (event->button == 1)
1129 return FALSE(0);
1130
1131 return gtk_widget_event (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
, (GdkEvent *) event);
1132}
1133
1134static void panel_toplevel_hide_button_clicked(PanelToplevel* toplevel, GtkButton* button)
1135{
1136 GtkArrowType arrow_type;
1137 gboolean ltr;
1138
1139 if (toplevel->priv->animating ||
1140 toplevel->priv->state == PANEL_STATE_AUTO_HIDDEN)
1141 return;
1142
1143 ltr = gtk_widget_get_direction (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
) == GTK_TEXT_DIR_LTR;
1144 arrow_type = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button), "arrow-type"))((gint) (glong) (g_object_get_data (((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((button)), (((GType) ((20) << (2)))
))))), "arrow-type")))
;
1145
1146 if (toplevel->priv->state == PANEL_STATE_NORMAL) {
1147 GtkDirectionType direction;
1148
1149 switch (arrow_type) {
1150 case GTK_ARROW_UP:
1151 direction = GTK_DIR_UP;
1152 break;
1153 case GTK_ARROW_DOWN:
1154 direction = GTK_DIR_DOWN;
1155 break;
1156 case GTK_ARROW_LEFT:
1157 direction = ltr ? GTK_DIR_LEFT : GTK_DIR_RIGHT;
1158 break;
1159 case GTK_ARROW_RIGHT:
1160 direction = ltr ? GTK_DIR_RIGHT : GTK_DIR_LEFT;
1161 break;
1162 default:
1163 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 1163, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1164 break;
1165 }
1166
1167 panel_toplevel_hide (toplevel, FALSE(0), (gint) direction);
1168 } else
1169 panel_toplevel_unhide (toplevel);
1170}
1171
1172static void
1173set_arrow_type (GtkImage *image,
1174 GtkArrowType arrow_type)
1175{
1176 switch (arrow_type)
1177 {
1178 case GTK_ARROW_NONE:
1179 case GTK_ARROW_DOWN:
1180 gtk_image_set_from_icon_name (image, "pan-down-symbolic", GTK_ICON_SIZE_BUTTON);
1181 break;
1182 case GTK_ARROW_UP:
1183 gtk_image_set_from_icon_name (image, "pan-up-symbolic", GTK_ICON_SIZE_BUTTON);
1184 break;
1185 case GTK_ARROW_LEFT:
1186 gtk_image_set_from_icon_name (image, "pan-start-symbolic", GTK_ICON_SIZE_BUTTON);
1187 break;
1188 case GTK_ARROW_RIGHT:
1189 gtk_image_set_from_icon_name (image, "pan-end-symbolic", GTK_ICON_SIZE_BUTTON);
1190 break;
1191 }
1192}
1193
1194static GtkWidget *
1195panel_toplevel_add_hide_button (PanelToplevel *toplevel,
1196 GtkArrowType arrow_type,
1197 int left,
1198 int top)
1199{
1200
1201 GtkWidget *button;
1202 AtkObject *obj;
1203 GtkWidget *arrow;
1204
1205 button = gtk_button_new ();
1206 obj = gtk_widget_get_accessible (button);
1207 atk_object_set_name (obj, _("Hide Panel")gettext ("Hide Panel"));
1208 gtk_widget_set_can_default (button, FALSE(0));
1209
1210 arrow = gtk_image_new ();
1211 set_arrow_type (GTK_IMAGE (arrow)((((GtkImage*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((arrow)), ((gtk_image_get_type ()))))))
, arrow_type);
1212 gtk_container_add (GTK_CONTAINER (button)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), ((gtk_container_get_type ()))))))
, arrow);
1213 gtk_widget_show (arrow);
1214
1215 g_object_set_data (G_OBJECT (button)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), (((GType) ((20) << (2))))))))
,
1216 "arrow-type",
1217 GINT_TO_POINTER (arrow_type)((gpointer) (glong) (arrow_type)));
1218
1219 g_signal_connect_swapped (button, "clicked",g_signal_connect_data ((button), ("clicked"), (((GCallback) (
panel_toplevel_hide_button_clicked))), (toplevel), ((void*)0)
, G_CONNECT_SWAPPED)
1220 G_CALLBACK (panel_toplevel_hide_button_clicked), toplevel)g_signal_connect_data ((button), ("clicked"), (((GCallback) (
panel_toplevel_hide_button_clicked))), (toplevel), ((void*)0)
, G_CONNECT_SWAPPED)
;
1221 g_signal_connect_swapped (button, "button-press-event",g_signal_connect_data ((button), ("button-press-event"), (((GCallback
) (panel_toplevel_hide_button_event))), (toplevel), ((void*)0
), G_CONNECT_SWAPPED)
1222 G_CALLBACK (panel_toplevel_hide_button_event), toplevel)g_signal_connect_data ((button), ("button-press-event"), (((GCallback
) (panel_toplevel_hide_button_event))), (toplevel), ((void*)0
), G_CONNECT_SWAPPED)
;
1223 g_signal_connect_swapped (button, "button-release-event",g_signal_connect_data ((button), ("button-release-event"), ((
(GCallback) (panel_toplevel_hide_button_event))), (toplevel),
((void*)0), G_CONNECT_SWAPPED)
1224 G_CALLBACK (panel_toplevel_hide_button_event), toplevel)g_signal_connect_data ((button), ("button-release-event"), ((
(GCallback) (panel_toplevel_hide_button_event))), (toplevel),
((void*)0), G_CONNECT_SWAPPED)
;
1225
1226 gtk_grid_attach (GTK_GRID (toplevel->priv->grid)((((GtkGrid*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->grid)), ((gtk_grid_get_type ()))))
))
, button, left, top, 1, 1);
1227
1228 return button;
1229}
1230
1231static void panel_toplevel_update_buttons_showing(PanelToplevel* toplevel)
1232{
1233 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)) {
1234 gtk_widget_hide (toplevel->priv->hide_button_top);
1235 gtk_widget_hide (toplevel->priv->hide_button_bottom);
1236 gtk_widget_show (toplevel->priv->hide_button_left);
1237 gtk_widget_show (toplevel->priv->hide_button_right);
1238 } else {
1239 gtk_widget_show (toplevel->priv->hide_button_top);
1240 gtk_widget_show (toplevel->priv->hide_button_bottom);
1241 gtk_widget_hide (toplevel->priv->hide_button_left);
1242 gtk_widget_hide (toplevel->priv->hide_button_right);
1243 }
1244
1245 if (toplevel->priv->attached) {
1246 switch (panel_toplevel_get_orientation (toplevel->priv->attach_toplevel)) {
1247 case PANEL_ORIENTATION_TOP:
1248 gtk_widget_hide (toplevel->priv->hide_button_top);
1249 break;
1250 case PANEL_ORIENTATION_BOTTOM:
1251 gtk_widget_hide (toplevel->priv->hide_button_bottom);
1252 break;
1253 case PANEL_ORIENTATION_LEFT:
1254 gtk_widget_hide (toplevel->priv->hide_button_left);
1255 break;
1256 case PANEL_ORIENTATION_RIGHT:
1257 gtk_widget_hide (toplevel->priv->hide_button_right);
1258 break;
1259 default:
1260 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 1260, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1261 break;
1262 }
1263 }
1264}
1265
1266/* force set hide button size on panel size < 30px */
1267static void panel_toplevel_update_hide_buttons_size (GtkWidget *button, int panel_size)
1268{
1269 GtkCssProvider *css_provider;
1270 GtkStyleContext *context;
1271 GtkWidget *arrow;
1272 GtkSettings *settings;
1273 gchar *gtk_theme_name = NULL((void*)0);
1274
1275 context = gtk_widget_get_style_context (button);
1276 gtk_style_context_add_class (context, "panel-button");
1277
1278 /* get defaults from theme */
1279 settings = gtk_settings_get_default ();
1280 g_object_get (settings, "gtk-theme-name", &gtk_theme_name, NULL((void*)0));
1281 css_provider = gtk_css_provider_get_named (gtk_theme_name, NULL((void*)0));
1282 g_free (gtk_theme_name);
1283
1284 /* set custom css by adding our custom code to the default theme css
1285 *
1286 * NOTE that contriary to the documentation:
1287 * https://developer.gnome.org/gtk3/stable/GtkCssProvider.html#gtk-css-provider-load-from-data
1288 * the previously loaded theme is NOT cleared from the css_provider. (reason unknown)
1289 * In other words, this works exactly, how we need it here.
1290 * ALSO NOTE that using gtk_css_provider_to_string () to convert the theme css data into a string
1291 * and then adding the custom css, then adding this updated css to a css_provider
1292 * with the gtk_css_provider_load_from_data () also works,
1293 * however some themes can't be easily converted to strings, beacuse of the binary data
1294 * they contain. This causes a delay of minutes in loading the mate-panel,
1295 * and so this approach is not viable. */
1296 if (panel_size < 30) {
1297 gtk_css_provider_load_from_data (css_provider, ".panel-button {min-height: 13px; min-width: 13px; padding: 0px;}", -1, NULL((void*)0));
1298 }
1299
1300 gtk_style_context_add_provider (context, GTK_STYLE_PROVIDER (css_provider)((((GtkStyleProvider*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((css_provider)), ((gtk_style_provider_get_type
()))))))
, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION600);
1301
1302 /* get arrow image */
1303 arrow = gtk_bin_get_child (GTK_BIN (button)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), ((gtk_bin_get_type ()))))))
);
1304
1305 /* set image size */
1306 if (panel_size < 20) {
1307 gtk_image_set_pixel_size (GTK_IMAGE (arrow)((((GtkImage*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((arrow)), ((gtk_image_get_type ()))))))
, 12);
1308 } else if (panel_size < 40) {
1309 gtk_image_set_pixel_size (GTK_IMAGE (arrow)((((GtkImage*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((arrow)), ((gtk_image_get_type ()))))))
, 16);
1310 } else if (panel_size < 60) {
1311 gtk_image_set_pixel_size (GTK_IMAGE (arrow)((((GtkImage*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((arrow)), ((gtk_image_get_type ()))))))
, 22);
1312 } else {
1313 gtk_image_set_pixel_size (GTK_IMAGE (arrow)((((GtkImage*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((arrow)), ((gtk_image_get_type ()))))))
, 24);
1314 }
1315}
1316
1317static void panel_toplevel_update_hide_buttons(PanelToplevel* toplevel)
1318{
1319
1320 int panel_size = toplevel->priv->size;
1321
1322 if (toplevel->priv->buttons_enabled) {
1323 panel_toplevel_update_buttons_showing (toplevel);
1324
1325 panel_toplevel_update_hide_buttons_size (toplevel->priv->hide_button_top, panel_size);
1326 panel_toplevel_update_hide_buttons_size (toplevel->priv->hide_button_bottom, panel_size);
1327 panel_toplevel_update_hide_buttons_size (toplevel->priv->hide_button_left, panel_size);
1328 panel_toplevel_update_hide_buttons_size (toplevel->priv->hide_button_right, panel_size);
1329
1330 } else {
1331 g_object_set (
1332 G_OBJECT (toplevel->priv->hide_button_top)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->hide_button_top)), (((GType) ((20)
<< (2))))))))
,
1333 "visible", toplevel->priv->state == PANEL_STATE_HIDDEN_DOWN,
1334 NULL((void*)0));
1335 g_object_set (
1336 G_OBJECT (toplevel->priv->hide_button_bottom)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->hide_button_bottom)), (((GType) ((
20) << (2))))))))
,
1337 "visible", toplevel->priv->state == PANEL_STATE_HIDDEN_UP,
1338 NULL((void*)0));
1339 g_object_set (
1340 G_OBJECT (toplevel->priv->hide_button_left)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->hide_button_left)), (((GType) ((20
) << (2))))))))
,
1341 "visible", toplevel->priv->state == PANEL_STATE_HIDDEN_RIGHT,
1342 NULL((void*)0));
1343 g_object_set (
1344 G_OBJECT (toplevel->priv->hide_button_right)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->hide_button_right)), (((GType) ((20
) << (2))))))))
,
1345 "visible", toplevel->priv->state == PANEL_STATE_HIDDEN_LEFT,
1346 NULL((void*)0));
1347 }
1348
1349 if (toplevel->priv->arrows_enabled) {
1350
1351 gtk_widget_show (gtk_bin_get_child (GTK_BIN (toplevel->priv->hide_button_top)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->hide_button_top)), ((gtk_bin_get_type
()))))))
));
1352 gtk_widget_show (gtk_bin_get_child (GTK_BIN (toplevel->priv->hide_button_bottom)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->hide_button_bottom)), ((gtk_bin_get_type
()))))))
));
1353 gtk_widget_show (gtk_bin_get_child (GTK_BIN (toplevel->priv->hide_button_left)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->hide_button_left)), ((gtk_bin_get_type
()))))))
));
1354 gtk_widget_show (gtk_bin_get_child (GTK_BIN (toplevel->priv->hide_button_right)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->hide_button_right)), ((gtk_bin_get_type
()))))))
));
1355
1356 } else {
1357
1358 gtk_widget_hide (gtk_bin_get_child (GTK_BIN (toplevel->priv->hide_button_top)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->hide_button_top)), ((gtk_bin_get_type
()))))))
));
1359 gtk_widget_hide (gtk_bin_get_child (GTK_BIN (toplevel->priv->hide_button_bottom)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->hide_button_bottom)), ((gtk_bin_get_type
()))))))
));
1360 gtk_widget_hide (gtk_bin_get_child (GTK_BIN (toplevel->priv->hide_button_left)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->hide_button_left)), ((gtk_bin_get_type
()))))))
));
1361 gtk_widget_hide (gtk_bin_get_child (GTK_BIN (toplevel->priv->hide_button_right)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->hide_button_right)), ((gtk_bin_get_type
()))))))
));
1362 }
1363
1364 /* set size after setting the arrow */
1365 if (toplevel->priv->buttons_enabled) {
1366 int hb_size;
1367
1368 if (panel_size < 20)
1369 hb_size = 16;
1370 else if (panel_size < 40)
1371 hb_size = 20;
1372 else if (panel_size < 60)
1373 hb_size = 26;
1374 else
1375 hb_size = 30;
1376
1377 gtk_widget_set_size_request (toplevel->priv->hide_button_top, panel_size, hb_size);
1378 gtk_widget_set_size_request (toplevel->priv->hide_button_bottom, panel_size, hb_size);
1379 gtk_widget_set_size_request (toplevel->priv->hide_button_left, hb_size, panel_size);
1380 gtk_widget_set_size_request (toplevel->priv->hide_button_right, hb_size, panel_size);
1381 }
1382}
1383
1384static gboolean panel_toplevel_contains_pointer(PanelToplevel* toplevel)
1385{
1386 GdkDisplay *display;
1387 GdkScreen *screen;
1388 GtkWidget *widget;
1389 GdkSeat *seat;
1390 GdkDevice *pointer;
1391 int x, y;
1392
1393 display = gdk_display_get_default ();
1394 seat = gdk_display_get_default_seat (display);
1395 pointer = gdk_seat_get_pointer (seat);
1396 widget = GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
;
1397
1398 if (!gtk_widget_get_realized (widget))
1399 return FALSE(0);
1400
1401 screen = NULL((void*)0);
1402 x = y = -1;
1403 gdk_device_get_position (pointer, &screen, &x, &y);
1404
1405 if (screen != gtk_window_get_screen (GTK_WINDOW (toplevel)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_window_get_type ()))))))
))
1406 return FALSE(0);
1407
1408 if (x == -1 || y == -1)
1409 return FALSE(0);
1410
1411 if (x < toplevel->priv->geometry.x || x >= (toplevel->priv->geometry.x + toplevel->priv->geometry.width) ||
1412 y < toplevel->priv->geometry.y || y >= (toplevel->priv->geometry.y + toplevel->priv->geometry.height))
1413 return FALSE(0);
1414
1415 return TRUE(!(0));
1416}
1417
1418static inline int panel_toplevel_get_effective_auto_hide_size(PanelToplevel* toplevel)
1419{
1420 int size;
1421
1422 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM))
1423 size = CLAMP (toplevel->priv->auto_hide_size,(((toplevel->priv->auto_hide_size) > (toplevel->priv
->original_height / 2)) ? (toplevel->priv->original_height
/ 2) : (((toplevel->priv->auto_hide_size) < (1)) ? (
1) : (toplevel->priv->auto_hide_size)))
1424 1, toplevel->priv->original_height / 2)(((toplevel->priv->auto_hide_size) > (toplevel->priv
->original_height / 2)) ? (toplevel->priv->original_height
/ 2) : (((toplevel->priv->auto_hide_size) < (1)) ? (
1) : (toplevel->priv->auto_hide_size)))
;
1425 else
1426 size = CLAMP (toplevel->priv->auto_hide_size,(((toplevel->priv->auto_hide_size) > (toplevel->priv
->original_width / 2)) ? (toplevel->priv->original_width
/ 2) : (((toplevel->priv->auto_hide_size) < (1)) ? (
1) : (toplevel->priv->auto_hide_size)))
1427 1, toplevel->priv->original_width / 2)(((toplevel->priv->auto_hide_size) > (toplevel->priv
->original_width / 2)) ? (toplevel->priv->original_width
/ 2) : (((toplevel->priv->auto_hide_size) < (1)) ? (
1) : (toplevel->priv->auto_hide_size)))
;
1428
1429 /* paranoia */
1430 return (size <= 0) ? DEFAULT_AUTO_HIDE_SIZE1 : size;
1431}
1432
1433static gboolean panel_toplevel_update_struts(PanelToplevel* toplevel, gboolean end_of_animation)
1434{
1435 PanelOrientation orientation;
1436 gboolean geometry_changed = FALSE(0);
1437 int strut, strut_start, strut_end;
1438 int x, y, width, height;
1439 GdkRectangle monitor_geom;
1440
1441 if (!toplevel->priv->updated_geometry_initial)
1442 return FALSE(0);
1443
1444#ifdef HAVE_X111
1445 if (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel)))(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gtk_widget_get_display (((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((toplevel)), ((gtk_widget_get_type ()))))
))))); GType __t = ((gdk_x11_display_get_type())); gboolean __r
; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
&& toplevel->priv->attached) {
1446 panel_struts_unregister_strut (toplevel);
1447 panel_struts_set_window_hint (toplevel);
1448 return FALSE(0);
1449 }
1450#endif /* HAVE_X11 */
1451
1452 /* In the case of the initial animation, we really want the struts to
1453 * represent what is at the end of the animation, to avoid desktop
1454 * icons jumping around. */
1455 if (!toplevel->priv->initial_animation_done) {
1456 end_of_animation = TRUE(!(0));
1457
1458 /* We've not started the animation yet, so we have to compute
1459 * where we want to end. Note that we don't want to compute
1460 * this everytime, since the struts conflict resolution will be
1461 * overridden if we do so */
1462 if (!toplevel->priv->animating)
1463 panel_toplevel_calculate_animation_end_geometry (toplevel);
1464 }
1465
1466 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
1467
1468 if (end_of_animation) {
1469 x = toplevel->priv->animation_end_x;
1470 y = toplevel->priv->animation_end_y;
1471 x += panel_multimonitor_x (toplevel->priv->monitor);
1472 y += panel_multimonitor_y (toplevel->priv->monitor);
1473 if (toplevel->priv->animation_end_width != -1)
1474 width = toplevel->priv->animation_end_width;
1475 else
1476 width = toplevel->priv->geometry.width;
1477 if (toplevel->priv->animation_end_height != -1)
1478 height = toplevel->priv->animation_end_height;
1479 else
1480 height = toplevel->priv->geometry.height;
1481 } else {
1482 x = toplevel->priv->geometry.x;
1483 y = toplevel->priv->geometry.y;
1484 width = toplevel->priv->geometry.width;
1485 height = toplevel->priv->geometry.height;
1486 }
1487
1488 orientation = toplevel->priv->orientation;
1489
1490 strut = strut_start = strut_end = 0;
1491
1492 if (orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)) {
1493 if (y <= monitor_geom.y) {
1494 orientation = PANEL_ORIENTATION_TOP;
1495 strut = y + height - monitor_geom.y;
1496 } else if (y >= monitor_geom.y + monitor_geom.height - height) {
1497 orientation = PANEL_ORIENTATION_BOTTOM;
1498 strut = monitor_geom.y + monitor_geom.height - y;
1499 }
1500
1501 if (strut > 0) {
1502 strut_start = MAX (x, monitor_geom.x)(((x) > (monitor_geom.x)) ? (x) : (monitor_geom.x));
1503 strut_end = MIN (x + width, monitor_geom.x + monitor_geom.width)(((x + width) < (monitor_geom.x + monitor_geom.width)) ? (
x + width) : (monitor_geom.x + monitor_geom.width))
- 1;
1504 }
1505 } else {
1506 if (x <= monitor_geom.x) {
1507 orientation = PANEL_ORIENTATION_LEFT;
1508 strut = x + width - monitor_geom.x;
1509 } else if (x >= monitor_geom.x + monitor_geom.width - width) {
1510 orientation = PANEL_ORIENTATION_RIGHT;
1511 strut = monitor_geom.x + monitor_geom.width - x;
1512 }
1513
1514 if (strut > 0) {
1515 strut_start = MAX (y, monitor_geom.y)(((y) > (monitor_geom.y)) ? (y) : (monitor_geom.y));
1516 strut_end = MIN (y + height, monitor_geom.y + monitor_geom.height)(((y + height) < (monitor_geom.y + monitor_geom.height)) ?
(y + height) : (monitor_geom.y + monitor_geom.height))
- 1;
1517 }
1518 }
1519
1520 if (orientation != toplevel->priv->orientation) {
1521 toplevel->priv->orientation = orientation;
1522 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "orientation");
1523 }
1524
1525 if (toplevel->priv->auto_hide && strut > 0)
1526 strut = panel_toplevel_get_effective_auto_hide_size (toplevel);
1527
1528#ifdef HAVE_X111
1529 if (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel)))(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gtk_widget_get_display (((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((toplevel)), ((gtk_widget_get_type ()))))
))))); GType __t = ((gdk_x11_display_get_type())); gboolean __r
; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
) {
1530 if (strut > 0) {
1531 GdkScreen *screen;
1532 screen = gtk_widget_get_screen (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
1533 geometry_changed = panel_struts_register_strut (toplevel,
1534 screen,
1535 toplevel->priv->monitor,
1536 orientation,
1537 strut,
1538 strut_start,
1539 strut_end);
1540 }
1541 else {
1542 panel_struts_unregister_strut (toplevel);
1543 }
1544
1545 if (toplevel->priv->state == PANEL_STATE_NORMAL ||
1546 toplevel->priv->state == PANEL_STATE_AUTO_HIDDEN ||
1547 toplevel->priv->animating)
1548 panel_struts_set_window_hint (toplevel);
1549 else
1550 panel_struts_unset_window_hint (toplevel);
1551 }
1552#endif /* HAVE_X11 */
1553
1554#ifdef HAVE_WAYLAND1
1555 if (GDK_IS_WAYLAND_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel)))(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gtk_widget_get_display (((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((toplevel)), ((gtk_widget_get_type ()))))
))))); GType __t = ((gdk_wayland_display_get_type())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
) {
1556 wayland_panel_toplevel_update_placement (toplevel);
1557 }
1558#endif /* HAVE_WAYLAND */
1559 return geometry_changed;
1560}
1561
1562void panel_toplevel_update_edges(PanelToplevel* toplevel)
1563{
1564 GtkWidget *widget;
1565 PanelFrameEdge edges;
1566 PanelFrameEdge inner_edges;
1567 PanelFrameEdge outer_edges;
1568 GdkRectangle monitor_geom;
1569 int width, height;
1570 gboolean inner_frame = FALSE(0);
1571
1572 widget = GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
;
1573
1574 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
1575
1576 width = toplevel->priv->geometry.width;
1577 height = toplevel->priv->geometry.height;
1578
1579 edges = PANEL_EDGE_NONE;
1580
1581 /* We don't want any bevels with a color/image background */
1582 if (toplevel->priv->geometry.y > 0)
1583 edges |= PANEL_EDGE_TOP;
1584
1585 if (toplevel->priv->geometry.x > 0)
1586 edges |= PANEL_EDGE_LEFT;
1587
1588 if (toplevel->priv->geometry.y < (monitor_geom.height - height))
1589 edges |= PANEL_EDGE_BOTTOM;
1590
1591 if (toplevel->priv->geometry.x < (monitor_geom.width - width))
1592 edges |= PANEL_EDGE_RIGHT;
1593
1594 /* There is a conflict in the position algorithm when a
1595 * non-expanded centered panel is nearly the size of the
1596 * screen. This is similar to the one we have in
1597 * panel_toplevel_update_position(). A simple solution is
1598 * to keep the bevels in this case. */
1599 if (!toplevel->priv->expand &&
1600 toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM) &&
1601 toplevel->priv->x_centered)
1602 edges |= PANEL_EDGE_LEFT | PANEL_EDGE_RIGHT;
1603
1604 if (!toplevel->priv->expand &&
1605 toplevel->priv->orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT) &&
1606 toplevel->priv->y_centered)
1607 edges |= PANEL_EDGE_TOP | PANEL_EDGE_BOTTOM;
1608
1609 if (gtk_widget_get_visible (toplevel->priv->hide_button_left) ||
1610 gtk_widget_get_visible (toplevel->priv->hide_button_right)) {
1611 inner_frame = TRUE(!(0));
1612 edges |= PANEL_EDGE_LEFT | PANEL_EDGE_RIGHT;
1613 }
1614
1615 if (gtk_widget_get_visible (toplevel->priv->hide_button_top) ||
1616 gtk_widget_get_visible (toplevel->priv->hide_button_bottom)) {
1617 inner_frame = TRUE(!(0));
1618 edges |= PANEL_EDGE_TOP | PANEL_EDGE_BOTTOM;
1619 }
1620
1621 if (!inner_frame) {
1622 inner_edges = PANEL_EDGE_NONE;
1623 outer_edges = edges;
1624 } else {
1625 inner_edges = edges;
1626 outer_edges = PANEL_EDGE_NONE;
1627 }
1628
1629 panel_frame_set_edges (toplevel->priv->inner_frame, inner_edges);
1630
1631 if (toplevel->priv->edges != outer_edges) {
1632 toplevel->priv->edges = outer_edges;
1633 gtk_widget_queue_resize (widget);
1634 }
1635}
1636
1637static const char* panel_toplevel_construct_description(PanelToplevel *toplevel)
1638{
1639 if (toplevel->priv->attached)
1640 return _("Drawer")gettext ("Drawer");
1641
1642 switch (toplevel->priv->orientation) {
1643 case PANEL_ORIENTATION_TOP:
1644 /* translators: these string will be shown in MetaCity's switch window
1645 * popup when you pass the focus to a panel */
1646 return _("Top Panel")gettext ("Top Panel");
1647 case PANEL_ORIENTATION_BOTTOM:
1648 return _("Bottom Panel")gettext ("Bottom Panel");
1649 case PANEL_ORIENTATION_LEFT:
1650 return _("Left Panel")gettext ("Left Panel");
1651 case PANEL_ORIENTATION_RIGHT:
1652 return _("Right Panel")gettext ("Right Panel");
1653 }
1654
1655 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 1655, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1656 return _("Top Panel")gettext ("Top Panel");
1657}
1658
1659static void panel_toplevel_update_description(PanelToplevel* toplevel)
1660{
1661 const char *description;
1662
1663 description = panel_toplevel_construct_description (toplevel);
1664
1665 if (toplevel->priv->description &&
1666 !strcmp (toplevel->priv->description, description))
1667 return;
1668
1669 if (toplevel->priv->description)
1670 g_free (toplevel->priv->description);
1671 toplevel->priv->description = g_strdup (description)g_strdup_inline (description);
1672
1673 if (!toplevel->priv->name)
1674 gtk_window_set_title (GTK_WINDOW (toplevel)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_window_get_type ()))))))
,
1675 toplevel->priv->description);
1676
1677 panel_a11y_set_atk_name_desc (
1678 GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
,
1679 toplevel->priv->name ? toplevel->priv->name :
1680 toplevel->priv->description,
1681 toplevel->priv->description);
1682}
1683
1684static void panel_toplevel_update_attached_position(PanelToplevel* toplevel, gboolean hidden, int* x, int* y, int* w, int* h)
1685{
1686 GtkAllocation attach_allocation;
1687 PanelOrientation attach_orientation;
1688 GdkRectangle toplevel_box;
1689 GdkRectangle parent_box;
1690 GdkRectangle attach_box;
1691 int x_origin = 0, y_origin = 0;
1692 GdkRectangle monitor_geom;
1693
1694 if (!gtk_widget_get_realized (GTK_WIDGET (toplevel->priv->attach_toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->attach_toplevel)), ((gtk_widget_get_type
()))))))
) ||
1695 !gtk_widget_get_realized (toplevel->priv->attach_widget))
1696 return;
1697
1698 gtk_widget_get_allocation (GTK_WIDGET (toplevel->priv->attach_widget)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->attach_widget)), ((gtk_widget_get_type
()))))))
, &attach_allocation);
1699
1700 toplevel_box = toplevel->priv->geometry;
1701 parent_box = toplevel->priv->attach_toplevel->priv->geometry;
1702 attach_box = attach_allocation;
1703
1704 if (attach_box.x != -1) {
1705 gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (toplevel->priv->attach_widget)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->attach_widget)), ((gtk_widget_get_type
()))))))
),
1706 &x_origin, &y_origin);
1707
1708 attach_box.x += x_origin;
1709 attach_box.y += y_origin;
1710 } else {
1711 /* attach_widget isn't allocated. Put the toplevel
1712 * off screen.
1713 */
1714 attach_box.x = -toplevel_box.width;
1715 attach_box.y = -toplevel_box.height;
1716 }
1717
1718 attach_orientation = panel_toplevel_get_orientation (
1719 toplevel->priv->attach_toplevel);
1720
1721 if (attach_orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM))
1722 *x = attach_box.x + attach_box.width / 2 - toplevel_box.width / 2;
1723 else
1724 *y = attach_box.y + attach_box.height / 2 - toplevel_box.height / 2;
1725
1726 switch (attach_orientation) {
1727 case PANEL_ORIENTATION_TOP:
1728 *y = parent_box.y;
1729 if (!hidden)
1730 *y += parent_box.height;
1731 else
1732 *h = parent_box.height;
1733 break;
1734 case PANEL_ORIENTATION_BOTTOM:
1735 *y = parent_box.y;
1736 if (!hidden)
1737 *y -= toplevel_box.height;
1738 else
1739 *h = parent_box.height;
1740 break;
1741 case PANEL_ORIENTATION_LEFT:
1742 *x = parent_box.x;
1743 if (!hidden)
1744 *x += parent_box.width;
1745 else
1746 *w = parent_box.width;
1747 break;
1748 case PANEL_ORIENTATION_RIGHT:
1749 *x = parent_box.x;
1750 if (!hidden)
1751 *x -= toplevel_box.width;
1752 else
1753 *w = parent_box.width;
1754 break;
1755 default:
1756 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 1756, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1757 break;
1758 }
1759
1760 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
1761
1762 *x -= monitor_geom.x;
1763 *y -= monitor_geom.y;
1764
1765 if (toplevel->priv->orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT))
1766 *x = CLAMP (*x, 0, monitor_geom.width - toplevel->priv->original_width)(((*x) > (monitor_geom.width - toplevel->priv->original_width
)) ? (monitor_geom.width - toplevel->priv->original_width
) : (((*x) < (0)) ? (0) : (*x)))
;
1767 else
1768 *y = CLAMP (*y, 0, monitor_geom.height - toplevel->priv->original_height)(((*y) > (monitor_geom.height - toplevel->priv->original_height
)) ? (monitor_geom.height - toplevel->priv->original_height
) : (((*y) < (0)) ? (0) : (*y)))
;
1769}
1770
1771static void panel_toplevel_update_normal_position(PanelToplevel* toplevel, int* x, int* y, int* w, int* h)
1772{
1773 GdkRectangle monitor_geom;
1774 int width, height;
1775 int snap_tolerance;
1776
1777 g_assert (x != NULL && y != NULL)do { if (x != ((void*)0) && y != ((void*)0)) ; else g_assertion_message_expr
(((gchar*) 0), "panel-toplevel.c", 1777, ((const char*) (__func__
)), "x != NULL && y != NULL"); } while (0)
;
1778
1779 if (toplevel->priv->attached) {
1780 panel_toplevel_update_attached_position (toplevel, FALSE(0), x, y, w, h);
1781 return;
1782 }
1783
1784 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
1785
1786 width = toplevel->priv->original_width;
1787 height = toplevel->priv->original_height;
1788 snap_tolerance = toplevel->priv->snap_tolerance;
1789
1790 *x = CLAMP (*x, 0, monitor_geom.width - width)(((*x) > (monitor_geom.width - width)) ? (monitor_geom.width
- width) : (((*x) < (0)) ? (0) : (*x)))
;
1791 *y = CLAMP (*y, 0, monitor_geom.height - height)(((*y) > (monitor_geom.height - height)) ? (monitor_geom.height
- height) : (((*y) < (0)) ? (0) : (*y)))
;
1792
1793 if (toplevel->priv->x <= snap_tolerance &&
1794 toplevel->priv->x_right == -1 &&
1795 !toplevel->priv->x_centered)
1796 *x = 0;
1797 else if (toplevel->priv->x_right != -1 &&
1798 toplevel->priv->x_right <= snap_tolerance &&
1799 !toplevel->priv->x_centered)
1800 *x = monitor_geom.width - width;
1801
1802 if (toplevel->priv->y <= snap_tolerance &&
1803 toplevel->priv->y_bottom == -1 &&
1804 !toplevel->priv->y_centered)
1805 *y = 0;
1806 else if (toplevel->priv->y_bottom != -1 &&
1807 toplevel->priv->y_bottom <= snap_tolerance &&
1808 !toplevel->priv->y_centered)
1809 *y = monitor_geom.height - height;
1810}
1811
1812static void
1813panel_toplevel_update_auto_hide_position (PanelToplevel *toplevel,
1814 int *x,
1815 int *y,
1816 int *w,
1817 int *h,
1818 gboolean for_end_position)
1819{
1820 int width, height;
1821 GdkRectangle monitor_geom;
1822 int auto_hide_size;
1823 int snap_tolerance;
1824
1825 g_assert (x != NULL && y != NULL)do { if (x != ((void*)0) && y != ((void*)0)) ; else g_assertion_message_expr
(((gchar*) 0), "panel-toplevel.c", 1825, ((const char*) (__func__
)), "x != NULL && y != NULL"); } while (0)
;
1826
1827 if (toplevel->priv->floating) {
1828 panel_toplevel_update_normal_position (toplevel, x, y, w, h);
1829 return;
1830 }
1831
1832 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
1833
1834 width = toplevel->priv->original_width;
1835 height = toplevel->priv->original_height;
1836 snap_tolerance = toplevel->priv->snap_tolerance;
1837
1838 /* For the initial animation, we animate from outside the screen, and
1839 * so we don't want the toplevel to be visible at all. But when the
1840 * request is for the end position, then we give the real result (it's
1841 * useful for struts) */
1842 if (for_end_position || toplevel->priv->initial_animation_done) {
1843 auto_hide_size = panel_toplevel_get_effective_auto_hide_size (toplevel);
1844 } else {
1845 auto_hide_size = 0;
1846 }
1847
1848 switch (toplevel->priv->orientation) {
1849 case PANEL_ORIENTATION_TOP:
1850 *y = - (height - auto_hide_size);
1851 break;
1852 case PANEL_ORIENTATION_BOTTOM:
1853 *y = monitor_geom.height - auto_hide_size;
1854 break;
1855 case PANEL_ORIENTATION_LEFT:
1856 *x = - (width - auto_hide_size);
1857 break;
1858 case PANEL_ORIENTATION_RIGHT:
1859 *x = monitor_geom.width - auto_hide_size;
1860 break;
1861 default:
1862 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 1862, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1863 break;
1864 }
1865
1866 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)) {
1867 if (toplevel->priv->x <= snap_tolerance &&
1868 toplevel->priv->x_right == -1 &&
1869 !toplevel->priv->x_centered)
1870 *x = 0;
1871 else if (toplevel->priv->x_right != -1 &&
1872 toplevel->priv->x_right <= snap_tolerance &&
1873 !toplevel->priv->x_centered)
1874 *x = monitor_geom.width - width;
1875 } else /* if (toplevel->priv->orientation & PANEL_VERTICAL_MASK) */ {
1876 if (toplevel->priv->y <= snap_tolerance &&
1877 toplevel->priv->y_bottom == -1 &&
1878 !toplevel->priv->y_centered)
1879 *y = 0;
1880 else if (toplevel->priv->y_bottom != -1 &&
1881 toplevel->priv->y_bottom <= snap_tolerance &&
1882 !toplevel->priv->y_centered)
1883 *y = monitor_geom.height - height;
1884 }
1885}
1886
1887/* FIXME: this is wrong for Xinerama. In the Xinerama case
1888 * I think if hiding it requires it to go onto the
1889 * next monitor then it should just move it on to
1890 * the next monitor and set its state back to normal
1891 */
1892static void
1893panel_toplevel_update_hidden_position (PanelToplevel *toplevel,
1894 int *x,
1895 int *y,
1896 int *w,
1897 int *h)
1898{
1899 int width, height;
1900 int min_hide_size;
1901 GdkRectangle monitor_geom;
1902 GtkAllocation hide_allocation;
1903
1904 g_assert (x != NULL && y != NULL)do { if (x != ((void*)0) && y != ((void*)0)) ; else g_assertion_message_expr
(((gchar*) 0), "panel-toplevel.c", 1904, ((const char*) (__func__
)), "x != NULL && y != NULL"); } while (0)
;
1905
1906 g_assert (toplevel->priv->state == PANEL_STATE_HIDDEN_UP ||do { if (toplevel->priv->state == PANEL_STATE_HIDDEN_UP
|| toplevel->priv->state == PANEL_STATE_HIDDEN_DOWN ||
toplevel->priv->state == PANEL_STATE_HIDDEN_LEFT || toplevel
->priv->state == PANEL_STATE_HIDDEN_RIGHT) ; else g_assertion_message_expr
(((gchar*) 0), "panel-toplevel.c", 1909, ((const char*) (__func__
)), "toplevel->priv->state == PANEL_STATE_HIDDEN_UP || toplevel->priv->state == PANEL_STATE_HIDDEN_DOWN || toplevel->priv->state == PANEL_STATE_HIDDEN_LEFT || toplevel->priv->state == PANEL_STATE_HIDDEN_RIGHT"
); } while (0)
1907 toplevel->priv->state == PANEL_STATE_HIDDEN_DOWN ||do { if (toplevel->priv->state == PANEL_STATE_HIDDEN_UP
|| toplevel->priv->state == PANEL_STATE_HIDDEN_DOWN ||
toplevel->priv->state == PANEL_STATE_HIDDEN_LEFT || toplevel
->priv->state == PANEL_STATE_HIDDEN_RIGHT) ; else g_assertion_message_expr
(((gchar*) 0), "panel-toplevel.c", 1909, ((const char*) (__func__
)), "toplevel->priv->state == PANEL_STATE_HIDDEN_UP || toplevel->priv->state == PANEL_STATE_HIDDEN_DOWN || toplevel->priv->state == PANEL_STATE_HIDDEN_LEFT || toplevel->priv->state == PANEL_STATE_HIDDEN_RIGHT"
); } while (0)
1908 toplevel->priv->state == PANEL_STATE_HIDDEN_LEFT ||do { if (toplevel->priv->state == PANEL_STATE_HIDDEN_UP
|| toplevel->priv->state == PANEL_STATE_HIDDEN_DOWN ||
toplevel->priv->state == PANEL_STATE_HIDDEN_LEFT || toplevel
->priv->state == PANEL_STATE_HIDDEN_RIGHT) ; else g_assertion_message_expr
(((gchar*) 0), "panel-toplevel.c", 1909, ((const char*) (__func__
)), "toplevel->priv->state == PANEL_STATE_HIDDEN_UP || toplevel->priv->state == PANEL_STATE_HIDDEN_DOWN || toplevel->priv->state == PANEL_STATE_HIDDEN_LEFT || toplevel->priv->state == PANEL_STATE_HIDDEN_RIGHT"
); } while (0)
1909 toplevel->priv->state == PANEL_STATE_HIDDEN_RIGHT)do { if (toplevel->priv->state == PANEL_STATE_HIDDEN_UP
|| toplevel->priv->state == PANEL_STATE_HIDDEN_DOWN ||
toplevel->priv->state == PANEL_STATE_HIDDEN_LEFT || toplevel
->priv->state == PANEL_STATE_HIDDEN_RIGHT) ; else g_assertion_message_expr
(((gchar*) 0), "panel-toplevel.c", 1909, ((const char*) (__func__
)), "toplevel->priv->state == PANEL_STATE_HIDDEN_UP || toplevel->priv->state == PANEL_STATE_HIDDEN_DOWN || toplevel->priv->state == PANEL_STATE_HIDDEN_LEFT || toplevel->priv->state == PANEL_STATE_HIDDEN_RIGHT"
); } while (0)
;
1910
1911 if (toplevel->priv->attached) {
1912 panel_toplevel_update_attached_position (toplevel, TRUE(!(0)), x, y, w, h);
1913 return;
1914 }
1915
1916 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
1917
1918 width = toplevel->priv->original_width;
1919 height = toplevel->priv->original_height;
1920
1921 /* FIXME should find a better default */
1922 min_hide_size = DEFAULT_AUTO_HIDE_SIZE1;
1923
1924 switch (toplevel->priv->state) {
1925 case PANEL_STATE_HIDDEN_UP:
1926 gtk_widget_get_allocation (toplevel->priv->hide_button_bottom,
1927 &hide_allocation);
1928 *y = - (height - MAX (hide_allocation.height, min_hide_size)(((hide_allocation.height) > (min_hide_size)) ? (hide_allocation
.height) : (min_hide_size))
);
1929 break;
1930 case PANEL_STATE_HIDDEN_DOWN:
1931 gtk_widget_get_allocation (toplevel->priv->hide_button_top,
1932 &hide_allocation);
1933 *y = monitor_geom.height - MAX (hide_allocation.height, min_hide_size)(((hide_allocation.height) > (min_hide_size)) ? (hide_allocation
.height) : (min_hide_size))
;
1934 break;
1935 case PANEL_STATE_HIDDEN_LEFT:
1936 gtk_widget_get_allocation (toplevel->priv->hide_button_right,
1937 &hide_allocation);
1938 *x = - (width - MAX (hide_allocation.width, min_hide_size)(((hide_allocation.width) > (min_hide_size)) ? (hide_allocation
.width) : (min_hide_size))
);
1939 break;
1940 case PANEL_STATE_HIDDEN_RIGHT:
1941 gtk_widget_get_allocation (toplevel->priv->hide_button_left,
1942 &hide_allocation);
1943 *x = monitor_geom.width - MAX (hide_allocation.width, min_hide_size)(((hide_allocation.width) > (min_hide_size)) ? (hide_allocation
.width) : (min_hide_size))
;
1944 break;
1945 default:
1946 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 1946, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1947 break;
1948 }
1949}
1950
1951/*
1952 * This is "almost" like the double sine movement
1953 * from the original panel except that it uses
1954 * a cubic (twice again). I suppose it looks less
1955 * mathematical now :) -- _v_
1956 */
1957static int
1958get_delta (int src,
1959 int dest,
1960 GTimeSpan elapsed_time,
1961 GTimeSpan duration_time)
1962{
1963 double x, percentage;
1964
1965 if (abs (dest - src) <= 1 || elapsed_time >= duration_time)
1966 return dest - src;
1967
1968 /* The cubic is: p(x) = (-2) x^2 (x-1.5) */
1969 /* running p(p(x)) to make it more "pronounced",
1970 * effectively making it a ninth-degree polynomial */
1971
1972 x = (double)elapsed_time/duration_time;
1973 x = -2 * (x*x) * (x-1.5);
1974 /* run it again */
1975 percentage = -2 * (x*x) * (x-1.5);
1976
1977 percentage = CLAMP (percentage, 0.0, 1.0)(((percentage) > (1.0)) ? (1.0) : (((percentage) < (0.0
)) ? (0.0) : (percentage)))
;
1978
1979 return ((dest - src) * percentage);
1980}
1981
1982static void
1983panel_toplevel_update_animating_position (PanelToplevel *toplevel)
1984{
1985 GTimeSpan animation_elapsed_time;
1986 int deltax, deltay, deltaw = 0, deltah = 0;
1987 int monitor_offset_x, monitor_offset_y;
1988
1989 if ((toplevel->priv->animation_start_time <= 0) ||
1990 (toplevel->priv->animation_duration_time <= 0))
1991 return;
1992
1993 animation_elapsed_time = g_get_monotonic_time () - toplevel->priv->animation_start_time;
1994
1995 monitor_offset_x = panel_multimonitor_x (toplevel->priv->monitor);
1996 monitor_offset_y = panel_multimonitor_y (toplevel->priv->monitor);
1997
1998 if (toplevel->priv->animation_end_width != -1)
1999 deltaw = get_delta (toplevel->priv->geometry.width,
2000 toplevel->priv->animation_end_width,
2001 animation_elapsed_time,
2002 toplevel->priv->animation_duration_time);
2003
2004 if (toplevel->priv->animation_end_height != -1)
2005 deltah = get_delta (toplevel->priv->geometry.height,
2006 toplevel->priv->animation_end_height,
2007 animation_elapsed_time,
2008 toplevel->priv->animation_duration_time);
2009
2010 deltax = get_delta (toplevel->priv->geometry.x - monitor_offset_x,
2011 toplevel->priv->animation_end_x,
2012 animation_elapsed_time,
2013 toplevel->priv->animation_duration_time);
2014
2015 deltay = get_delta (toplevel->priv->geometry.y - monitor_offset_y,
2016 toplevel->priv->animation_end_y,
2017 animation_elapsed_time,
2018 toplevel->priv->animation_duration_time);
2019
2020 if (deltaw != 0 && abs (deltaw) > abs (deltax))
2021 deltax = deltaw;
2022 if (deltah != 0 && abs (deltah) > abs (deltay))
2023 deltay = deltah;
2024
2025 toplevel->priv->geometry.x += deltax;
2026 toplevel->priv->geometry.y += deltay;
2027
2028 toplevel->priv->geometry.width += deltaw;
2029 toplevel->priv->geometry.height += deltah;
2030
2031 if (toplevel->priv->geometry.x - monitor_offset_x == toplevel->priv->animation_end_x &&
2032 toplevel->priv->geometry.y - monitor_offset_y == toplevel->priv->animation_end_y) {
2033 toplevel->priv->animating = FALSE(0);
2034 /* Note: it's important to set initial_animation_done to TRUE
2035 * as soon as possible (hence, here) since we don't want to
2036 * have a wrong value in a size request event */
2037 toplevel->priv->initial_animation_done = TRUE(!(0));
2038
2039 if (toplevel->priv->attached && panel_toplevel_get_is_hidden (toplevel))
2040 gtk_widget_unmap (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
2041 else
2042 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
2043
2044 if (toplevel->priv->state == PANEL_STATE_NORMAL)
2045 g_signal_emit (toplevel, toplevel_signals [UNHIDE_SIGNAL], 0);
2046 }
2047}
2048
2049static void
2050panel_toplevel_update_expanded_position (PanelToplevel *toplevel)
2051{
2052 GdkRectangle monitor_geom;
2053 int x, y;
2054 int x_right, y_bottom;
2055 int monitor;
2056
2057 if (!toplevel->priv->expand)
2058 return;
2059
2060 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
2061
2062 x = -1;
2063 y = -1;
2064 x_right = -1;
2065 y_bottom = -1;
2066
2067 switch (toplevel->priv->orientation) {
2068 case PANEL_ORIENTATION_TOP:
2069 x = monitor_geom.x;
2070 y = monitor_geom.y;
2071 break;
2072 case PANEL_ORIENTATION_LEFT:
2073 x = monitor_geom.x;
2074 y = monitor_geom.y;
2075 break;
2076 case PANEL_ORIENTATION_BOTTOM:
2077 x = monitor_geom.x;
2078 y = monitor_geom.y + monitor_geom.height - toplevel->priv->geometry.height;
2079 y_bottom = 0;
2080 break;
2081 case PANEL_ORIENTATION_RIGHT:
2082 x = monitor_geom.x + monitor_geom.width - toplevel->priv->geometry.width;
2083 y = monitor_geom.y;
2084 x_right = 0;
2085 break;
2086 default:
2087 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 2087, ((const char*) (__func__)), ((void*)0)); } while (0)
;
2088 break;
2089 }
2090
2091 monitor = panel_multimonitor_get_monitor_at_point (x, y);
2092
2093 panel_toplevel_set_monitor_internal (toplevel, monitor, TRUE(!(0)));
2094
2095 x -= panel_multimonitor_x (monitor);
2096 y -= panel_multimonitor_y (monitor);
2097
2098 g_object_freeze_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
);
2099
2100 if (toplevel->priv->x != x) {
2101 toplevel->priv->x = x;
2102 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "x");
2103 }
2104
2105 if (toplevel->priv->y != y) {
2106 toplevel->priv->y = y;
2107 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "y");
2108 }
2109
2110 if (toplevel->priv->x_right != x_right) {
2111 toplevel->priv->x_right = x_right;
2112 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "x_right");
2113 }
2114
2115 if (toplevel->priv->y_bottom != y_bottom) {
2116 toplevel->priv->y_bottom = y_bottom;
2117 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "y_bottom");
2118 }
2119
2120 g_object_thaw_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
);
2121}
2122
2123static void
2124panel_toplevel_update_position (PanelToplevel *toplevel)
2125{
2126 PanelBackground *background;
2127 int x, y;
2128 int w, h;
2129 GdkRectangle monitor_geom;
2130
2131 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
2132
2133 if (toplevel->priv->animating) {
2134 panel_toplevel_update_animating_position (toplevel);
2135 return;
2136 }
2137
2138 if (toplevel->priv->position_centered) {
2139 toplevel->priv->position_centered = FALSE(0);
2140
2141 g_object_freeze_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
);
2142
2143 if (!toplevel->priv->x_centered) {
2144 int x_right;
2145
2146 toplevel->priv->x -= toplevel->priv->geometry.width / 2;
2147 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "x");
2148
2149 if ((toplevel->priv->x + toplevel->priv->geometry.width / 2) > monitor_geom.width / 2)
2150 x_right = monitor_geom.width - (toplevel->priv->x + toplevel->priv->geometry.width);
2151 else
2152 x_right = -1;
2153 if (toplevel->priv->x_right != x_right) {
2154 toplevel->priv->x_right = x_right;
2155 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
,
2156 "x-right");
2157 }
2158 }
2159
2160 if (!toplevel->priv->y_centered) {
2161 int y_bottom;
2162
2163 toplevel->priv->y -= toplevel->priv->geometry.height / 2;
2164 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "y");
2165
2166 if ((toplevel->priv->y + toplevel->priv->geometry.height / 2) > monitor_geom.height / 2)
2167 y_bottom = monitor_geom.height - (toplevel->priv->y + toplevel->priv->geometry.height);
2168 else
2169 y_bottom = -1;
2170 if (toplevel->priv->y_bottom != y_bottom) {
2171 toplevel->priv->y_bottom = y_bottom;
2172 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
,
2173 "y-bottom");
2174 }
2175 }
2176
2177 g_object_thaw_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
);
2178 }
2179
2180 panel_toplevel_update_expanded_position (toplevel);
2181 panel_toplevel_calc_floating (toplevel); /* FIXME should probably be done after panel_toplevel_update_normal_position() too */
2182
2183 if (toplevel->priv->x_right == -1)
2184 x = toplevel->priv->x;
2185 else
2186 x = monitor_geom.width - (toplevel->priv->x_right + toplevel->priv->geometry.width);
2187 if (toplevel->priv->y_bottom == -1)
2188 y = toplevel->priv->y;
2189 else
2190 y = monitor_geom.height - (toplevel->priv->y_bottom + toplevel->priv->geometry.height);
2191
2192 if (!toplevel->priv->expand) {
2193 if (toplevel->priv->x_centered)
2194 x = (monitor_geom.width - toplevel->priv->geometry.width) / 2;
2195 if (toplevel->priv->y_centered)
2196 y = (monitor_geom.height - toplevel->priv->geometry.height) / 2;
2197 }
2198
2199 w = h = -1;
2200
2201 if (toplevel->priv->state == PANEL_STATE_NORMAL)
2202 panel_toplevel_update_normal_position (toplevel, &x, &y, &w, &h);
2203
2204 else if (toplevel->priv->state == PANEL_STATE_AUTO_HIDDEN)
2205 panel_toplevel_update_auto_hide_position (toplevel, &x, &y, &w, &h, FALSE(0));
2206
2207 else
2208 panel_toplevel_update_hidden_position (toplevel, &x, &y, &w, &h);
2209
2210 if (w != -1)
2211 toplevel->priv->geometry.width = w;
2212 if (h != -1)
2213 toplevel->priv->geometry.height = h;
2214
2215 /* This is some kind of snap: there's a possibility of an infinite loop
2216 * because of the bevels of the frame that are set in
2217 * panel_toplevel_update_edges(). The bevels change the width/height of
2218 * the toplevel. The typical loop is:
2219 * x = 1 => outer bevel => x = 0 => no outer bevel = > x = 1 => ...
2220 * FIXME: maybe the real bug is that we enter into this loop (see bug
2221 * #160748 to learn how to reproduce.) */
2222 background = &toplevel->background;
2223
2224 /* There's no bevels with a color/image background */
2225 if (panel_background_effective_type (background) == PANEL_BACK_NONE) {
2226 GtkStyleContext *context;
2227 GtkStateFlags state;
2228 GdkRectangle *geometry;
2229 GtkBorder padding;
2230 int max_size;
2231
2232 state = gtk_widget_get_state_flags (GTK_WIDGET (toplevel->priv->inner_frame)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->inner_frame)), ((gtk_widget_get_type
()))))))
);
2233 context = gtk_widget_get_style_context (GTK_WIDGET (toplevel->priv->inner_frame)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->inner_frame)), ((gtk_widget_get_type
()))))))
);
2234 gtk_style_context_get_padding (context, state, &padding);
2235 geometry = &toplevel->priv->geometry;
2236
2237 if (x <= padding.left && x > 0 &&
2238 !toplevel->priv->x_centered)
2239 x = 0;
2240
2241 if (y <= padding.top && y > 0 &&
2242 !toplevel->priv->y_centered)
2243 y = 0;
2244
2245 max_size = monitor_geom.width - geometry->width - padding.right;
2246 if (x + padding.left >= max_size && x < max_size &&
2247 !toplevel->priv->x_centered)
2248 x = max_size;
2249
2250 max_size = monitor_geom.height - geometry->height - padding.bottom;
2251 if (y + padding.top >= max_size && y < max_size &&
2252 !toplevel->priv->y_centered)
2253 y = max_size;
2254 }
2255
2256 x += panel_multimonitor_x (toplevel->priv->monitor);
2257 y += panel_multimonitor_y (toplevel->priv->monitor);
2258
2259 toplevel->priv->geometry.x = x;
2260 toplevel->priv->geometry.y = y;
2261}
2262
2263static int
2264calculate_minimum_height (GtkWidget *widget,
2265 PanelOrientation orientation)
2266{
2267 GtkStateFlags state;
2268 GtkStyleContext *style_context;
2269 PangoFontDescription *font_desc;
2270 GtkBorder padding;
2271 PangoContext *pango_context;
2272 PangoFontMetrics *metrics;
2273 int ascent;
2274 int descent;
2275 int thickness;
2276
2277 state = gtk_widget_get_state_flags (widget);
2278 style_context = gtk_widget_get_style_context (widget);
2279 gtk_style_context_get(style_context, state, GTK_STYLE_PROPERTY_FONT"font", &font_desc, NULL((void*)0));
2280
2281 pango_context = gtk_widget_get_pango_context (widget);
2282 metrics = pango_context_get_metrics (pango_context,
2283 font_desc,
2284 pango_context_get_language (pango_context));
2285 gtk_style_context_get_padding (style_context, state, &padding);
2286
2287 ascent = pango_font_metrics_get_ascent (metrics);
2288 descent = pango_font_metrics_get_descent (metrics);
2289
2290 pango_font_description_free (font_desc);
2291 pango_font_metrics_unref (metrics);
2292
2293 thickness = (orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)) ?
2294 padding.top + padding.bottom :
2295 padding.left + padding.right;
2296
2297 return PANGO_PIXELS (ascent + descent)(((int)(ascent + descent) + 512) >> 10) + thickness;
2298}
2299
2300static int
2301panel_toplevel_update_size_from_hints (PanelToplevel *toplevel,
2302 int requisition_size,
2303 int monitor_size,
2304 int non_panel_widget_size)
2305{
2306 int nb_size_hints;
2307 AppletSizeHints *applets_hints;
2308 AppletSizeHintsAlloc *using_hint;
2309
2310 int i;
2311 int total_size;
2312 int full_hints;
2313
2314 /* Scale down the size so that the panel only takes what it needs for the applets it has. */
2315 total_size = non_panel_widget_size + (requisition_size / toplevel->priv->scale);
2316
2317 nb_size_hints = toplevel->priv->panel_widget->nb_applets_size_hints;
2318 if (nb_size_hints <= 0)
2319 return total_size;
2320
2321 applets_hints = toplevel->priv->panel_widget->applets_hints;
2322 using_hint = toplevel->priv->panel_widget->applets_using_hint;
2323
2324 for (i = 0; i < nb_size_hints; i++) {
2325 using_hint[i].index = applets_hints[i].len - 2;
2326 using_hint[i].size = applets_hints[i].hints[applets_hints[i].len - 1];
2327 total_size += using_hint[i].size;
2328 }
2329
2330 if (total_size > monitor_size)
2331 return monitor_size;
2332
2333 full_hints = 0;
2334 while (full_hints != nb_size_hints && total_size < monitor_size) {
2335 int bonus;
2336 int extra_bonus;
2337
2338 bonus = (monitor_size - total_size)
2339 / (nb_size_hints - full_hints);
2340 extra_bonus = (monitor_size - total_size)
2341 % (nb_size_hints - full_hints);
2342 full_hints = 0;
2343
2344 for (i = 0; i < nb_size_hints; i++) {
2345 int new_size;
2346 int current_bonus;
2347
2348 current_bonus = bonus;
2349
2350 while (using_hint[i].index > 0 && applets_hints[i].hints[using_hint[i].index - 1] < using_hint[i].size + current_bonus) {
2351 new_size = applets_hints[i].hints[using_hint[i].index - 1];
2352 current_bonus = using_hint[i].size
2353 + current_bonus - new_size;
2354 total_size = total_size - using_hint[i].size
2355 + new_size;
2356
2357 using_hint[i].index -= 2;
2358 using_hint[i].size = new_size;
2359 }
2360
2361 new_size = MIN (applets_hints[i].hints[using_hint[i].index],(((applets_hints[i].hints[using_hint[i].index]) < (using_hint
[i].size + current_bonus)) ? (applets_hints[i].hints[using_hint
[i].index]) : (using_hint[i].size + current_bonus))
2362 using_hint[i].size + current_bonus)(((applets_hints[i].hints[using_hint[i].index]) < (using_hint
[i].size + current_bonus)) ? (applets_hints[i].hints[using_hint
[i].index]) : (using_hint[i].size + current_bonus))
;
2363 if (new_size > using_hint[i].size) {
2364 total_size += (new_size - using_hint[i].size);
2365 using_hint[i].size = new_size;
2366 }
2367
2368 if (extra_bonus > 0) {
2369 new_size = MIN (applets_hints[i].hints[using_hint[i].index],(((applets_hints[i].hints[using_hint[i].index]) < (using_hint
[i].size + extra_bonus)) ? (applets_hints[i].hints[using_hint
[i].index]) : (using_hint[i].size + extra_bonus))
2370 using_hint[i].size + extra_bonus)(((applets_hints[i].hints[using_hint[i].index]) < (using_hint
[i].size + extra_bonus)) ? (applets_hints[i].hints[using_hint
[i].index]) : (using_hint[i].size + extra_bonus))
;
2371 if (new_size > using_hint[i].size) {
2372 total_size += (new_size
2373 - using_hint[i].size);
2374 extra_bonus -= (new_size
2375 - using_hint[i].size);
2376 using_hint[i].size = new_size;
2377 }
2378 }
2379
2380 if (using_hint[i].size == applets_hints[i].hints[using_hint[i].index])
2381 full_hints++;
2382 }
2383 }
2384
2385 return total_size;
2386}
2387
2388static void
2389panel_toplevel_update_size (PanelToplevel *toplevel,
2390 GtkRequisition *requisition)
2391{
2392 GtkWidget *widget;
2393 GtkStyleContext *context;
2394 GtkStateFlags state;
2395 GtkBorder padding;
2396 GdkRectangle monitor_geom;
2397 int width, height;
2398 int minimum_height;
2399 int non_panel_widget_size;
2400
2401 if (toplevel->priv->animating)
2402 return;
2403
2404 widget = GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
;
2405 context = gtk_widget_get_style_context (widget);
2406 state = gtk_widget_get_state_flags (widget);
2407 gtk_style_context_get_padding (context, state, &padding);
2408
2409 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
2410
2411 width = requisition->width;
2412 height = requisition->height;
2413
2414 if (!toplevel->priv->expand &&
2415 !toplevel->priv->buttons_enabled && !toplevel->priv->attached)
2416 non_panel_widget_size = 2 * HANDLE_SIZE10;
2417 else
2418 non_panel_widget_size = 0;
2419
2420 minimum_height = calculate_minimum_height (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
,
2421 toplevel->priv->orientation);
2422
2423 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)) {
2424
2425 height = MAX (MIN (MAX (height, toplevel->priv->size),(((((((((height) > (toplevel->priv->size)) ? (height
) : (toplevel->priv->size))) < (panel_toplevel_get_maximum_size
(toplevel))) ? ((((height) > (toplevel->priv->size)
) ? (height) : (toplevel->priv->size))) : (panel_toplevel_get_maximum_size
(toplevel)))) > (minimum_height)) ? (((((((height) > (
toplevel->priv->size)) ? (height) : (toplevel->priv->
size))) < (panel_toplevel_get_maximum_size (toplevel))) ? (
(((height) > (toplevel->priv->size)) ? (height) : (toplevel
->priv->size))) : (panel_toplevel_get_maximum_size (toplevel
)))) : (minimum_height))
2426 panel_toplevel_get_maximum_size (toplevel)),(((((((((height) > (toplevel->priv->size)) ? (height
) : (toplevel->priv->size))) < (panel_toplevel_get_maximum_size
(toplevel))) ? ((((height) > (toplevel->priv->size)
) ? (height) : (toplevel->priv->size))) : (panel_toplevel_get_maximum_size
(toplevel)))) > (minimum_height)) ? (((((((height) > (
toplevel->priv->size)) ? (height) : (toplevel->priv->
size))) < (panel_toplevel_get_maximum_size (toplevel))) ? (
(((height) > (toplevel->priv->size)) ? (height) : (toplevel
->priv->size))) : (panel_toplevel_get_maximum_size (toplevel
)))) : (minimum_height))
2427 minimum_height)(((((((((height) > (toplevel->priv->size)) ? (height
) : (toplevel->priv->size))) < (panel_toplevel_get_maximum_size
(toplevel))) ? ((((height) > (toplevel->priv->size)
) ? (height) : (toplevel->priv->size))) : (panel_toplevel_get_maximum_size
(toplevel)))) > (minimum_height)) ? (((((((height) > (
toplevel->priv->size)) ? (height) : (toplevel->priv->
size))) < (panel_toplevel_get_maximum_size (toplevel))) ? (
(((height) > (toplevel->priv->size)) ? (height) : (toplevel
->priv->size))) : (panel_toplevel_get_maximum_size (toplevel
)))) : (minimum_height))
;
2428
2429 if (toplevel->priv->expand)
2430 width = monitor_geom.width;
2431 else {
2432 int max_width;
2433
2434 if (!toplevel->priv->attached)
2435 max_width = monitor_geom.width;
2436 else {
2437 if (panel_toplevel_get_orientation (toplevel->priv->attach_toplevel) == PANEL_ORIENTATION_LEFT)
2438 max_width = monitor_geom.width
2439 - toplevel->priv->geometry.x;
2440 else
2441 max_width = toplevel->priv->geometry.x +
2442 toplevel->priv->geometry.width;
2443 }
2444
2445 width = panel_toplevel_update_size_from_hints (
2446 toplevel,
2447 requisition->width,
2448 max_width,
2449 non_panel_widget_size);
2450 }
2451
2452 width = MAX (MINIMUM_WIDTH, width)(((100) > (width)) ? (100) : (width));
2453 } else {
2454 width = MAX (MIN (MAX (width, toplevel->priv->size),(((((((((width) > (toplevel->priv->size)) ? (width) :
(toplevel->priv->size))) < (panel_toplevel_get_maximum_size
(toplevel))) ? ((((width) > (toplevel->priv->size))
? (width) : (toplevel->priv->size))) : (panel_toplevel_get_maximum_size
(toplevel)))) > (minimum_height)) ? (((((((width) > (toplevel
->priv->size)) ? (width) : (toplevel->priv->size)
)) < (panel_toplevel_get_maximum_size (toplevel))) ? ((((width
) > (toplevel->priv->size)) ? (width) : (toplevel->
priv->size))) : (panel_toplevel_get_maximum_size (toplevel
)))) : (minimum_height))
2455 panel_toplevel_get_maximum_size (toplevel)),(((((((((width) > (toplevel->priv->size)) ? (width) :
(toplevel->priv->size))) < (panel_toplevel_get_maximum_size
(toplevel))) ? ((((width) > (toplevel->priv->size))
? (width) : (toplevel->priv->size))) : (panel_toplevel_get_maximum_size
(toplevel)))) > (minimum_height)) ? (((((((width) > (toplevel
->priv->size)) ? (width) : (toplevel->priv->size)
)) < (panel_toplevel_get_maximum_size (toplevel))) ? ((((width
) > (toplevel->priv->size)) ? (width) : (toplevel->
priv->size))) : (panel_toplevel_get_maximum_size (toplevel
)))) : (minimum_height))
2456 minimum_height)(((((((((width) > (toplevel->priv->size)) ? (width) :
(toplevel->priv->size))) < (panel_toplevel_get_maximum_size
(toplevel))) ? ((((width) > (toplevel->priv->size))
? (width) : (toplevel->priv->size))) : (panel_toplevel_get_maximum_size
(toplevel)))) > (minimum_height)) ? (((((((width) > (toplevel
->priv->size)) ? (width) : (toplevel->priv->size)
)) < (panel_toplevel_get_maximum_size (toplevel))) ? ((((width
) > (toplevel->priv->size)) ? (width) : (toplevel->
priv->size))) : (panel_toplevel_get_maximum_size (toplevel
)))) : (minimum_height))
;
2457
2458 if (toplevel->priv->expand)
2459 height = monitor_geom.height;
2460 else {
2461 int max_height;
2462
2463 if (!toplevel->priv->attached)
2464 max_height = monitor_geom.height;
2465 else {
2466 if (panel_toplevel_get_orientation (toplevel->priv->attach_toplevel) == PANEL_ORIENTATION_TOP)
2467 max_height = monitor_geom.height
2468 - toplevel->priv->geometry.y;
2469 else
2470 max_height = toplevel->priv->geometry.y +
2471 toplevel->priv->geometry.height;
2472 }
2473
2474 height = panel_toplevel_update_size_from_hints (
2475 toplevel,
2476 requisition->height,
2477 max_height,
2478 non_panel_widget_size);
2479 }
2480
2481 height = MAX (MINIMUM_WIDTH, height)(((100) > (height)) ? (100) : (height));
2482 }
2483
2484 if (toplevel->priv->edges & PANEL_EDGE_TOP)
2485 height += padding.top;
2486 if (toplevel->priv->edges & PANEL_EDGE_BOTTOM)
2487 height += padding.bottom;
2488 if (toplevel->priv->edges & PANEL_EDGE_LEFT)
2489 width += padding.left;
2490 if (toplevel->priv->edges & PANEL_EDGE_RIGHT)
2491 width += padding.right;
2492
2493 toplevel->priv->geometry.width = CLAMP (width, 0, monitor_geom.width)(((width) > (monitor_geom.width)) ? (monitor_geom.width) :
(((width) < (0)) ? (0) : (width)))
;
2494 toplevel->priv->geometry.height = CLAMP (height, 0, monitor_geom.height)(((height) > (monitor_geom.height)) ? (monitor_geom.height
) : (((height) < (0)) ? (0) : (height)))
;
2495 toplevel->priv->original_width = toplevel->priv->geometry.width;
2496 toplevel->priv->original_height = toplevel->priv->geometry.height;
2497}
2498
2499static void
2500panel_toplevel_update_geometry (PanelToplevel *toplevel,
2501 GtkRequisition *requisition)
2502{
2503 toplevel->priv->updated_geometry_initial = TRUE(!(0));
2504 panel_toplevel_update_size (toplevel, requisition);
2505 panel_toplevel_update_position (toplevel);
2506
2507 panel_toplevel_update_struts (toplevel, FALSE(0));
2508
2509#ifdef HAVE_X111
2510 if (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel)))(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gtk_widget_get_display (((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((toplevel)), ((gtk_widget_get_type ()))))
))))); GType __t = ((gdk_x11_display_get_type())); gboolean __r
; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
) {
2511 if (toplevel->priv->state == PANEL_STATE_NORMAL ||
2512 toplevel->priv->state != PANEL_STATE_AUTO_HIDDEN) {
2513 panel_struts_update_toplevel_geometry (toplevel,
2514 &toplevel->priv->geometry.x,
2515 &toplevel->priv->geometry.y,
2516 &toplevel->priv->geometry.width,
2517 &toplevel->priv->geometry.height);
2518 } else {
2519 panel_struts_update_toplevel_geometry (toplevel,
2520 &toplevel->priv->geometry.x,
2521 &toplevel->priv->geometry.y,
2522 NULL((void*)0), NULL((void*)0));
2523 }
2524 }
2525#endif /* HAVE_X11 */
2526
2527 panel_toplevel_update_edges (toplevel);
2528 panel_toplevel_update_description (toplevel);
2529}
2530
2531static void
2532panel_toplevel_attach_widget_destroyed (PanelToplevel *toplevel)
2533{
2534 panel_toplevel_detach (toplevel);
2535}
2536
2537static gboolean
2538panel_toplevel_attach_widget_configure (PanelToplevel *toplevel)
2539{
2540 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
2541
2542 return FALSE(0);
2543}
2544
2545static void
2546panel_toplevel_update_attach_orientation (PanelToplevel *toplevel)
2547{
2548 PanelOrientation attach_orientation;
2549 PanelOrientation orientation;
2550
2551 attach_orientation =
2552 panel_toplevel_get_orientation (toplevel->priv->attach_toplevel);
2553
2554 orientation = toplevel->priv->orientation;
2555
2556 switch (attach_orientation) {
2557 case PANEL_ORIENTATION_TOP:
2558 orientation = PANEL_ORIENTATION_LEFT;
2559 break;
2560 case PANEL_ORIENTATION_BOTTOM:
2561 orientation = PANEL_ORIENTATION_RIGHT;
2562 break;
2563 case PANEL_ORIENTATION_LEFT:
2564 orientation = PANEL_ORIENTATION_TOP;
2565 break;
2566 case PANEL_ORIENTATION_RIGHT:
2567 orientation = PANEL_ORIENTATION_BOTTOM;
2568 break;
2569 default:
2570 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 2570, ((const char*) (__func__)), ((void*)0)); } while (0)
;
2571 break;
2572 }
2573
2574 panel_toplevel_set_orientation (toplevel, orientation);
2575}
2576
2577static void
2578panel_toplevel_attach_widget_parent_set (PanelToplevel *toplevel,
2579 GtkWidget *previous_parent,
2580 GtkWidget *attach_widget)
2581{
2582 GtkWidget *panel_widget;
2583
2584 panel_widget = gtk_widget_get_parent (GTK_WIDGET (attach_widget)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((attach_widget)), ((gtk_widget_get_type ()))))))
);
2585 if (!panel_widget)
2586 return;
2587
2588 g_assert (PANEL_IS_WIDGET (panel_widget))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((panel_widget)); GType __t = ((panel_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_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 2588, ((const char*) (__func__)), "PANEL_IS_WIDGET (panel_widget)"
); } while (0)
;
2589
2590 toplevel->priv->attach_toplevel = PANEL_WIDGET (panel_widget)((((PanelWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((panel_widget)), ((panel_widget_get_type()))))))
->toplevel;
2591 panel_toplevel_update_attach_orientation (toplevel);
2592 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
2593}
2594
2595static void
2596panel_toplevel_attach_toplevel_hiding (PanelToplevel *toplevel)
2597{
2598 if (!panel_toplevel_get_is_hidden (toplevel)) {
2599 panel_toplevel_hide (toplevel, FALSE(0), -1);
2600
2601 toplevel->priv->attach_hidden = TRUE(!(0));
2602 }
2603}
2604
2605static void
2606panel_toplevel_attach_toplevel_unhiding (PanelToplevel *toplevel)
2607{
2608 if (!toplevel->priv->attach_hidden)
2609 return;
2610
2611 toplevel->priv->attach_hidden = FALSE(0);
2612
2613 panel_toplevel_unhide (toplevel);
2614}
2615
2616static void
2617panel_toplevel_reverse_arrow (PanelToplevel *toplevel,
2618 GtkWidget *button)
2619{
2620 GtkArrowType arrow_type;
2621
2622 arrow_type = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button), "arrow-type"))((gint) (glong) (g_object_get_data (((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((button)), (((GType) ((20) << (2)))
))))), "arrow-type")))
;
2623
2624 switch (arrow_type) {
2625 case GTK_ARROW_UP:
2626 arrow_type = GTK_ARROW_DOWN;
2627 break;
2628 case GTK_ARROW_DOWN:
2629 arrow_type = GTK_ARROW_UP;
2630 break;
2631 case GTK_ARROW_LEFT:
2632 arrow_type = GTK_ARROW_RIGHT;
2633 break;
2634 case GTK_ARROW_RIGHT:
2635 arrow_type = GTK_ARROW_LEFT;
2636 break;
2637 default:
2638 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 2638, ((const char*) (__func__)), ((void*)0)); } while (0)
;
2639 break;
2640 }
2641
2642 g_object_set_data (G_OBJECT (button)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), (((GType) ((20) << (2))))))))
, "arrow-type", GINT_TO_POINTER (arrow_type)((gpointer) (glong) (arrow_type)));
2643
2644 set_arrow_type (GTK_IMAGE (gtk_bin_get_child (GTK_BIN (button)))((((GtkImage*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_bin_get_child (((((GtkBin*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((button)), ((gtk_bin_get_type ())))))))))
, ((gtk_image_get_type ()))))))
, arrow_type);
2645}
2646
2647static void
2648panel_toplevel_reverse_arrows (PanelToplevel *toplevel)
2649{
2650 panel_toplevel_reverse_arrow (toplevel, toplevel->priv->hide_button_top);
2651 panel_toplevel_reverse_arrow (toplevel, toplevel->priv->hide_button_bottom);
2652 panel_toplevel_reverse_arrow (toplevel, toplevel->priv->hide_button_left);
2653 panel_toplevel_reverse_arrow (toplevel, toplevel->priv->hide_button_right);
2654}
2655
2656static void
2657panel_toplevel_disconnect_attached (PanelToplevel *toplevel)
2658{
2659 guint i;
2660
2661#if GLIB_CHECK_VERSION(2,62,0)(2 > (2) || (2 == (2) && 80 > (62)) || (2 == (2
) && 80 == (62) && 2 >= (0)))
2662 for (i = 0; i < N_ATTACH_TOPLEVEL_SIGNALS5; i++) {
2663 g_clear_signal_handler (&toplevel->priv->attach_toplevel_signals [i],do { gpointer const _instance = (toplevel->priv->attach_toplevel
); gulong *const _handler_id_ptr = (&toplevel->priv->
attach_toplevel_signals [i]); const gulong _handler_id = *_handler_id_ptr
; if (_handler_id > 0) { *_handler_id_ptr = 0; g_signal_handler_disconnect
(_instance, _handler_id); } } while (0)
2664 toplevel->priv->attach_toplevel)do { gpointer const _instance = (toplevel->priv->attach_toplevel
); gulong *const _handler_id_ptr = (&toplevel->priv->
attach_toplevel_signals [i]); const gulong _handler_id = *_handler_id_ptr
; if (_handler_id > 0) { *_handler_id_ptr = 0; g_signal_handler_disconnect
(_instance, _handler_id); } } while (0)
;
2665 }
2666
2667 for (i = 0; i < N_ATTACH_WIDGET_SIGNALS5; i++) {
2668 g_clear_signal_handler (&toplevel->priv->attach_widget_signals [i],do { gpointer const _instance = (toplevel->priv->attach_widget
); gulong *const _handler_id_ptr = (&toplevel->priv->
attach_widget_signals [i]); const gulong _handler_id = *_handler_id_ptr
; if (_handler_id > 0) { *_handler_id_ptr = 0; g_signal_handler_disconnect
(_instance, _handler_id); } } while (0)
2669 toplevel->priv->attach_widget)do { gpointer const _instance = (toplevel->priv->attach_widget
); gulong *const _handler_id_ptr = (&toplevel->priv->
attach_widget_signals [i]); const gulong _handler_id = *_handler_id_ptr
; if (_handler_id > 0) { *_handler_id_ptr = 0; g_signal_handler_disconnect
(_instance, _handler_id); } } while (0)
;
2670 }
2671#else
2672 for (i = 0; i < N_ATTACH_TOPLEVEL_SIGNALS5; i++) {
2673 if (toplevel->priv->attach_toplevel_signals [i] != 0) {
2674 g_signal_handler_disconnect (toplevel->priv->attach_toplevel,
2675 toplevel->priv->attach_toplevel_signals [i]);
2676 toplevel->priv->attach_toplevel_signals [i] = 0;
2677 }
2678 }
2679
2680 for (i = 0; i < N_ATTACH_WIDGET_SIGNALS5; i++) {
2681 if (toplevel->priv->attach_widget_signals [i] != 0) {
2682 g_signal_handler_disconnect (toplevel->priv->attach_widget,
2683 toplevel->priv->attach_widget_signals [i]);
2684 toplevel->priv->attach_widget_signals [i] = 0;
2685 }
2686 }
2687#endif
2688}
2689
2690static void
2691panel_toplevel_connect_attached (PanelToplevel *toplevel)
2692{
2693 gulong *signals;
2694 int i = 0;
2695
2696 signals = toplevel->priv->attach_toplevel_signals;
2697
2698 signals [i++] = g_signal_connect_swapped (g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("destroy"), (((GCallback) (panel_toplevel_attach_widget_destroyed
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2699 toplevel->priv->attach_toplevel, "destroy",g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("destroy"), (((GCallback) (panel_toplevel_attach_widget_destroyed
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2700 G_CALLBACK (panel_toplevel_attach_widget_destroyed), toplevel)g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("destroy"), (((GCallback) (panel_toplevel_attach_widget_destroyed
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
;
2701 signals [i++] = g_signal_connect_swapped (g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("notify::orientation"), (((GCallback) (panel_toplevel_update_attach_orientation
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2702 toplevel->priv->attach_toplevel, "notify::orientation",g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("notify::orientation"), (((GCallback) (panel_toplevel_update_attach_orientation
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2703 G_CALLBACK (panel_toplevel_update_attach_orientation), toplevel)g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("notify::orientation"), (((GCallback) (panel_toplevel_update_attach_orientation
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
;
2704 signals [i++] = g_signal_connect_swapped (g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("configure-event"), (((GCallback) (panel_toplevel_attach_widget_configure
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2705 toplevel->priv->attach_toplevel, "configure-event",g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("configure-event"), (((GCallback) (panel_toplevel_attach_widget_configure
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2706 G_CALLBACK (panel_toplevel_attach_widget_configure), toplevel)g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("configure-event"), (((GCallback) (panel_toplevel_attach_widget_configure
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
;
2707 signals [i++] = g_signal_connect_swapped (g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("hiding"), (((GCallback) (panel_toplevel_attach_toplevel_hiding
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2708 toplevel->priv->attach_toplevel, "hiding",g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("hiding"), (((GCallback) (panel_toplevel_attach_toplevel_hiding
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2709 G_CALLBACK (panel_toplevel_attach_toplevel_hiding), toplevel)g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("hiding"), (((GCallback) (panel_toplevel_attach_toplevel_hiding
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
;
2710 signals [i++] = g_signal_connect_swapped (g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("unhiding"), (((GCallback) (panel_toplevel_attach_toplevel_unhiding
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2711 toplevel->priv->attach_toplevel, "unhiding",g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("unhiding"), (((GCallback) (panel_toplevel_attach_toplevel_unhiding
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2712 G_CALLBACK (panel_toplevel_attach_toplevel_unhiding), toplevel)g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("unhiding"), (((GCallback) (panel_toplevel_attach_toplevel_unhiding
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
;
2713
2714 g_assert (i == N_ATTACH_TOPLEVEL_SIGNALS)do { if (i == 5) ; else g_assertion_message_expr (((gchar*) 0
), "panel-toplevel.c", 2714, ((const char*) (__func__)), "i == N_ATTACH_TOPLEVEL_SIGNALS"
); } while (0)
;
2715
2716 signals = toplevel->priv->attach_widget_signals;
2717 i = 0;
2718
2719 signals [i++] = g_signal_connect_swapped (g_signal_connect_data ((toplevel->priv->attach_widget),
("destroy"), (((GCallback) (panel_toplevel_attach_widget_destroyed
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2720 toplevel->priv->attach_widget, "destroy",g_signal_connect_data ((toplevel->priv->attach_widget),
("destroy"), (((GCallback) (panel_toplevel_attach_widget_destroyed
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2721 G_CALLBACK (panel_toplevel_attach_widget_destroyed), toplevel)g_signal_connect_data ((toplevel->priv->attach_widget),
("destroy"), (((GCallback) (panel_toplevel_attach_widget_destroyed
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
;
2722 signals [i++] = g_signal_connect_swapped (g_signal_connect_data ((toplevel->priv->attach_widget),
("configure-event"), (((GCallback) (panel_toplevel_attach_widget_configure
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2723 toplevel->priv->attach_widget, "configure-event",g_signal_connect_data ((toplevel->priv->attach_widget),
("configure-event"), (((GCallback) (panel_toplevel_attach_widget_configure
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2724 G_CALLBACK (panel_toplevel_attach_widget_configure), toplevel)g_signal_connect_data ((toplevel->priv->attach_widget),
("configure-event"), (((GCallback) (panel_toplevel_attach_widget_configure
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
;
2725 signals [i++] = g_signal_connect_swapped (g_signal_connect_data ((toplevel->priv->attach_widget),
("parent-set"), (((GCallback) (panel_toplevel_attach_widget_parent_set
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2726 toplevel->priv->attach_widget, "parent-set",g_signal_connect_data ((toplevel->priv->attach_widget),
("parent-set"), (((GCallback) (panel_toplevel_attach_widget_parent_set
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2727 G_CALLBACK (panel_toplevel_attach_widget_parent_set), toplevel)g_signal_connect_data ((toplevel->priv->attach_widget),
("parent-set"), (((GCallback) (panel_toplevel_attach_widget_parent_set
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
;
2728 signals [i++] = g_signal_connect_swapped (g_signal_connect_data ((toplevel->priv->attach_widget),
("show"), (((GCallback) (gtk_widget_show))), (toplevel), ((void
*)0), G_CONNECT_SWAPPED)
2729 toplevel->priv->attach_widget, "show",g_signal_connect_data ((toplevel->priv->attach_widget),
("show"), (((GCallback) (gtk_widget_show))), (toplevel), ((void
*)0), G_CONNECT_SWAPPED)
2730 G_CALLBACK (gtk_widget_show), toplevel)g_signal_connect_data ((toplevel->priv->attach_widget),
("show"), (((GCallback) (gtk_widget_show))), (toplevel), ((void
*)0), G_CONNECT_SWAPPED)
;
2731 signals [i++] = g_signal_connect_swapped (g_signal_connect_data ((toplevel->priv->attach_widget),
("hide"), (((GCallback) (gtk_widget_hide))), (toplevel), ((void
*)0), G_CONNECT_SWAPPED)
2732 toplevel->priv->attach_widget, "hide",g_signal_connect_data ((toplevel->priv->attach_widget),
("hide"), (((GCallback) (gtk_widget_hide))), (toplevel), ((void
*)0), G_CONNECT_SWAPPED)
2733 G_CALLBACK (gtk_widget_hide), toplevel)g_signal_connect_data ((toplevel->priv->attach_widget),
("hide"), (((GCallback) (gtk_widget_hide))), (toplevel), ((void
*)0), G_CONNECT_SWAPPED)
;
2734
2735 g_assert (i == N_ATTACH_WIDGET_SIGNALS)do { if (i == 5) ; else g_assertion_message_expr (((gchar*) 0
), "panel-toplevel.c", 2735, ((const char*) (__func__)), "i == N_ATTACH_WIDGET_SIGNALS"
); } while (0)
;
2736}
2737
2738void
2739panel_toplevel_attach_to_widget (PanelToplevel *toplevel,
2740 PanelToplevel *attach_toplevel,
2741 GtkWidget *attach_widget)
2742{
2743 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
2744 g_return_if_fail (PANEL_IS_TOPLEVEL (attach_toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((attach_toplevel)); GType __t = ((panel_toplevel_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0
), ((const char*) (__func__)), "PANEL_IS_TOPLEVEL (attach_toplevel)"
); return; } } while (0)
;
2745 g_return_if_fail (GTK_IS_WIDGET (attach_widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((attach_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 (((gchar*) 0), ((const
char*) (__func__)), "GTK_IS_WIDGET (attach_widget)"); return
; } } while (0)
;
2746
2747 if (toplevel->priv->attached)
2748 panel_toplevel_disconnect_attached (toplevel);
2749
2750 toplevel->priv->attached = TRUE(!(0));
2751
2752 /* Cancelling the initial animation for drawers in
2753 * panel_toplevel_initially_hide() is not enough, since this will
2754 * happen only when the toplevel is realized, which might be too late
2755 * for drawers (since it's realized when the drawer is clicked) */
2756 toplevel->priv->initial_animation_done = TRUE(!(0));
2757
2758 toplevel->priv->attach_toplevel = attach_toplevel;
2759 toplevel->priv->attach_widget = attach_widget;
2760
2761 panel_toplevel_connect_attached (toplevel);
2762
2763 panel_toplevel_reverse_arrows (toplevel);
2764 panel_toplevel_set_expand (toplevel, FALSE(0));
2765 panel_toplevel_update_attach_orientation (toplevel);
2766 panel_toplevel_update_hide_buttons (toplevel);
2767
2768 gtk_window_set_screen (GTK_WINDOW (toplevel)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_window_get_type ()))))))
,
2769 gtk_widget_get_screen (GTK_WIDGET (attach_toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((attach_toplevel)), ((gtk_widget_get_type ()))))))
));
2770 panel_toplevel_set_monitor (toplevel,
2771 panel_toplevel_get_monitor (attach_toplevel));
2772 if (toplevel->priv->state == PANEL_STATE_NORMAL)
2773 panel_toplevel_push_autohide_disabler (toplevel->priv->attach_toplevel);
2774
2775 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
2776}
2777
2778void
2779panel_toplevel_detach (PanelToplevel *toplevel)
2780{
2781 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
2782
2783 if (!toplevel->priv->attached)
2784 return;
2785
2786 if (toplevel->priv->state == PANEL_STATE_NORMAL)
2787 panel_toplevel_pop_autohide_disabler (toplevel->priv->attach_toplevel);
2788
2789 panel_toplevel_disconnect_attached (toplevel);
2790
2791 panel_toplevel_reverse_arrows (toplevel);
2792
2793 toplevel->priv->attached = FALSE(0);
2794
2795 toplevel->priv->attach_toplevel = NULL((void*)0);
2796 toplevel->priv->attach_widget = NULL((void*)0);
2797
2798 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
2799}
2800
2801gboolean
2802panel_toplevel_get_is_attached (PanelToplevel *toplevel)
2803{
2804 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return ((0));
} } while (0)
;
2805
2806 return toplevel->priv->attached;
2807}
2808
2809PanelToplevel *
2810panel_toplevel_get_attach_toplevel (PanelToplevel *toplevel)
2811{
2812 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return (((void
*)0)); } } while (0)
;
2813
2814 return toplevel->priv->attach_toplevel;
2815}
2816
2817GtkWidget *
2818panel_toplevel_get_attach_widget (PanelToplevel *toplevel)
2819{
2820 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return (((void
*)0)); } } while (0)
;
2821
2822 return toplevel->priv->attach_widget;
2823}
2824
2825static gboolean
2826panel_toplevel_popup_panel_menu (PanelToplevel *toplevel)
2827{
2828 gboolean retval = FALSE(0);
2829
2830 g_signal_emit_by_name (toplevel, "popup-menu", &retval);
2831
2832 return retval;
2833}
2834
2835static gboolean
2836panel_toplevel_toggle_expand (PanelToplevel *toplevel)
2837{
2838 panel_toplevel_set_expand (toplevel, !toplevel->priv->expand);
2839
2840 return TRUE(!(0));
2841}
2842
2843static gboolean
2844panel_toplevel_expand (PanelToplevel *toplevel)
2845{
2846 panel_toplevel_set_expand (toplevel, TRUE(!(0)));
2847
2848 return TRUE(!(0));
2849}
2850
2851static gboolean
2852panel_toplevel_unexpand (PanelToplevel *toplevel)
2853{
2854 panel_toplevel_set_expand (toplevel, FALSE(0));
2855
2856 return TRUE(!(0));
2857}
2858
2859static gboolean
2860panel_toplevel_toggle_hidden (PanelToplevel *toplevel)
2861{
2862 if (toplevel->priv->state == PANEL_STATE_NORMAL)
2863 panel_toplevel_hide (toplevel, toplevel->priv->auto_hide, -1);
2864 else
2865 panel_toplevel_unhide (toplevel);
2866
2867 return FALSE(0);
2868}
2869
2870static gboolean
2871panel_toplevel_begin_move (PanelToplevel *toplevel)
2872{
2873 if (toplevel->priv->grab_op != PANEL_GRAB_OP_NONE)
2874 return FALSE(0);
2875
2876 panel_toplevel_begin_grab_op (
2877 toplevel, PANEL_GRAB_OP_MOVE, TRUE(!(0)), GDK_CURRENT_TIME0L);
2878
2879 return TRUE(!(0));
2880}
2881
2882static gboolean
2883panel_toplevel_begin_resize (PanelToplevel *toplevel)
2884{
2885 if (toplevel->priv->grab_op != PANEL_GRAB_OP_NONE)
2886 return FALSE(0);
2887
2888 panel_toplevel_begin_grab_op (
2889 toplevel, PANEL_GRAB_OP_RESIZE, TRUE(!(0)), GDK_CURRENT_TIME0L);
2890
2891 return TRUE(!(0));
2892}
2893
2894static void
2895panel_toplevel_move_resize_window (PanelToplevel *toplevel,
2896 gboolean move,
2897 gboolean resize)
2898{
2899 GtkWidget *widget;
2900
2901 GList *list;
2902 gboolean stick;
2903
2904 widget = GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
;
2905
2906 g_assert (gtk_widget_get_realized (widget))do { if (gtk_widget_get_realized (widget)) ; else g_assertion_message_expr
(((gchar*) 0), "panel-toplevel.c", 2906, ((const char*) (__func__
)), "gtk_widget_get_realized (widget)"); } while (0)
;
2907
2908 if (move && resize)
2909 gdk_window_move_resize (gtk_widget_get_window (widget),
2910 toplevel->priv->geometry.x,
2911 toplevel->priv->geometry.y,
2912 toplevel->priv->geometry.width,
2913 toplevel->priv->geometry.height);
2914 else if (move)
2915 gdk_window_move (gtk_widget_get_window (widget),
2916 toplevel->priv->geometry.x,
2917 toplevel->priv->geometry.y);
2918 else if (resize)
2919 gdk_window_resize (gtk_widget_get_window (widget),
2920 toplevel->priv->geometry.width,
2921 toplevel->priv->geometry.height);
2922
2923 if (resize || move) {
2924 for (list = toplevel->priv->panel_widget->applet_list; list != NULL((void*)0); list = g_list_next (list)((list) ? (((GList *)(list))->next) : ((void*)0))) {
2925 AppletData *ad = list->data;
2926 const char *id = mate_panel_applet_get_id_by_widget (ad->applet);
2927
2928 if (!id)
2929 return;
2930
2931 AppletInfo *info;
2932 info = mate_panel_applet_get_by_id (id);
2933
2934 stick = g_settings_get_boolean (info->settings, PANEL_OBJECT_PANEL_RIGHT_STICK_KEY"panel-right-stick");
2935
2936 if (stick) {
2937 int position = g_settings_get_int (info->settings, PANEL_OBJECT_POSITION_KEY"position");
2938 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)) {
2939 ad->pos = toplevel->priv->geometry.width - position;
2940 } else {
2941 ad->pos = toplevel->priv->geometry.height - position;
2942 }
2943 }
2944 }
2945 }
2946}
2947
2948static void
2949panel_toplevel_initially_hide (PanelToplevel *toplevel)
2950{
2951 if (!toplevel->priv->attached) {
2952 toplevel->priv->initial_animation_done = FALSE(0);
2953
2954 /* We start the panel off hidden until all the applets are
2955 * loaded, and then finally slide it down when it's ready to be
2956 * used */
2957 toplevel->priv->state = PANEL_STATE_AUTO_HIDDEN;
2958 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
2959 } else
2960 toplevel->priv->initial_animation_done = TRUE(!(0));
2961}
2962
2963static void
2964set_background_default_style (GtkWidget *widget)
2965{
2966 PanelToplevel *toplevel;
2967 GtkStyleContext *context;
2968 GtkStateFlags state;
2969 GdkRGBA *bg_color;
2970 cairo_pattern_t *bg_image;
2971
2972 if (!gtk_widget_get_realized (widget))
2973 return;
2974
2975 toplevel = PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
;
2976
2977 context = gtk_widget_get_style_context (widget);
2978 state = gtk_style_context_get_state (context);
2979
2980 gtk_style_context_get (context, state,
2981 "background-color", &bg_color,
2982 "background-image", &bg_image,
2983 NULL((void*)0));
2984
2985 panel_background_set_default_style (&toplevel->background,
2986 bg_color, bg_image);
2987
2988 if (bg_color)
2989 gdk_rgba_free (bg_color);
2990
2991 if (bg_image)
2992 cairo_pattern_destroy (bg_image);
2993}
2994
2995static void
2996panel_toplevel_realize (GtkWidget *widget)
2997{
2998 PanelToplevel *toplevel;
2999 GdkScreen *screen;
3000 GdkVisual *visual;
3001 GdkWindow *window;
3002
3003 toplevel = PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
;
3004
3005 screen = gtk_widget_get_screen (widget);
3006 visual = gdk_screen_get_rgba_visual (screen);
3007
3008 if (visual == NULL((void*)0))
3009 visual = gdk_screen_get_system_visual (screen);
3010
3011 gtk_widget_set_visual (widget, visual);
3012 gtk_window_stick (GTK_WINDOW (widget)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_window_get_type ()))))))
);
3013 gtk_window_set_decorated (GTK_WINDOW (widget)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_window_get_type ()))))))
, FALSE(0));
3014 gtk_window_stick (GTK_WINDOW (widget)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_window_get_type ()))))))
);
3015 gtk_window_set_type_hint (GTK_WINDOW (widget)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_window_get_type ()))))))
, GDK_WINDOW_TYPE_HINT_DOCK);
3016
3017 GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->realize (widget);
3018
3019 window = gtk_widget_get_window (widget);
3020 set_background_default_style (widget);
3021 panel_background_realized (&toplevel->background, window);
3022
3023#ifdef HAVE_X111
3024 if (GDK_IS_X11_WINDOW (window)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(window)); GType __t = ((gdk_x11_window_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
) {
3025 panel_struts_set_window_hint (toplevel);
3026 gdk_window_set_geometry_hints (window, NULL((void*)0), 0);
3027 }
3028#endif /* HAVE_X11 */
3029
3030 gdk_window_set_group (window, window);
3031 panel_toplevel_initially_hide (toplevel);
3032
3033 panel_toplevel_move_resize_window (toplevel, TRUE(!(0)), TRUE(!(0)));
3034}
3035
3036static void
3037panel_toplevel_disconnect_timeouts (PanelToplevel *toplevel)
3038{
3039 if (toplevel->priv->hide_timeout)
3040 g_source_remove (toplevel->priv->hide_timeout);
3041 toplevel->priv->hide_timeout = 0;
3042
3043 if (toplevel->priv->unhide_timeout)
3044 g_source_remove (toplevel->priv->unhide_timeout);
3045 toplevel->priv->unhide_timeout = 0;
3046
3047 if (toplevel->priv->animation_timeout)
3048 g_source_remove (toplevel->priv->animation_timeout);
3049 toplevel->priv->animation_timeout = 0;
3050}
3051
3052static void
3053panel_toplevel_unrealize (GtkWidget *widget)
3054{
3055 PanelToplevel *toplevel;
3056 toplevel = PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
;
3057 panel_toplevel_disconnect_timeouts (toplevel);
3058 panel_background_unrealized (&toplevel->background);
3059 GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->unrealize (widget);
3060}
3061
3062static void
3063panel_toplevel_dispose (GObject *widget)
3064{
3065 PanelToplevel *toplevel = (PanelToplevel *) widget;
3066
3067 g_clear_pointer (&toplevel->priv->settings_path, g_free)do { _Static_assert (sizeof *(&toplevel->priv->settings_path
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
((&toplevel->priv->settings_path)) _pp = (&toplevel
->priv->settings_path); __typeof__ (*(&toplevel->
priv->settings_path)) _ptr = *_pp; *_pp = ((void*)0); if (
_ptr) (g_free) (_ptr); } while (0)
;
3068
3069 if (toplevel->settings) {
3070 g_signal_handlers_disconnect_by_data (toplevel->settings, toplevel)g_signal_handlers_disconnect_matched ((toplevel->settings)
, G_SIGNAL_MATCH_DATA, 0, 0, ((void*)0), ((void*)0), (toplevel
))
;
3071 g_clear_object (&toplevel->settings)do { _Static_assert (sizeof *((&toplevel->settings)) ==
sizeof (gpointer), "Expression evaluates to false"); __typeof__
(((&toplevel->settings))) _pp = ((&toplevel->settings
)); __typeof__ (*((&toplevel->settings))) _ptr = *_pp;
*_pp = ((void*)0); if (_ptr) (g_object_unref) (_ptr); } while
(0)
;
3072 }
3073
3074 g_clear_object (&toplevel->queued_settings)do { _Static_assert (sizeof *((&toplevel->queued_settings
)) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(((&toplevel->queued_settings))) _pp = ((&toplevel
->queued_settings)); __typeof__ (*((&toplevel->queued_settings
))) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (g_object_unref
) (_ptr); } while (0)
;
3075
3076 if (toplevel->background_settings) {
3077 g_signal_handlers_disconnect_by_data (toplevel->background_settings, toplevel)g_signal_handlers_disconnect_matched ((toplevel->background_settings
), G_SIGNAL_MATCH_DATA, 0, 0, ((void*)0), ((void*)0), (toplevel
))
;
3078 g_clear_object (&toplevel->background_settings)do { _Static_assert (sizeof *((&toplevel->background_settings
)) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(((&toplevel->background_settings))) _pp = ((&toplevel
->background_settings)); __typeof__ (*((&toplevel->
background_settings))) _ptr = *_pp; *_pp = ((void*)0); if (_ptr
) (g_object_unref) (_ptr); } while (0)
;
3079 }
3080
3081 if (toplevel->priv->gtk_settings) {
3082 g_signal_handlers_disconnect_by_func (toplevel->priv->gtk_settings,g_signal_handlers_disconnect_matched ((toplevel->priv->
gtk_settings), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (panel_toplevel_drag_threshold_changed
))), (toplevel))
3083 G_CALLBACK (panel_toplevel_drag_threshold_changed),g_signal_handlers_disconnect_matched ((toplevel->priv->
gtk_settings), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (panel_toplevel_drag_threshold_changed
))), (toplevel))
3084 toplevel)g_signal_handlers_disconnect_matched ((toplevel->priv->
gtk_settings), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (panel_toplevel_drag_threshold_changed
))), (toplevel))
;
3085 toplevel->priv->gtk_settings = NULL((void*)0);
3086
3087 panel_background_free (&toplevel->background);
3088 }
3089
3090 if (toplevel->priv->attached) {
3091 panel_toplevel_disconnect_attached (toplevel);
3092 toplevel->priv->attached = FALSE(0);
3093
3094 toplevel->priv->attach_toplevel = NULL((void*)0);
3095 toplevel->priv->attach_widget = NULL((void*)0);
3096 }
3097
3098 g_clear_pointer (&toplevel->priv->description, g_free)do { _Static_assert (sizeof *(&toplevel->priv->description
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
((&toplevel->priv->description)) _pp = (&toplevel
->priv->description); __typeof__ (*(&toplevel->priv
->description)) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (
g_free) (_ptr); } while (0)
;
3099 g_clear_pointer (&toplevel->priv->name, g_free)do { _Static_assert (sizeof *(&toplevel->priv->name
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
((&toplevel->priv->name)) _pp = (&toplevel->
priv->name); __typeof__ (*(&toplevel->priv->name
)) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (g_free) (_ptr);
} while (0)
;
3100
3101 panel_toplevel_disconnect_timeouts (toplevel);
3102
3103 G_OBJECT_CLASS (panel_toplevel_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), (((GType) ((20) << (
2))))))))
->dispose (widget);
3104}
3105
3106static void
3107panel_toplevel_check_resize (GtkContainer *container)
3108{
3109 GtkAllocation allocation;
3110 GtkRequisition requisition;
3111 GtkWidget *widget;
3112
3113 widget = GTK_WIDGET (container)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((container)), ((gtk_widget_get_type ()))))))
;
3114
3115 if (!gtk_widget_get_visible (widget))
3116 return;
3117
3118 requisition.width = -1;
3119 requisition.height = -1;
3120
3121 gtk_widget_get_preferred_size (widget, &requisition, NULL((void*)0));
3122 gtk_widget_get_allocation (widget, &allocation);
3123
3124 allocation.width = requisition.width;
3125 allocation.height = requisition.height;
3126
3127 gtk_widget_size_allocate (widget, &allocation);
3128}
3129
3130static void
3131panel_toplevel_size_request (GtkWidget *widget,
3132 GtkRequisition *requisition)
3133{
3134 PanelToplevel *toplevel;
3135 GtkBin *bin;
3136 GtkWidget *child;
3137 GdkRectangle old_geometry;
3138 int position_changed = FALSE(0);
3139 int size_changed = FALSE(0);
3140
3141 toplevel = PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
;
3142 bin = GTK_BIN (widget)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_bin_get_type ()))))))
;
3143
3144 /* we get a size request when there are new monitors, so first try to
3145 * see if we need to move to a new monitor */
3146 panel_toplevel_update_monitor (toplevel);
3147
3148 child = gtk_bin_get_child (bin);
3149 if (child && gtk_widget_get_visible (child))
3150 gtk_widget_get_preferred_size (child, requisition, NULL((void*)0));
3151
3152 old_geometry = toplevel->priv->geometry;
3153
3154 panel_toplevel_update_geometry (toplevel, requisition);
3155
3156 requisition->width = toplevel->priv->geometry.width;
3157 requisition->height = toplevel->priv->geometry.height;
3158
3159 if (!gtk_widget_get_realized (widget))
3160 return;
3161
3162 if (old_geometry.width != toplevel->priv->geometry.width ||
3163 old_geometry.height != toplevel->priv->geometry.height)
3164 size_changed = TRUE(!(0));
3165
3166 if (old_geometry.x != toplevel->priv->geometry.x ||
3167 old_geometry.y != toplevel->priv->geometry.y)
3168 position_changed = TRUE(!(0));
3169
3170 panel_toplevel_move_resize_window (toplevel, position_changed, size_changed);
3171}
3172
3173static void
3174panel_toplevel_get_preferred_width (GtkWidget *widget,
3175 gint *minimum_width,
3176 gint *natural_width)
3177{
3178 GtkRequisition req;
3179 panel_toplevel_size_request (widget, &req);
3180 *minimum_width = *natural_width = req.width;
3181}
3182
3183static void
3184panel_toplevel_get_preferred_height (GtkWidget *widget,
3185 gint *minimum_height,
3186 gint *natural_height)
3187{
3188 GtkRequisition req;
3189 panel_toplevel_size_request (widget, &req);
3190 *minimum_height = *natural_height = req.height;
3191}
3192
3193static void
3194set_background_region (PanelToplevel *toplevel)
3195{
3196 GtkWidget *widget;
3197 GdkWindow *window;
3198 gint origin_x;
3199 gint origin_y;
3200 GtkAllocation allocation;
3201 GtkOrientation orientation;
3202
3203 widget = GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
;
3204
3205 if (!gtk_widget_get_realized (widget))
3206 return;
3207
3208 window = gtk_widget_get_window (widget);
3209 origin_x = -1;
3210 origin_y = -1;
3211
3212 gdk_window_get_origin (window, &origin_x, &origin_y);
3213 gtk_widget_get_allocation (widget, &allocation);
3214
3215 orientation = GTK_ORIENTATION_HORIZONTAL;
3216 if (toplevel->priv->orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT))
3217 orientation = GTK_ORIENTATION_VERTICAL;
3218
3219 panel_background_change_region (&toplevel->background, orientation,
3220 origin_x, origin_y,
3221 allocation.width, allocation.height);
3222}
3223
3224static void
3225panel_toplevel_size_allocate (GtkWidget *widget,
3226 GtkAllocation *allocation)
3227{
3228 PanelToplevel *toplevel = (PanelToplevel *) widget;
3229 GtkBin *bin = (GtkBin *) widget;
3230 GtkStyleContext *context;
3231 GtkStateFlags state;
3232 GtkBorder padding;
3233 GtkWidget *child;
3234 GtkAllocation challoc;
3235 GtkAllocation child_allocation;
3236
3237 gtk_widget_set_allocation (widget, allocation);
3238
3239 if (toplevel->priv->expand ||
3240 toplevel->priv->buttons_enabled ||
3241 toplevel->priv->attached)
3242 challoc = *allocation;
3243 else {
3244 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)) {
3245 challoc.x = HANDLE_SIZE10;
3246 challoc.y = 0;
3247 challoc.width = allocation->width - 2 * HANDLE_SIZE10;
3248 challoc.height = allocation->height;
3249 } else {
3250 challoc.x = 0;
3251 challoc.y = HANDLE_SIZE10;
3252 challoc.width = allocation->width;
3253 challoc.height = allocation->height - 2 * HANDLE_SIZE10;
3254 }
3255 }
3256
3257 state = gtk_widget_get_state_flags (widget);
3258 context = gtk_widget_get_style_context (widget);
3259 gtk_style_context_get_padding (context, state, &padding);
3260
3261 if (toplevel->priv->edges & PANEL_EDGE_TOP) {
3262 challoc.y += padding.top;
3263 challoc.height -= padding.top;
3264 }
3265
3266 if (toplevel->priv->edges & PANEL_EDGE_LEFT) {
3267 challoc.x += padding.left;
3268 challoc.width -= padding.left;
3269 }
3270
3271 if (toplevel->priv->edges & PANEL_EDGE_BOTTOM)
3272 challoc.height -= padding.bottom;
3273
3274 if (toplevel->priv->edges & PANEL_EDGE_RIGHT)
3275 challoc.width -= padding.right;
3276
3277 challoc.width = MAX (1, challoc.width)(((1) > (challoc.width)) ? (1) : (challoc.width));
3278 challoc.height = MAX (1, challoc.height)(((1) > (challoc.height)) ? (1) : (challoc.height));
3279
3280 child = gtk_bin_get_child (bin);
3281 gtk_widget_get_allocation (child, &child_allocation);
3282
3283 if (gtk_widget_get_mapped (widget) &&
3284 (challoc.x != child_allocation.x ||
3285 challoc.y != child_allocation.y ||
3286 challoc.width != child_allocation.width ||
3287 challoc.height != child_allocation.height)) {
3288 GtkAllocation allocation_to_invalidate;
3289
3290 gtk_widget_get_allocation (widget, &allocation_to_invalidate);
3291 gdk_window_invalidate_rect (gtk_widget_get_window (widget),
3292 &allocation_to_invalidate, FALSE(0));
3293 }
3294
3295 if (child && gtk_widget_get_visible (child))
3296 gtk_widget_size_allocate (child, &challoc);
3297
3298 set_background_region (toplevel);
3299}
3300
3301static gboolean panel_toplevel_draw(GtkWidget* widget, cairo_t* cr)
3302{
3303 PanelToplevel* toplevel = (PanelToplevel*) widget;
3304 PanelFrameEdge edges;
3305 gboolean retval = FALSE(0);
3306 int awidth;
3307 int aheight;
3308 GtkStyleContext *context;
3309 GtkStateFlags state;
3310 GtkBorder padding;
3311
3312 if (!gtk_widget_is_drawable (widget))
3313 return retval;
3314
3315 if (GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->draw)
3316 retval = GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->draw (widget, cr);
3317
3318 edges = toplevel->priv->edges;
3319 panel_frame_draw (widget, cr, edges);
3320
3321 if (toplevel->priv->expand ||
3322 toplevel->priv->buttons_enabled ||
3323 toplevel->priv->attached)
3324 return retval;
3325
3326 state = gtk_widget_get_state_flags (widget);
3327 awidth = gtk_widget_get_allocated_width (widget);
3328 aheight = gtk_widget_get_allocated_height (widget);
3329
3330 context = gtk_widget_get_style_context (widget);
3331 gtk_style_context_get_padding (context, state, &padding);
3332
3333 gtk_style_context_save (context);
3334 gtk_style_context_set_state (context, state);
3335
3336 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)) {
3337 int x, y, width, height;
3338
3339 x = 0;
3340 y = 0;
3341 height = aheight;
3342 width = HANDLE_SIZE10;
3343
3344 if (edges & PANEL_EDGE_TOP) {
3345 y += padding.top;
3346 height -= padding.top;
3347 }
3348 if (edges & PANEL_EDGE_BOTTOM)
3349 height -= padding.bottom;
3350 if (edges & PANEL_EDGE_LEFT)
3351 x += padding.left;
3352
3353 cairo_save (cr);
3354 gtk_render_handle (context, cr, x, y, width, height);
3355 cairo_restore (cr);
3356
3357 x = awidth - HANDLE_SIZE10;
3358 if (edges & PANEL_EDGE_RIGHT)
3359 x -= padding.right;
3360
3361 cairo_save (cr);
3362 gtk_render_handle (context, cr, x, y, width, height);
3363 cairo_restore (cr);
3364 } else {
3365 int x, y, width, height;
3366
3367 x = 0;
3368 y = 0;
3369 width = awidth;
3370 height = HANDLE_SIZE10;
3371
3372 if (edges & PANEL_EDGE_LEFT) {
3373 x += padding.left;
3374 width -= padding.left;
3375 }
3376 if (edges & PANEL_EDGE_RIGHT)
3377 width -= padding.right;
3378 if (edges & PANEL_EDGE_TOP)
3379 y += padding.top;
3380
3381 cairo_save (cr);
3382 gtk_render_handle (context, cr, x, y, width, height);
3383 cairo_restore (cr);
3384
3385 y = aheight - HANDLE_SIZE10;
3386 if (edges & PANEL_EDGE_BOTTOM)
3387 y -= padding.bottom;
3388
3389 cairo_save (cr);
3390 gtk_render_handle (context, cr, x, y, width, height);
3391 cairo_restore (cr);
3392 }
3393
3394 gtk_style_context_restore (context);
3395
3396 return retval;
3397}
3398
3399static gboolean
3400panel_toplevel_button_press_event (GtkWidget *widget,
3401 GdkEventButton *event)
3402{
3403 PanelToplevel *toplevel;
3404 GtkWidget *event_widget;
3405
3406 g_return_val_if_fail (PANEL_IS_TOPLEVEL (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (widget)"); return ((0)); }
} while (0)
;
3407
3408 toplevel = PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
;
3409
3410 if (event->button != 1 && event->button != 2)
3411 return FALSE(0);
3412
3413 if (toplevel->priv->animating)
3414 return FALSE(0);
3415
3416 /* Get the mouse-button modifier from marco so that only intentional
3417 * moves are considered. We don't this for non-expanded panels since we
3418 * only have the handles that the user can grab. */
3419 if ((toplevel->priv->expand || toplevel->priv->attached) &&
3420 (event->state & GDK_MODIFIER_MASK) != panel_bindings_get_mouse_button_modifier_keymask ())
3421 return FALSE(0);
3422
3423 gdk_window_get_user_data (event->window, (gpointer)&event_widget);
3424 g_assert (GTK_IS_WIDGET (event_widget))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((event_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_assertion_message_expr (((gchar*) 0), "panel-toplevel.c", 3424
, ((const char*) (__func__)), "GTK_IS_WIDGET (event_widget)")
; } while (0)
;
3425 gtk_widget_translate_coordinates (event_widget,
3426 widget,
3427 event->x,
3428 event->y,
3429 &toplevel->priv->drag_offset_x,
3430 &toplevel->priv->drag_offset_y);
3431
3432 panel_toplevel_begin_grab_op (toplevel, PANEL_GRAB_OP_MOVE, FALSE(0), event->time);
3433
3434 return TRUE(!(0));
3435}
3436
3437static gboolean
3438panel_toplevel_button_release_event (GtkWidget *widget,
3439 GdkEventButton *event)
3440{
3441 PanelToplevel *toplevel;
3442
3443 if (event->button != 1 && event->button != 2)
3444 return FALSE(0);
3445
3446 toplevel = PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
;
3447
3448 if (toplevel->priv->grab_op == PANEL_GRAB_OP_NONE)
3449 return FALSE(0);
3450
3451 if (toplevel->priv->grab_is_keyboard)
3452 return FALSE(0);
3453
3454 panel_toplevel_end_grab_op (toplevel, event->time);
3455
3456 return TRUE(!(0));
3457}
3458
3459static gboolean
3460panel_toplevel_configure_event (GtkWidget *widget,
3461 GdkEventConfigure *event)
3462{
3463 PanelToplevel *toplevel;
3464
3465 toplevel = PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
;
3466
3467 set_background_region (toplevel);
3468
3469 return TRUE(!(0));
3470}
3471
3472static gboolean
3473panel_toplevel_key_press_event (GtkWidget *widget,
3474 GdkEventKey *event)
3475{
3476 PanelToplevel *toplevel = (PanelToplevel *) widget;
3477
3478 if (toplevel->priv->grab_op != PANEL_GRAB_OP_NONE &&
3479 panel_toplevel_handle_grab_op_key_event (toplevel, event))
3480 return TRUE(!(0));
3481
3482 if (GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->key_press_event)
3483 return GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->key_press_event (widget, event);
3484
3485 return FALSE(0);
3486}
3487
3488static void
3489panel_toplevel_state_flags_changed (GtkWidget *widget,
3490 GtkStateFlags previous_state)
3491{
3492 GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->state_flags_changed (widget,
3493 previous_state);
3494
3495 set_background_default_style (widget);
3496}
3497
3498static gboolean
3499panel_toplevel_motion_notify_event (GtkWidget *widget,
3500 GdkEventMotion *event)
3501{
3502 if (gdk_event_get_screen ((GdkEvent *)event) ==
3503 gtk_window_get_screen (GTK_WINDOW (widget)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_window_get_type ()))))))
))
3504 return panel_toplevel_handle_grab_op_motion_event (
3505 PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
, event);
3506 else
3507 return FALSE(0);
3508}
3509
3510static gboolean
3511panel_toplevel_animation_timeout (PanelToplevel *toplevel)
3512{
3513 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
3514
3515 if (!toplevel->priv->animating) {
3516 toplevel->priv->animation_end_x = 0xdead;
3517 toplevel->priv->animation_end_y = 0xdead;
3518 toplevel->priv->animation_end_width = 0xdead;
3519 toplevel->priv->animation_end_height = 0xdead;
3520 toplevel->priv->animation_start_time = 0xdead;
3521 toplevel->priv->animation_duration_time = 0xdead;
3522 toplevel->priv->animation_timeout = 0;
3523 toplevel->priv->initial_animation_done = TRUE(!(0));
3524 }
3525
3526 return toplevel->priv->animating;
3527}
3528
3529static GTimeSpan
3530panel_toplevel_get_animation_time (PanelToplevel *toplevel)
3531{
3532 /* The number of seconds to complete the animation.
3533 */
3534#define ANIMATION_TIME_FAST 400
3535#define ANIMATION_TIME_MEDIUM 1200
3536#define ANIMATION_TIME_SLOW 2000
3537
3538 GTimeSpan t;
3539
3540 switch (toplevel->priv->animation_speed) {
3541 case PANEL_ANIMATION_SLOW:
3542 t = ANIMATION_TIME_SLOW * G_TIME_SPAN_MILLISECOND((1000L));
3543 break;
3544 case PANEL_ANIMATION_MEDIUM:
3545 t = ANIMATION_TIME_MEDIUM * G_TIME_SPAN_MILLISECOND((1000L));
3546 break;
3547 case PANEL_ANIMATION_FAST:
3548 t = ANIMATION_TIME_FAST * G_TIME_SPAN_MILLISECOND((1000L));
3549 break;
3550 default:
3551 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 3551, ((const char*) (__func__)), ((void*)0)); } while (0)
;
3552 break;
3553 }
3554
3555 return t;
3556
3557#undef ANIMATION_TIME_FAST
3558#undef ANIMATION_TIME_MEDIUM
3559#undef ANIMATION_TIME_SLOW
3560}
3561
3562static void
3563panel_toplevel_calculate_animation_end_geometry (PanelToplevel *toplevel)
3564{
3565 GdkRectangle monitor_geom;
3566
3567 toplevel->priv->animation_end_x = toplevel->priv->x;
3568 toplevel->priv->animation_end_y = toplevel->priv->y;
3569 toplevel->priv->animation_end_width = -1;
3570 toplevel->priv->animation_end_height = -1;
3571
3572 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
3573
3574 if (!toplevel->priv->expand) {
3575
3576 if (toplevel->priv->x_centered)
3577 toplevel->priv->animation_end_x =
3578 (monitor_geom.width - toplevel->priv->geometry.width) / 2;
3579 if (toplevel->priv->y_centered)
3580 toplevel->priv->animation_end_y =
3581 (monitor_geom.height - toplevel->priv->geometry.height) / 2;
3582 }
3583
3584 /* we consider the toplevels which are in the initial animation stage
3585 * as in a normal state */
3586 if (toplevel->priv->state == PANEL_STATE_NORMAL ||
3587 (!toplevel->priv->initial_animation_done &&
3588 !toplevel->priv->auto_hide))
3589 panel_toplevel_update_normal_position (toplevel,
3590 &toplevel->priv->animation_end_x,
3591 &toplevel->priv->animation_end_y,
3592 &toplevel->priv->animation_end_width,
3593 &toplevel->priv->animation_end_height);
3594
3595 else if (toplevel->priv->state == PANEL_STATE_AUTO_HIDDEN)
3596 panel_toplevel_update_auto_hide_position (toplevel,
3597 &toplevel->priv->animation_end_x,
3598 &toplevel->priv->animation_end_y,
3599 &toplevel->priv->animation_end_width,
3600 &toplevel->priv->animation_end_height,
3601 TRUE(!(0)));
3602 else
3603 panel_toplevel_update_hidden_position (toplevel,
3604 &toplevel->priv->animation_end_x,
3605 &toplevel->priv->animation_end_y,
3606 &toplevel->priv->animation_end_width,
3607 &toplevel->priv->animation_end_height);
3608}
3609
3610static void
3611panel_toplevel_start_animation (PanelToplevel *toplevel)
3612{
3613 GtkRequisition requisition;
3614 int deltax, deltay, deltaw = 0, deltah = 0;
3615 int cur_x = -1, cur_y = -1;
3616
3617 panel_toplevel_calculate_animation_end_geometry (toplevel);
3618
3619 toplevel->priv->animating = TRUE(!(0));
3620
3621 panel_toplevel_update_struts (toplevel, TRUE(!(0)));
3622#ifdef HAVE_X111
3623 if (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel)))(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gtk_widget_get_display (((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((toplevel)), ((gtk_widget_get_type ()))))
))))); GType __t = ((gdk_x11_display_get_type())); gboolean __r
; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
) {
3624 panel_struts_update_toplevel_geometry (toplevel,
3625 &toplevel->priv->animation_end_x,
3626 &toplevel->priv->animation_end_y,
3627 &toplevel->priv->animation_end_width,
3628 &toplevel->priv->animation_end_height);
3629 }
3630#endif /* HAVE_X11 */
3631 panel_toplevel_update_struts (toplevel, FALSE(0));
3632
3633 gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
), &cur_x, &cur_y);
3634
3635 cur_x -= panel_multimonitor_x (toplevel->priv->monitor);
3636 cur_y -= panel_multimonitor_y (toplevel->priv->monitor);
3637
3638 deltax = toplevel->priv->animation_end_x - cur_x;
3639 deltay = toplevel->priv->animation_end_y - cur_y;
3640
3641 gtk_widget_get_preferred_size (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
, &requisition, NULL((void*)0));
3642
3643 if (toplevel->priv->animation_end_width != -1)
3644 deltaw = toplevel->priv->animation_end_width - requisition.width;
3645
3646 if (toplevel->priv->animation_end_height != -1)
3647 deltah = toplevel->priv->animation_end_height - requisition.height;
3648
3649 if (deltax == 0 && deltay == 0 && deltaw == 0 && deltah == 0) {
3650 toplevel->priv->animation_end_x = -1;
3651 toplevel->priv->animation_end_y = -1;
3652 toplevel->priv->animation_end_width = -1;
3653 toplevel->priv->animation_end_height = -1;
3654 toplevel->priv->animating = FALSE(0);
3655 return;
3656 }
3657
3658 if (toplevel->priv->attached) {
3659 /* Re-map unmapped attached toplevels */
3660 if (!gtk_widget_get_visible (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
))
3661 gtk_widget_set_visible (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
, TRUE(!(0)));
3662
3663 if (!gtk_widget_get_mapped (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
))
3664 gtk_widget_map (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
3665
3666 gtk_window_present (GTK_WINDOW (toplevel->priv->attach_toplevel)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->attach_toplevel)), ((gtk_window_get_type
()))))))
);
3667 }
3668
3669 toplevel->priv->animation_start_time = g_get_monotonic_time ();
3670 toplevel->priv->animation_duration_time = panel_toplevel_get_animation_time (toplevel);
3671
3672 if (!toplevel->priv->animation_timeout)
3673 toplevel->priv->animation_timeout =
3674 g_timeout_add (20, (GSourceFunc) panel_toplevel_animation_timeout, toplevel);
3675}
3676
3677void
3678panel_toplevel_hide (PanelToplevel *toplevel,
3679 gboolean auto_hide,
3680 gint direction)
3681{
3682 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
3683
3684 if (toplevel->priv->state != PANEL_STATE_NORMAL)
3685 return;
3686
3687 g_signal_emit (toplevel, toplevel_signals [HIDE_SIGNAL], 0);
3688
3689 if (toplevel->priv->attach_toplevel)
3690 panel_toplevel_pop_autohide_disabler (toplevel->priv->attach_toplevel);
3691
3692 if (auto_hide)
3693 toplevel->priv->state = PANEL_STATE_AUTO_HIDDEN;
3694 else {
3695 GtkDirectionType hide_direction;
3696
3697 if (direction == -1) {
3698 if (toplevel->priv->orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT))
3699 hide_direction = GTK_DIR_UP;
3700 else
3701 hide_direction = GTK_DIR_LEFT;
3702 } else {
3703 hide_direction = (GtkDirectionType) direction;
3704 }
3705
3706 switch (hide_direction) {
3707 case GTK_DIR_UP:
3708 g_return_if_fail (toplevel->priv->orientation & PANEL_VERTICAL_MASK)do { if ((toplevel->priv->orientation & (PANEL_ORIENTATION_LEFT
| PANEL_ORIENTATION_RIGHT))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "toplevel->priv->orientation & PANEL_VERTICAL_MASK"
); return; } } while (0)
;
3709 toplevel->priv->state = PANEL_STATE_HIDDEN_UP;
3710 break;
3711 case GTK_DIR_DOWN:
3712 g_return_if_fail (toplevel->priv->orientation & PANEL_VERTICAL_MASK)do { if ((toplevel->priv->orientation & (PANEL_ORIENTATION_LEFT
| PANEL_ORIENTATION_RIGHT))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "toplevel->priv->orientation & PANEL_VERTICAL_MASK"
); return; } } while (0)
;
3713 toplevel->priv->state = PANEL_STATE_HIDDEN_DOWN;
3714 break;
3715 case GTK_DIR_LEFT:
3716 g_return_if_fail (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK)do { if ((toplevel->priv->orientation & (PANEL_ORIENTATION_TOP
| PANEL_ORIENTATION_BOTTOM))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "toplevel->priv->orientation & PANEL_HORIZONTAL_MASK"
); return; } } while (0)
;
3717 toplevel->priv->state = PANEL_STATE_HIDDEN_LEFT;
3718 break;
3719 case GTK_DIR_RIGHT:
3720 g_return_if_fail (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK)do { if ((toplevel->priv->orientation & (PANEL_ORIENTATION_TOP
| PANEL_ORIENTATION_BOTTOM))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "toplevel->priv->orientation & PANEL_HORIZONTAL_MASK"
); return; } } while (0)
;
3721 toplevel->priv->state = PANEL_STATE_HIDDEN_RIGHT;
3722 break;
3723 default:
3724 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 3724, ((const char*) (__func__)), ((void*)0)); } while (0)
;
3725 break;
3726 }
3727
3728 panel_toplevel_update_hide_buttons (toplevel);
3729 }
3730
3731 if (toplevel->priv->animate && gtk_widget_get_realized (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
)) {
3732 panel_toplevel_start_animation (toplevel);
3733 }
3734
3735 /* if the toplevel is attached (-> drawer), hide it after the animation
3736 * this hides the hide button properly as well */
3737 if (toplevel->priv->attached) {
3738 gtk_widget_hide (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
3739 }
3740
3741 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
3742}
3743
3744static gboolean
3745panel_toplevel_auto_hide_timeout_handler (PanelToplevel *toplevel)
3746{
3747 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return ((0));
} } while (0)
;
3748
3749 if (panel_toplevel_get_autohide_disabled (toplevel)) {
3750 toplevel->priv->hide_timeout = 0;
3751 return FALSE(0);
3752 }
3753
3754 /* keep coming back until the animation has finished.
3755 * FIXME: we should really remove the timeout/idle
3756 * completely and re-instate it when the
3757 * animation has finished.
3758 */
3759 if (toplevel->priv->animating)
3760 return TRUE(!(0));
3761
3762 panel_toplevel_hide (toplevel, TRUE(!(0)), -1);
3763
3764 toplevel->priv->hide_timeout = 0;
3765
3766 return FALSE(0);
3767}
3768
3769void
3770panel_toplevel_unhide (PanelToplevel *toplevel)
3771{
3772 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
3773
3774 if (toplevel->priv->state == PANEL_STATE_NORMAL)
3775 return;
3776
3777 toplevel->priv->state = PANEL_STATE_NORMAL;
3778
3779 panel_toplevel_update_hide_buttons (toplevel);
3780
3781 if (toplevel->priv->attach_toplevel)
3782 panel_toplevel_push_autohide_disabler (toplevel->priv->attach_toplevel);
3783
3784 if (toplevel->priv->animate && gtk_widget_get_realized (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
)) {
3785 panel_toplevel_start_animation (toplevel);
3786 }
3787
3788 /* if the toplevel is attached (-> drawer), unhide it after the animation
3789 * (same as for hide) */
3790 if (toplevel->priv->attached) {
3791 gtk_widget_show (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
3792 }
3793
3794 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
3795
3796 if (!toplevel->priv->animate)
3797 g_signal_emit (toplevel, toplevel_signals [UNHIDE_SIGNAL], 0);
3798}
3799
3800static gboolean
3801panel_toplevel_auto_unhide_timeout_handler (PanelToplevel *toplevel)
3802{
3803 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return ((0));
} } while (0)
;
3804
3805 /* keep coming back until the animation has finished.
3806 * FIXME: we should really remove the timeout/idle
3807 * completely and re-instate it when the
3808 * animation has finished.
3809 */
3810 if (toplevel->priv->animating)
3811 return TRUE(!(0));
3812
3813 if (!toplevel->priv->animate)
3814 toplevel->priv->initial_animation_done = TRUE(!(0));
3815
3816 /* initial animation for auto-hidden panels: we need to unhide and hide
3817 * again to get at the right size */
3818 if (!toplevel->priv->initial_animation_done &&
3819 toplevel->priv->auto_hide) {
3820 toplevel->priv->unhide_timeout = 0;
3821 panel_toplevel_unhide (toplevel);
3822 panel_toplevel_hide (toplevel, TRUE(!(0)), -1);
3823 return FALSE(0);
3824 }
3825
3826 if (!panel_toplevel_contains_pointer (toplevel) &&
3827 toplevel->priv->auto_hide) {
3828 toplevel->priv->unhide_timeout = 0;
3829 return FALSE(0);
3830 }
3831
3832 panel_toplevel_unhide (toplevel);
3833
3834 toplevel->priv->unhide_timeout = 0;
3835
3836 return FALSE(0);
3837}
3838
3839void
3840panel_toplevel_queue_auto_hide (PanelToplevel *toplevel)
3841{
3842 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
3843
3844 if (!toplevel->priv->auto_hide ||
3845 panel_toplevel_contains_pointer (toplevel) ||
3846 panel_toplevel_get_autohide_disabled (toplevel))
3847 return;
3848
3849 if (toplevel->priv->unhide_timeout)
3850 g_source_remove (toplevel->priv->unhide_timeout);
3851 toplevel->priv->unhide_timeout = 0;
3852
3853 if (toplevel->priv->hide_timeout ||
3854 toplevel->priv->state != PANEL_STATE_NORMAL)
3855 return;
3856
3857 if (toplevel->priv->hide_delay > 0)
3858 toplevel->priv->hide_timeout =
3859 g_timeout_add (toplevel->priv->hide_delay,
3860 (GSourceFunc) panel_toplevel_auto_hide_timeout_handler,
3861 toplevel);
3862 else
3863 toplevel->priv->hide_timeout =
3864 g_idle_add ((GSourceFunc) panel_toplevel_auto_hide_timeout_handler,
3865 toplevel);
3866}
3867
3868void
3869panel_toplevel_queue_auto_unhide (PanelToplevel *toplevel)
3870{
3871 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
3872
3873 if (toplevel->priv->unhide_timeout)
3874 return;
3875
3876 if (toplevel->priv->hide_timeout)
3877 g_source_remove (toplevel->priv->hide_timeout);
3878 toplevel->priv->hide_timeout = 0;
3879
3880 if (toplevel->priv->state != PANEL_STATE_AUTO_HIDDEN)
3881 return;
3882
3883 if (toplevel->priv->unhide_delay > 0)
3884 toplevel->priv->unhide_timeout =
3885 g_timeout_add (toplevel->priv->unhide_delay,
3886 (GSourceFunc) panel_toplevel_auto_unhide_timeout_handler,
3887 toplevel);
3888 else
3889 toplevel->priv->unhide_timeout =
3890 g_idle_add ((GSourceFunc) panel_toplevel_auto_unhide_timeout_handler,
3891 toplevel);
3892}
3893
3894void
3895panel_toplevel_queue_initial_unhide (PanelToplevel *toplevel)
3896{
3897 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
3898
3899 if (toplevel->priv->initial_animation_done)
3900 return;
3901
3902 if (toplevel->priv->unhide_timeout)
3903 return;
3904
3905 toplevel->priv->unhide_timeout =
3906 g_idle_add ((GSourceFunc) panel_toplevel_auto_unhide_timeout_handler,
3907 toplevel);
3908}
3909
3910static gboolean
3911panel_toplevel_enter_notify_event (GtkWidget *widget,
3912 GdkEventCrossing *event)
3913{
3914 PanelToplevel *toplevel;
3915
3916 g_return_val_if_fail (PANEL_IS_TOPLEVEL (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (widget)"); return ((0)); }
} while (0)
;
3917
3918 toplevel = PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
;
3919
3920 if (toplevel->priv->auto_hide && event->detail != GDK_NOTIFY_INFERIOR)
3921 panel_toplevel_queue_auto_unhide (toplevel);
3922
3923 if (GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->enter_notify_event)
3924 return GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->enter_notify_event (widget, event);
3925
3926 return FALSE(0);
3927}
3928
3929static gboolean
3930panel_toplevel_leave_notify_event (GtkWidget *widget,
3931 GdkEventCrossing *event)
3932{
3933 PanelToplevel *toplevel;
3934
3935 g_return_val_if_fail (PANEL_IS_TOPLEVEL (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (widget)"); return ((0)); }
} while (0)
;
3936
3937 toplevel = PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
;
3938
3939 if (toplevel->priv->auto_hide && event->detail != GDK_NOTIFY_INFERIOR)
3940 panel_toplevel_queue_auto_hide (toplevel);
3941
3942 if (GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->leave_notify_event)
3943 return GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->leave_notify_event (widget, event);
3944
3945 return FALSE(0);
3946}
3947
3948static gboolean
3949panel_toplevel_focus_in_event (GtkWidget *widget,
3950 GdkEventFocus *event)
3951{
3952 PanelToplevel *toplevel = PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
;
3953
3954 if (toplevel->priv->state == PANEL_STATE_AUTO_HIDDEN)
3955 panel_toplevel_unhide (toplevel);
3956
3957 if (GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->focus_in_event)
3958 return GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->focus_in_event (widget, event);
3959
3960 return FALSE(0);
3961}
3962
3963static gboolean
3964panel_toplevel_focus_out_event (GtkWidget *widget,
3965 GdkEventFocus *event)
3966{
3967 PanelToplevel *toplevel = PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
;
3968
3969 /* It appears that sometimes we don't get a leave notify event,
3970 but just a focus in/out, so queue the autohide in that case.
3971 If the pointer is inside the panel then obviously we won't hide */
3972 if (toplevel->priv->auto_hide)
3973 panel_toplevel_queue_auto_hide (toplevel);
3974
3975 if (GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->focus_out_event)
3976 return GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->focus_out_event (widget, event);
3977
3978 return FALSE(0);
3979}
3980
3981static void
3982panel_toplevel_style_updated (GtkWidget *widget)
3983{
3984 panel_toplevel_update_hide_buttons (PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
);
3985
3986 if (GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->style_updated)
3987 GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->style_updated (widget);
3988
3989 set_background_default_style (widget);
3990}
3991
3992static void
3993panel_toplevel_drag_threshold_changed (PanelToplevel *toplevel)
3994{
3995 int threshold;
3996
3997 threshold = 0;
3998 g_object_get (G_OBJECT (toplevel->priv->gtk_settings)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->gtk_settings)), (((GType) ((20) <<
(2))))))))
,
3999 "gtk-dnd-drag-threshold", &threshold,
4000 NULL((void*)0));
4001
4002 if (threshold)
4003 toplevel->priv->snap_tolerance = threshold * SNAP_TOLERANCE_FACTOR6;
4004}
4005
4006static void
4007panel_toplevel_update_gtk_settings (PanelToplevel *toplevel)
4008{
4009 if (toplevel->priv->gtk_settings)
4010 g_signal_handlers_disconnect_by_func (toplevel->priv->gtk_settings,g_signal_handlers_disconnect_matched ((toplevel->priv->
gtk_settings), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (panel_toplevel_drag_threshold_changed
))), (toplevel))
4011 G_CALLBACK (panel_toplevel_drag_threshold_changed),g_signal_handlers_disconnect_matched ((toplevel->priv->
gtk_settings), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (panel_toplevel_drag_threshold_changed
))), (toplevel))
4012 toplevel)g_signal_handlers_disconnect_matched ((toplevel->priv->
gtk_settings), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (panel_toplevel_drag_threshold_changed
))), (toplevel))
;
4013
4014 toplevel->priv->gtk_settings = gtk_widget_get_settings (GTK_WIDGET (toplevel->priv->panel_widget)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->panel_widget)), ((gtk_widget_get_type
()))))))
);
4015
4016 g_signal_connect_swapped (toplevel->priv->gtk_settings, "notify::gtk-dnd-drag-threshold",g_signal_connect_data ((toplevel->priv->gtk_settings), (
"notify::gtk-dnd-drag-threshold"), (((GCallback) (panel_toplevel_drag_threshold_changed
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
4017 G_CALLBACK (panel_toplevel_drag_threshold_changed),g_signal_connect_data ((toplevel->priv->gtk_settings), (
"notify::gtk-dnd-drag-threshold"), (((GCallback) (panel_toplevel_drag_threshold_changed
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
4018 toplevel)g_signal_connect_data ((toplevel->priv->gtk_settings), (
"notify::gtk-dnd-drag-threshold"), (((GCallback) (panel_toplevel_drag_threshold_changed
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
;
4019
4020 panel_toplevel_drag_threshold_changed (toplevel);
4021}
4022
4023static void
4024panel_toplevel_screen_changed (GtkWidget *widget,
4025 GdkScreen *previous_screen)
4026{
4027 panel_toplevel_update_gtk_settings (PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
);
4028
4029 if (GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->screen_changed)
4030 GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->screen_changed (widget, previous_screen);
4031
4032 gtk_widget_queue_resize (widget);
4033}
4034
4035static void
4036panel_toplevel_set_property (GObject *object,
4037 guint prop_id,
4038 const GValue *value,
4039 GParamSpec *pspec)
4040{
4041 PanelToplevel *toplevel;
4042
4043 g_return_if_fail (PANEL_IS_TOPLEVEL (object))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((object)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (object)"); return; } } while
(0)
;
4044
4045 toplevel = PANEL_TOPLEVEL (object)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((panel_toplevel_get_type ()))))))
;
4046
4047 switch (prop_id) {
4048 case PROP_NAME:
4049 panel_toplevel_set_name (toplevel, g_value_get_string (value));
4050 break;
4051 case PROP_SETTINGS_PATH:
4052 panel_toplevel_set_settings_path (toplevel, g_value_get_string (value));
4053 break;
4054 case PROP_EXPAND:
4055 panel_toplevel_set_expand (toplevel, g_value_get_boolean (value));
4056 break;
4057 case PROP_ORIENTATION:
4058 panel_toplevel_set_orientation (toplevel, g_value_get_enum (value));
4059 break;
4060 case PROP_SIZE:
4061 panel_toplevel_set_size (toplevel, g_value_get_int (value));
4062 break;
4063 case PROP_X:
4064 panel_toplevel_set_x (toplevel,
4065 g_value_get_int (value),
4066 toplevel->priv->x_right,
4067 toplevel->priv->x_centered);
4068 break;
4069 case PROP_X_RIGHT:
4070 panel_toplevel_set_x (toplevel,
4071 toplevel->priv->x,
4072 g_value_get_int (value),
4073 toplevel->priv->x_centered);
4074 break;
4075 case PROP_X_CENTERED:
4076 panel_toplevel_set_x (toplevel,
4077 toplevel->priv->x,
4078 toplevel->priv->x_right,
4079 g_value_get_boolean (value));
4080 break;
4081 case PROP_Y:
4082 panel_toplevel_set_y (toplevel,
4083 g_value_get_int (value),
4084 toplevel->priv->y_bottom,
4085 toplevel->priv->y_centered);
4086 break;
4087 case PROP_Y_BOTTOM:
4088 panel_toplevel_set_y (toplevel,
4089 toplevel->priv->y,
4090 g_value_get_int (value),
4091 toplevel->priv->y_centered);
4092 break;
4093 case PROP_Y_CENTERED:
4094 panel_toplevel_set_y (toplevel,
4095 toplevel->priv->y,
4096 toplevel->priv->y_bottom,
4097 g_value_get_boolean (value));
4098 break;
4099 case PROP_MONITOR:
4100 panel_toplevel_set_monitor (toplevel, g_value_get_int (value));
4101 break;
4102 case PROP_AUTOHIDE:
4103 panel_toplevel_set_auto_hide (toplevel, g_value_get_boolean (value));
4104 break;
4105 case PROP_HIDE_DELAY:
4106 panel_toplevel_set_hide_delay (toplevel, g_value_get_int (value));
4107 break;
4108 case PROP_UNHIDE_DELAY:
4109 panel_toplevel_set_unhide_delay (toplevel, g_value_get_int (value));
4110 break;
4111 case PROP_AUTOHIDE_SIZE:
4112 panel_toplevel_set_auto_hide_size (toplevel, g_value_get_int (value));
4113 break;
4114 case PROP_ANIMATE:
4115 panel_toplevel_set_animate (toplevel, g_value_get_boolean (value));
4116 break;
4117 case PROP_ANIMATION_SPEED:
4118 panel_toplevel_set_animation_speed (toplevel, g_value_get_enum (value));
4119 break;
4120 case PROP_BUTTONS_ENABLED:
4121 panel_toplevel_set_enable_buttons (toplevel, g_value_get_boolean (value));
4122 break;
4123 case PROP_ARROWS_ENABLED:
4124 panel_toplevel_set_enable_arrows (toplevel, g_value_get_boolean (value));
4125 break;
4126 default:
4127 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "panel-toplevel.c", 4127, ("property"), _glib__property_id,
_glib__pspec->name, g_type_name ((((((GTypeClass*) (((GTypeInstance
*) (_glib__pspec))->g_class))->g_type)))), (g_type_name
((((((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
4128 break;
4129 }
4130}
4131
4132static void
4133panel_toplevel_get_property (GObject *object,
4134 guint prop_id,
4135 GValue *value,
4136 GParamSpec *pspec)
4137{
4138 PanelToplevel *toplevel;
4139
4140 g_return_if_fail (PANEL_IS_TOPLEVEL (object))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((object)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (object)"); return; } } while
(0)
;
4141
4142 toplevel = PANEL_TOPLEVEL (object)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((panel_toplevel_get_type ()))))))
;
4143
4144 switch (prop_id) {
4145 case PROP_NAME:
4146 g_value_set_string (value, panel_toplevel_get_name (toplevel));
4147 break;
4148 case PROP_SETTINGS_PATH:
4149 g_value_set_string (value, toplevel->priv->settings_path);
4150 break;
4151 case PROP_EXPAND:
4152 g_value_set_boolean (value, toplevel->priv->expand);
4153 break;
4154 case PROP_ORIENTATION:
4155 g_value_set_enum (value, toplevel->priv->orientation);
4156 break;
4157 case PROP_SIZE:
4158 g_value_set_int (value, toplevel->priv->size);
4159 break;
4160 case PROP_X:
4161 g_value_set_int (value, toplevel->priv->x);
4162 break;
4163 case PROP_X_RIGHT:
4164 g_value_set_int (value, toplevel->priv->x_right);
4165 break;
4166 case PROP_X_CENTERED:
4167 g_value_set_boolean (value, toplevel->priv->x_centered);
4168 break;
4169 case PROP_Y:
4170 g_value_set_int (value, toplevel->priv->y);
4171 break;
4172 case PROP_Y_BOTTOM:
4173 g_value_set_int (value, toplevel->priv->y_bottom);
4174 break;
4175 case PROP_Y_CENTERED:
4176 g_value_set_boolean (value, toplevel->priv->y_centered);
4177 break;
4178 case PROP_MONITOR:
4179 g_value_set_int (value, toplevel->priv->monitor);
4180 break;
4181 case PROP_AUTOHIDE:
4182 g_value_set_boolean (value, toplevel->priv->auto_hide);
4183 break;
4184 case PROP_HIDE_DELAY:
4185 g_value_set_int (value, toplevel->priv->hide_delay);
4186 break;
4187 case PROP_UNHIDE_DELAY:
4188 g_value_set_int (value, toplevel->priv->unhide_delay);
4189 break;
4190 case PROP_AUTOHIDE_SIZE:
4191 g_value_set_int (value, toplevel->priv->auto_hide_size);
4192 break;
4193 case PROP_ANIMATE:
4194 g_value_set_boolean (value, toplevel->priv->animate);
4195 break;
4196 case PROP_ANIMATION_SPEED:
4197 g_value_set_enum (value, toplevel->priv->animation_speed);
4198 break;
4199 case PROP_BUTTONS_ENABLED:
4200 g_value_set_boolean (value, toplevel->priv->buttons_enabled);
4201 break;
4202 case PROP_ARROWS_ENABLED:
4203 g_value_set_boolean (value, toplevel->priv->arrows_enabled);
4204 break;
4205 default:
4206 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "panel-toplevel.c", 4206, ("property"), _glib__property_id,
_glib__pspec->name, g_type_name ((((((GTypeClass*) (((GTypeInstance
*) (_glib__pspec))->g_class))->g_type)))), (g_type_name
((((((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
4207 break;
4208 }
4209}
4210
4211static GObject*
4212panel_toplevel_constructor (GType type,
4213 guint n_construct_properties,
4214 GObjectConstructParam *construct_properties)
4215{
4216 GObject *object;
4217
4218 object = G_OBJECT_CLASS (panel_toplevel_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), (((GType) ((20) << (
2))))))))
->constructor (type,
4219 n_construct_properties,
4220 construct_properties);
4221 PanelToplevel *toplevel = PANEL_TOPLEVEL(object)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((panel_toplevel_get_type ()))))))
;
4222 GdkScreen *screen = gtk_widget_get_screen(GTK_WIDGET(toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
4223 GdkVisual *visual = gdk_screen_get_rgba_visual(screen);
4224 gtk_widget_set_visual(GTK_WIDGET(toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
, visual);
4225
4226 return object;
4227}
4228
4229static void
4230panel_toplevel_finalize (GObject *object)
4231{
4232 PanelToplevel *toplevel = (PanelToplevel *) object;
4233
4234#ifdef HAVE_X111
4235 if (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel)))(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gtk_widget_get_display (((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((toplevel)), ((gtk_widget_get_type ()))))
))))); GType __t = ((gdk_x11_display_get_type())); gboolean __r
; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
)
4236 panel_struts_unregister_strut (toplevel);
4237#endif /* HAVE_X11 */
4238
4239 toplevel_list = g_slist_remove (toplevel_list, toplevel);
4240
4241 G_OBJECT_CLASS (panel_toplevel_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), (((GType) ((20) << (
2))))))))
->finalize (object);
4242}
4243
4244static void
4245panel_toplevel_class_init (PanelToplevelClass *klass)
4246{
4247 GObjectClass *gobject_class = (GObjectClass *) klass;
4248 GtkWidgetClass *widget_class = (GtkWidgetClass *) klass;
4249 GtkContainerClass *container_class = (GtkContainerClass *) klass;
4250 GtkBindingSet *binding_set;
4251
4252 binding_set = gtk_binding_set_by_class (klass);
4253
4254 gobject_class->constructor = panel_toplevel_constructor;
4255 gobject_class->set_property = panel_toplevel_set_property;
4256 gobject_class->get_property = panel_toplevel_get_property;
4257 gobject_class->finalize = panel_toplevel_finalize;
4258
4259 gobject_class->dispose = panel_toplevel_dispose;
4260
4261 widget_class->realize = panel_toplevel_realize;
4262 widget_class->unrealize = panel_toplevel_unrealize;
4263 widget_class->state_flags_changed = panel_toplevel_state_flags_changed;
4264 widget_class->draw = panel_toplevel_draw;
4265 widget_class->get_preferred_width = panel_toplevel_get_preferred_width;
4266 widget_class->get_preferred_height = panel_toplevel_get_preferred_height;
4267 widget_class->style_updated = panel_toplevel_style_updated;
4268 widget_class->size_allocate = panel_toplevel_size_allocate;
4269 widget_class->button_press_event = panel_toplevel_button_press_event;
4270 widget_class->button_release_event = panel_toplevel_button_release_event;
4271 widget_class->configure_event = panel_toplevel_configure_event;
4272 widget_class->key_press_event = panel_toplevel_key_press_event;
4273 widget_class->motion_notify_event = panel_toplevel_motion_notify_event;
4274 widget_class->enter_notify_event = panel_toplevel_enter_notify_event;
4275 widget_class->leave_notify_event = panel_toplevel_leave_notify_event;
4276 widget_class->screen_changed = panel_toplevel_screen_changed;
4277 widget_class->focus_in_event = panel_toplevel_focus_in_event;
4278 widget_class->focus_out_event = panel_toplevel_focus_out_event;
4279
4280 gtk_widget_class_set_css_name (widget_class, "PanelToplevel");
4281
4282 container_class->check_resize = panel_toplevel_check_resize;
4283
4284 klass->hiding = NULL((void*)0);
4285 klass->unhiding = NULL((void*)0);
4286 klass->popup_panel_menu = panel_toplevel_popup_panel_menu;
4287 klass->toggle_expand = panel_toplevel_toggle_expand;
4288 klass->expand = panel_toplevel_expand;
4289 klass->unexpand = panel_toplevel_unexpand;
4290 klass->toggle_hidden = panel_toplevel_toggle_hidden;
4291 klass->begin_move = panel_toplevel_begin_move;
4292 klass->begin_resize = panel_toplevel_begin_resize;
4293
4294 g_object_class_install_property (
4295 gobject_class,
4296 PROP_NAME,
4297 g_param_spec_string (
4298 "name",
4299 "Name",
4300 "The name of this panel",
4301 NULL((void*)0),
4302 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4303
4304 g_object_class_install_property (
4305 gobject_class,
4306 PROP_SETTINGS_PATH,
4307 g_param_spec_string (
4308 "settings-path",
4309 "GSettings path",
4310 "The GSettings path used for this panel",
4311 NULL((void*)0),
4312 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4313
4314 g_object_class_install_property (
4315 gobject_class,
4316 PROP_EXPAND,
4317 g_param_spec_boolean (
4318 "expand",
4319 "Expand",
4320 "Expand to take up the full monitor width/height",
4321 TRUE(!(0)),
4322 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4323
4324 g_object_class_install_property (
4325 gobject_class,
4326 PROP_ORIENTATION,
4327 g_param_spec_enum (
4328 "orientation",
4329 "Orientation",
4330 "The orientation of the panel",
4331 PANEL_TYPE_ORIENTATIONpanel_orientation_get_type(),
4332 PANEL_ORIENTATION_TOP,
4333 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4334
4335 g_object_class_install_property (
4336 gobject_class,
4337 PROP_SIZE,
4338 g_param_spec_int (
4339 "size",
4340 "Size",
4341 "The height (or width when vertical) of the panel",
4342 0,
4343 G_MAXINT2147483647,
4344 DEFAULT_SIZE48,
4345 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4346
4347 g_object_class_install_property (
4348 gobject_class,
4349 PROP_X,
4350 g_param_spec_int (
4351 "x",
4352 "X position",
4353 "The X position of the panel",
4354 0,
4355 G_MAXINT2147483647,
4356 0,
4357 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4358
4359 g_object_class_install_property (
4360 gobject_class,
4361 PROP_X_RIGHT,
4362 g_param_spec_int (
4363 "x-right",
4364 "X position, from the right",
4365 "The X position of the panel, starting from the right of the screen",
4366 -1,
4367 G_MAXINT2147483647,
4368 -1,
4369 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4370
4371 g_object_class_install_property (
4372 gobject_class,
4373 PROP_X_CENTERED,
4374 g_param_spec_boolean (
4375 "x-centered",
4376 "X centered",
4377 "The x co-ordinate is relative to center screen",
4378 FALSE(0),
4379 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4380
4381 g_object_class_install_property (
4382 gobject_class,
4383 PROP_Y,
4384 g_param_spec_int (
4385 "y",
4386 "Y position",
4387 "The Y position of the panel",
4388 0,
4389 G_MAXINT2147483647,
4390 0,
4391 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4392
4393 g_object_class_install_property (
4394 gobject_class,
4395 PROP_Y_BOTTOM,
4396 g_param_spec_int (
4397 "y_bottom",
4398 "Y position, from the bottom",
4399 "The Y position of the panel, starting from the bottom of the screen",
4400 -1,
4401 G_MAXINT2147483647,
4402 -1,
4403 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4404
4405 g_object_class_install_property (
4406 gobject_class,
4407 PROP_Y_CENTERED,
4408 g_param_spec_boolean (
4409 "y-centered",
4410 "Y centered",
4411 "The y co-ordinate is relative to center screen",
4412 FALSE(0),
4413 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4414
4415 g_object_class_install_property (
4416 gobject_class,
4417 PROP_MONITOR,
4418 g_param_spec_int (
4419 "monitor",
4420 "Xinerama monitor",
4421 "The monitor (in terms of Xinerama) which the panel is on",
4422 0,
4423 G_MAXINT2147483647,
4424 0,
4425 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4426
4427 g_object_class_install_property (
4428 gobject_class,
4429 PROP_AUTOHIDE,
4430 g_param_spec_boolean (
4431 "auto-hide",
4432 "Auto hide",
4433 "Automatically hide the panel when the mouse leaves the panel",
4434 FALSE(0),
4435 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4436
4437 g_object_class_install_property (
4438 gobject_class,
4439 PROP_HIDE_DELAY,
4440 g_param_spec_int (
4441 "hide-delay",
4442 "Hide delay",
4443 "The number of milliseconds to delay before automatically hiding",
4444 0,
4445 G_MAXINT2147483647,
4446 DEFAULT_HIDE_DELAY300,
4447 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4448
4449 g_object_class_install_property (
4450 gobject_class,
4451 PROP_UNHIDE_DELAY,
4452 g_param_spec_int (
4453 "unhide-delay",
4454 "Un-hide delay",
4455 "The number of milliseconds to delay before automatically un-hiding",
4456 0,
4457 G_MAXINT2147483647,
4458 DEFAULT_UNHIDE_DELAY100,
4459 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4460
4461 g_object_class_install_property (
4462 gobject_class,
4463 PROP_AUTOHIDE_SIZE,
4464 g_param_spec_int (
4465 "auto-hide-size",
4466 "Auto-hide size",
4467 "The number of pixels visible when the panel has been automatically hidden",
4468 1,
4469 G_MAXINT2147483647,
4470 DEFAULT_AUTO_HIDE_SIZE1,
4471 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4472
4473 g_object_class_install_property (
4474 gobject_class,
4475 PROP_ANIMATE,
4476 g_param_spec_boolean (
4477 "animate",
4478 "Animate",
4479 "Enable hiding/showing animations",
4480 TRUE(!(0)),
4481 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4482
4483 g_object_class_install_property (
4484 gobject_class,
4485 PROP_ANIMATION_SPEED,
4486 g_param_spec_enum (
4487 "animation-speed",
4488 "Animation Speed",
4489 "The speed at which to animate panel hiding/showing",
4490 PANEL_TYPE_ANIMATION_SPEEDpanel_animation_speed_get_type(),
4491 PANEL_ANIMATION_MEDIUM,
4492 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4493
4494 g_object_class_install_property (
4495 gobject_class,
4496 PROP_BUTTONS_ENABLED,
4497 g_param_spec_boolean (
4498 "buttons-enabled",
4499 "Buttons Enabled",
4500 "Enable hide/show buttons",
4501 TRUE(!(0)),
4502 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4503
4504 g_object_class_install_property (
4505 gobject_class,
4506 PROP_ARROWS_ENABLED,
4507 g_param_spec_boolean (
4508 "arrows-enabled",
4509 "Arrows Enabled",
4510 "Enable arrows on hide/show buttons",
4511 TRUE(!(0)),
4512 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4513
4514 gtk_widget_class_install_style_property (
4515 widget_class,
4516 g_param_spec_int (
4517 "arrow-size",
4518 "Arrow Size",
4519 "The size of the arrows on the hide/show buttons",
4520 0,
4521 G_MAXINT2147483647,
4522 DEFAULT_ARROW_SIZE20,
4523 G_PARAM_READABLE));
4524
4525 toplevel_signals [HIDE_SIGNAL] =
4526 g_signal_new ("hiding",
4527 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
4528 G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
4529 G_STRUCT_OFFSET (PanelToplevelClass, hiding)((glong) __builtin_offsetof(PanelToplevelClass, hiding)),
4530 NULL((void*)0),
4531 NULL((void*)0),
4532 g_cclosure_marshal_VOID__VOID,
4533 G_TYPE_NONE((GType) ((1) << (2))),
4534 0);
4535
4536 toplevel_signals [UNHIDE_SIGNAL] =
4537 g_signal_new ("unhiding",
4538 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
4539 G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
4540 G_STRUCT_OFFSET (PanelToplevelClass, unhiding)((glong) __builtin_offsetof(PanelToplevelClass, unhiding)),
4541 NULL((void*)0),
4542 NULL((void*)0),
4543 g_cclosure_marshal_VOID__VOID,
4544 G_TYPE_NONE((GType) ((1) << (2))),
4545 0);
4546
4547 toplevel_signals [POPUP_PANEL_MENU_SIGNAL] =
4548 g_signal_new ("popup-panel-menu",
4549 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
4550 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
4551 G_STRUCT_OFFSET (PanelToplevelClass, popup_panel_menu)((glong) __builtin_offsetof(PanelToplevelClass, popup_panel_menu
))
,
4552 NULL((void*)0),
4553 NULL((void*)0),
4554 panel_marshal_BOOLEAN__VOID,
4555 G_TYPE_BOOLEAN((GType) ((5) << (2))),
4556 0);
4557
4558 toplevel_signals [TOGGLE_EXPAND_SIGNAL] =
4559 g_signal_new ("toggle-expand",
4560 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
4561 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
4562 G_STRUCT_OFFSET (PanelToplevelClass, toggle_expand)((glong) __builtin_offsetof(PanelToplevelClass, toggle_expand
))
,
4563 NULL((void*)0),
4564 NULL((void*)0),
4565 panel_marshal_BOOLEAN__VOID,
4566 G_TYPE_BOOLEAN((GType) ((5) << (2))),
4567 0);
4568
4569 toplevel_signals [EXPAND_SIGNAL] =
4570 g_signal_new ("expand",
4571 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
4572 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
4573 G_STRUCT_OFFSET (PanelToplevelClass, expand)((glong) __builtin_offsetof(PanelToplevelClass, expand)),
4574 NULL((void*)0),
4575 NULL((void*)0),
4576 panel_marshal_BOOLEAN__VOID,
4577 G_TYPE_BOOLEAN((GType) ((5) << (2))),
4578 0);
4579
4580 toplevel_signals [UNEXPAND_SIGNAL] =
4581 g_signal_new ("unexpand",
4582 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
4583 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
4584 G_STRUCT_OFFSET (PanelToplevelClass, unexpand)((glong) __builtin_offsetof(PanelToplevelClass, unexpand)),
4585 NULL((void*)0),
4586 NULL((void*)0),
4587 panel_marshal_BOOLEAN__VOID,
4588 G_TYPE_BOOLEAN((GType) ((5) << (2))),
4589 0);
4590
4591 toplevel_signals [TOGGLE_HIDDEN_SIGNAL] =
4592 g_signal_new ("toggle-hidden",
4593 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
4594 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
4595 G_STRUCT_OFFSET (PanelToplevelClass, toggle_hidden)((glong) __builtin_offsetof(PanelToplevelClass, toggle_hidden
))
,
4596 NULL((void*)0),
4597 NULL((void*)0),
4598 panel_marshal_BOOLEAN__VOID,
4599 G_TYPE_BOOLEAN((GType) ((5) << (2))),
4600 0);
4601
4602 toplevel_signals [BEGIN_MOVE_SIGNAL] =
4603 g_signal_new ("begin-move",
4604 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
4605 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
4606 G_STRUCT_OFFSET (PanelToplevelClass, begin_move)((glong) __builtin_offsetof(PanelToplevelClass, begin_move)),
4607 NULL((void*)0),
4608 NULL((void*)0),
4609 panel_marshal_BOOLEAN__VOID,
4610 G_TYPE_BOOLEAN((GType) ((5) << (2))),
4611 0);
4612
4613 toplevel_signals [BEGIN_RESIZE_SIGNAL] =
4614 g_signal_new ("begin-resize",
4615 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
4616 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
4617 G_STRUCT_OFFSET (PanelToplevelClass, begin_resize)((glong) __builtin_offsetof(PanelToplevelClass, begin_resize)
)
,
4618 NULL((void*)0),
4619 NULL((void*)0),
4620 panel_marshal_BOOLEAN__VOID,
4621 G_TYPE_BOOLEAN((GType) ((5) << (2))),
4622 0);
4623
4624 gtk_binding_entry_add_signal (binding_set, GDK_KEY_F100xffc7, GDK_CONTROL_MASK,
4625 "popup_panel_menu", 0);
4626
4627 panel_bindings_set_entries (binding_set);
4628}
4629
4630static void
4631panel_toplevel_setup_widgets (PanelToplevel *toplevel)
4632{
4633 GtkWidget* container;
4634
4635 toplevel->priv->grid = gtk_grid_new ();
4636
4637 toplevel->priv->hide_button_top = panel_toplevel_add_hide_button (toplevel, GTK_ARROW_UP, 1, 0);
4638 toplevel->priv->hide_button_bottom = panel_toplevel_add_hide_button (toplevel, GTK_ARROW_DOWN, 1, 2);
4639 toplevel->priv->hide_button_left = panel_toplevel_add_hide_button (toplevel, GTK_ARROW_LEFT, 0, 1);
4640 toplevel->priv->hide_button_right = panel_toplevel_add_hide_button (toplevel, GTK_ARROW_RIGHT, 2, 1);
4641
4642 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM))
4643 {
4644 gtk_widget_show(toplevel->priv->hide_button_left);
4645 gtk_widget_show(toplevel->priv->hide_button_right);
4646 }
4647 else
4648 {
4649 gtk_widget_show(toplevel->priv->hide_button_top);
4650 gtk_widget_show(toplevel->priv->hide_button_bottom);
4651 }
4652
4653 toplevel->priv->inner_frame = g_object_new(PANEL_TYPE_FRAME(panel_frame_get_type ()), NULL((void*)0));
4654
4655 gtk_widget_set_hexpand (GTK_WIDGET (toplevel->priv->inner_frame)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->inner_frame)), ((gtk_widget_get_type
()))))))
, TRUE(!(0)));
4656 gtk_widget_set_vexpand (GTK_WIDGET (toplevel->priv->inner_frame)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->inner_frame)), ((gtk_widget_get_type
()))))))
, TRUE(!(0)));
4657
4658 gtk_grid_attach (GTK_GRID (toplevel->priv->grid)((((GtkGrid*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->grid)), ((gtk_grid_get_type ()))))
))
, GTK_WIDGET (toplevel->priv->inner_frame)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->inner_frame)), ((gtk_widget_get_type
()))))))
, 1, 1, 1, 1);
4659 gtk_widget_show (GTK_WIDGET (toplevel->priv->inner_frame)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->inner_frame)), ((gtk_widget_get_type
()))))))
);
4660
4661 container = panel_widget_new (toplevel,
4662 !toplevel->priv->expand,
4663 (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)) ?
4664 GTK_ORIENTATION_HORIZONTAL :
4665 GTK_ORIENTATION_VERTICAL,
4666 toplevel->priv->size);
4667
4668 toplevel->priv->panel_widget = PANEL_WIDGET(container)((((PanelWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((container)), ((panel_widget_get_type()))))))
;
4669
4670 gtk_container_add(GTK_CONTAINER(toplevel->priv->inner_frame)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->inner_frame)), ((gtk_container_get_type
()))))))
, container);
4671 gtk_widget_show(container);
4672
4673 gtk_container_add (GTK_CONTAINER (toplevel)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_container_get_type ()))))))
, toplevel->priv->grid);
4674 gtk_widget_show (toplevel->priv->grid);
4675}
4676
4677static void
4678background_changed (PanelBackground *background,
4679 PanelToplevel *toplevel)
4680{
4681 panel_toplevel_update_edges (toplevel);
4682 panel_widget_emit_background_changed (toplevel->priv->panel_widget);
4683}
4684
4685static void
4686panel_toplevel_init (PanelToplevel *toplevel)
4687{
4688 GtkWidget *widget;
4689 int i;
4690
4691 toplevel->priv = panel_toplevel_get_instance_private (toplevel);
4692
4693 toplevel->priv->expand = TRUE(!(0));
4694 toplevel->priv->orientation = PANEL_ORIENTATION_BOTTOM;
4695 toplevel->priv->size = DEFAULT_SIZE48;
4696 toplevel->priv->scale = gtk_widget_get_scale_factor (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
4697 toplevel->priv->x = 0;
4698 toplevel->priv->y = 0;
4699 toplevel->priv->x_right = -1;
4700 toplevel->priv->y_bottom = -1;
4701 toplevel->priv->monitor = 0;
4702 toplevel->priv->configured_monitor = -1;
4703 toplevel->priv->hide_delay = DEFAULT_HIDE_DELAY300;
4704 toplevel->priv->unhide_delay = DEFAULT_UNHIDE_DELAY100;
4705 toplevel->priv->auto_hide_size = DEFAULT_AUTO_HIDE_SIZE1;
4706 toplevel->priv->animation_speed = PANEL_ANIMATION_FAST;
4707
4708 toplevel->priv->snap_tolerance = DEFAULT_DND_THRESHOLD8 * SNAP_TOLERANCE_FACTOR6;
4709 toplevel->priv->gtk_settings = NULL((void*)0);
4710
4711 toplevel->priv->state = PANEL_STATE_NORMAL;
4712
4713 toplevel->priv->name = NULL((void*)0);
4714 toplevel->priv->description = NULL((void*)0);
4715
4716 toplevel->priv->hide_timeout = 0;
4717 toplevel->priv->unhide_timeout = 0;
4718
4719 toplevel->priv->geometry.x = -1;
4720 toplevel->priv->geometry.y = -1;
4721 toplevel->priv->geometry.width = -1;
4722 toplevel->priv->geometry.height = -1;
4723
4724 toplevel->priv->original_width = -1;
4725 toplevel->priv->original_height = -1;
4726
4727 toplevel->priv->grab_op = PANEL_GRAB_OP_NONE;
4728
4729 toplevel->priv->drag_offset_x = 0;
4730 toplevel->priv->drag_offset_y = 0;
4731
4732 toplevel->priv->animation_end_x = 0;
4733 toplevel->priv->animation_end_y = 0;
4734 toplevel->priv->animation_end_width = 0;
4735 toplevel->priv->animation_end_height = 0;
4736 toplevel->priv->animation_start_time = 0;
4737 toplevel->priv->animation_duration_time = 0;
4738 toplevel->priv->animation_timeout = 0;
4739
4740 toplevel->priv->panel_widget = NULL((void*)0);
4741 toplevel->priv->inner_frame = NULL((void*)0);
4742 toplevel->priv->grid = NULL((void*)0);
4743 toplevel->priv->hide_button_top = NULL((void*)0);
4744 toplevel->priv->hide_button_bottom = NULL((void*)0);
4745 toplevel->priv->hide_button_left = NULL((void*)0);
4746 toplevel->priv->hide_button_right = NULL((void*)0);
4747
4748 toplevel->priv->attach_toplevel = NULL((void*)0);
4749 toplevel->priv->attach_widget = NULL((void*)0);
4750 toplevel->priv->n_autohide_disablers = 0;
4751
4752 for (i = 0; i < N_ATTACH_TOPLEVEL_SIGNALS5; i++)
4753 toplevel->priv->attach_toplevel_signals [i] = 0;
4754 for (i = 0; i < N_ATTACH_WIDGET_SIGNALS5; i++)
4755 toplevel->priv->attach_widget_signals [i] = 0;
4756
4757 toplevel->priv->auto_hide = FALSE(0);
4758 toplevel->priv->buttons_enabled = TRUE(!(0));
4759 toplevel->priv->arrows_enabled = TRUE(!(0));
4760 toplevel->priv->x_centered = FALSE(0);
4761 toplevel->priv->y_centered = FALSE(0);
4762 toplevel->priv->animating = FALSE(0);
4763 toplevel->priv->grab_is_keyboard = FALSE(0);
4764 toplevel->priv->position_centered = FALSE(0);
4765 toplevel->priv->attached = FALSE(0);
4766 toplevel->priv->attach_hidden = FALSE(0);
4767 toplevel->priv->updated_geometry_initial = FALSE(0);
4768 toplevel->priv->initial_animation_done = FALSE(0);
4769
4770 widget = GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
;
4771 gtk_widget_add_events (widget,
4772 GDK_BUTTON_PRESS_MASK |
4773 GDK_BUTTON_RELEASE_MASK |
4774 GDK_POINTER_MOTION_MASK |
4775 GDK_ENTER_NOTIFY_MASK |
4776 GDK_LEAVE_NOTIFY_MASK);
4777
4778 gtk_widget_set_app_paintable (widget, TRUE(!(0)));
4779
4780 panel_toplevel_setup_widgets (toplevel);
4781 panel_toplevel_update_description (toplevel);
4782 panel_toplevel_update_gtk_settings (toplevel);
4783
4784 toplevel_list = g_slist_prepend (toplevel_list, toplevel);
4785
4786 /* Prevent the window from being deleted via Alt+F4 by accident. This
4787 * happens with "alternative" window managers such as Sawfish or XFWM4.
4788 */
4789 g_signal_connect (toplevel, "delete-event", G_CALLBACK(gtk_true), NULL)g_signal_connect_data ((toplevel), ("delete-event"), (((GCallback
) (gtk_true))), (((void*)0)), ((void*)0), (GConnectFlags) 0)
;
4790
4791 panel_background_init (&toplevel->background,
4792 (PanelBackgroundChangedNotify) background_changed,
4793 toplevel);
4794
4795 update_style_classes (toplevel);
4796
4797#ifdef HAVE_WAYLAND1
4798 if (GDK_IS_WAYLAND_DISPLAY (gdk_display_get_default ())(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gdk_display_get_default ())); GType __t = ((gdk_wayland_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
) {
4799 wayland_panel_toplevel_init (toplevel);
4800 }
4801#endif /* HAVE_WAYLAND */
4802}
4803
4804PanelWidget *
4805panel_toplevel_get_panel_widget (PanelToplevel *toplevel)
4806{
4807
4808 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return (((void
*)0)); } } while (0)
;
4809
4810 return toplevel->priv->panel_widget;
4811}
4812
4813static void
4814panel_toplevel_update_name (PanelToplevel *toplevel)
4815{
4816 char *title;
4817
4818 g_assert (toplevel->priv->description != NULL)do { if (toplevel->priv->description != ((void*)0)) ; else
g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c", 4818
, ((const char*) (__func__)), "toplevel->priv->description != NULL"
); } while (0)
;
4819
4820 title = toplevel->priv->name ? toplevel->priv->name : toplevel->priv->description;
4821
4822 gtk_window_set_title (GTK_WINDOW (toplevel)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_window_get_type ()))))))
, title);
4823
4824 panel_a11y_set_atk_name_desc (
4825 GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
,
4826 title, toplevel->priv->description);
4827}
4828
4829void
4830panel_toplevel_set_name (PanelToplevel *toplevel,
4831 const char *name)
4832{
4833 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
4834
4835 if (!toplevel->priv->name && (!name || !name [0]))
4836 return;
4837
4838 if (toplevel->priv->name && name && name [0] &&
4839 !strcmp (toplevel->priv->name, name))
4840 return;
4841
4842 g_free (toplevel->priv->name);
4843 if (name && name [0])
4844 toplevel->priv->name = g_strdup (name)g_strdup_inline (name);
4845 else
4846 toplevel->priv->name = NULL((void*)0);
4847
4848 panel_toplevel_update_name (toplevel);
4849
4850 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "name");
4851}
4852
4853void
4854panel_toplevel_set_settings_path (PanelToplevel *toplevel,
4855 const char *settings_path)
4856{
4857 toplevel->priv->settings_path = g_strdup (settings_path)g_strdup_inline (settings_path);
4858}
4859
4860const char* panel_toplevel_get_name(PanelToplevel* toplevel)
4861{
4862 g_return_val_if_fail(PANEL_IS_TOPLEVEL(toplevel), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL(toplevel)"); return (((void
*)0)); } } while (0)
;
4863
4864 return toplevel->priv->name;
4865}
4866
4867const char* panel_toplevel_get_description(PanelToplevel* toplevel)
4868{
4869 g_return_val_if_fail(PANEL_IS_TOPLEVEL(toplevel), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL(toplevel)"); return (((void
*)0)); } } while (0)
;
4870
4871 return toplevel->priv->description;
4872}
4873
4874void
4875panel_toplevel_set_expand (PanelToplevel *toplevel,
4876 gboolean expand)
4877{
4878 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
4879
4880 if (toplevel->priv->attached && expand) {
4881 g_warning ("attempt to expand attached toplevel; ignoring");
4882 return;
4883 }
4884
4885 expand = expand != FALSE(0);
4886
4887 if (toplevel->priv->expand == expand)
4888 return;
4889
4890 toplevel->priv->expand = expand;
4891
4892 if (!toplevel->priv->expand && toplevel->priv->updated_geometry_initial) {
4893 switch (toplevel->priv->orientation) {
4894 case PANEL_ORIENTATION_TOP:
4895 panel_toplevel_set_x (toplevel, 0, -1, TRUE(!(0)));
4896 break;
4897 case PANEL_ORIENTATION_BOTTOM:
4898 panel_toplevel_set_x (toplevel, 0, 0, TRUE(!(0)));
4899 break;
4900 case PANEL_ORIENTATION_LEFT:
4901 panel_toplevel_set_y (toplevel, 0, -1, TRUE(!(0)));
4902 break;
4903 case PANEL_ORIENTATION_RIGHT:
4904 panel_toplevel_set_y (toplevel, 0, 0, TRUE(!(0)));
4905 break;
4906 default:
4907 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 4907, ((const char*) (__func__)), ((void*)0)); } while (0)
;
4908 break;
4909 }
4910 }
4911
4912 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
4913
4914 panel_widget_set_packed (toplevel->priv->panel_widget, !toplevel->priv->expand);
4915
4916 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "expand");
4917}
4918
4919gboolean
4920panel_toplevel_get_expand (PanelToplevel *toplevel)
4921{
4922 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), TRUE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return ((!(0)
)); } } while (0)
;
4923
4924 return toplevel->priv->expand;
4925}
4926
4927gboolean
4928panel_toplevel_get_is_floating (PanelToplevel *toplevel)
4929{
4930 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), TRUE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return ((!(0)
)); } } while (0)
;
4931
4932 return toplevel->priv->floating;
4933}
4934
4935void
4936panel_toplevel_set_orientation (PanelToplevel *toplevel,
4937 PanelOrientation orientation)
4938{
4939 gboolean rotate;
4940 GdkRectangle monitor_geom;
4941
4942 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
4943
4944 if (toplevel->priv->orientation == orientation)
4945 return;
4946
4947 g_object_freeze_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
);
4948
4949 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
4950
4951 /* Un-snap from center if no longer along screen edge */
4952 if (toplevel->priv->x_centered &&
4953 (orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT))) {
4954 toplevel->priv->x_centered = FALSE(0);
4955 toplevel->priv->x = (monitor_geom.width - toplevel->priv->geometry.width) / 2;
4956 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "x");
4957 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "x-centered");
4958
4959 if (toplevel->priv->x_right != -1) {
4960 toplevel->priv->x_right = -1;
4961 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "x-right");
4962 }
4963 }
4964
4965 if (toplevel->priv->y_centered &&
4966 (orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM))) {
4967 toplevel->priv->y_centered = FALSE(0);
4968 toplevel->priv->y = (monitor_geom.height - toplevel->priv->geometry.height) / 2;
4969 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "y");
4970 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "y-centered");
4971
4972 if (toplevel->priv->y_bottom != -1) {
4973 toplevel->priv->y_bottom = -1;
4974 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "y-bottom");
4975 }
4976 }
4977
4978 rotate = FALSE(0);
4979 if ((orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)) &&
4980 (toplevel->priv->orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT)))
4981 rotate = TRUE(!(0));
4982 else if ((orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT)) &&
4983 (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)))
4984 rotate = TRUE(!(0));
4985
4986 /* rotate around the center */
4987 if (rotate && !toplevel->priv->position_centered && !toplevel->priv->expand &&
4988 toplevel->priv->updated_geometry_initial) {
4989 toplevel->priv->position_centered = TRUE(!(0));
4990
4991 /* x, y temporary refer to the panel center, so we don't care
4992 * about x_right, y_bottom. Those will get updated in
4993 * panel_toplevel_update_position() accordingly. */
4994 if (!toplevel->priv->x_centered) {
4995 toplevel->priv->x += toplevel->priv->geometry.width / 2;
4996 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "x");
4997 }
4998
4999 if (!toplevel->priv->y_centered) {
5000 toplevel->priv->y += toplevel->priv->geometry.height / 2;
5001 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "y");
5002 }
5003
5004 }
5005
5006 toplevel->priv->orientation = orientation;
5007 update_style_classes (toplevel);
5008
5009 gtk_widget_reset_style (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
5010
5011 panel_toplevel_update_hide_buttons (toplevel);
5012
5013 panel_widget_set_orientation (
5014 toplevel->priv->panel_widget,
5015 (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)) ?
5016 GTK_ORIENTATION_HORIZONTAL :
5017 GTK_ORIENTATION_VERTICAL);
5018
5019 switch (toplevel->priv->state) {
5020 case PANEL_STATE_HIDDEN_UP:
5021 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM))
5022 toplevel->priv->state = PANEL_STATE_HIDDEN_LEFT;
5023 break;
5024 case PANEL_STATE_HIDDEN_DOWN:
5025 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM))
5026 toplevel->priv->state = PANEL_STATE_HIDDEN_RIGHT;
5027 break;
5028 case PANEL_STATE_HIDDEN_LEFT:
5029 if (toplevel->priv->orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT))
5030 toplevel->priv->state = PANEL_STATE_HIDDEN_UP;
5031 break;
5032 case PANEL_STATE_HIDDEN_RIGHT:
5033 if (toplevel->priv->orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT))
5034 toplevel->priv->state = PANEL_STATE_HIDDEN_DOWN;
5035 break;
5036 default:
5037 break;
5038 }
5039
5040 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
5041
5042 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "orientation");
5043
5044 g_object_thaw_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
);
5045
5046#ifdef HAVE_WAYLAND1
5047 if (GDK_IS_WAYLAND_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel)))(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gtk_widget_get_display (((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((toplevel)), ((gtk_widget_get_type ()))))
))))); GType __t = ((gdk_wayland_display_get_type())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
) {
5048 wayland_panel_toplevel_update_placement (toplevel);
5049 }
5050#endif /* HAVE_WAYLAND */
5051}
5052
5053PanelOrientation
5054panel_toplevel_get_orientation (PanelToplevel *toplevel)
5055{
5056 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), PANEL_ORIENTATION_TOP)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return (PANEL_ORIENTATION_TOP
); } } while (0)
;
5057
5058 return toplevel->priv->orientation;
5059}
5060
5061void
5062panel_toplevel_set_size (PanelToplevel *toplevel,
5063 int size)
5064{
5065 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
5066 g_return_if_fail (size >= 0)do { if ((size >= 0)) { } else { g_return_if_fail_warning (
((gchar*) 0), ((const char*) (__func__)), "size >= 0"); return
; } } while (0)
;
5067
5068 if (toplevel->priv->size == size)
5069 return;
5070
5071 toplevel->priv->size = size;
5072
5073 panel_widget_set_size (toplevel->priv->panel_widget, toplevel->priv->size);
5074
5075 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
5076
5077 panel_toplevel_update_hide_buttons (toplevel);
5078
5079 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "size");
5080}
5081
5082int
5083panel_toplevel_get_size (PanelToplevel *toplevel)
5084{
5085 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), DEFAULT_SIZE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return (48); }
} while (0)
;
5086
5087 return toplevel->priv->size;
5088}
5089
5090void
5091panel_toplevel_set_auto_hide_size (PanelToplevel *toplevel,
5092 int auto_hide_size)
5093{
5094 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
5095
5096 if (toplevel->priv->auto_hide_size == auto_hide_size)
5097 return;
5098
5099 toplevel->priv->auto_hide_size = auto_hide_size;
5100
5101 if (toplevel->priv->state == PANEL_STATE_AUTO_HIDDEN) {
5102 if (panel_toplevel_update_struts (toplevel, FALSE(0))) {
5103 if (toplevel->priv->animate) {
5104 panel_toplevel_unhide (toplevel);
5105 panel_toplevel_hide (toplevel, TRUE(!(0)), -1);
5106 } else
5107 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
5108 }
5109 }
5110
5111 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "auto-hide-size");
5112}
5113
5114int
5115panel_toplevel_get_auto_hide_size (PanelToplevel *toplevel)
5116{
5117 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), DEFAULT_AUTO_HIDE_SIZE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return (1); }
} while (0)
;
5118
5119 return toplevel->priv->auto_hide_size;
5120}
5121
5122void
5123panel_toplevel_set_x (PanelToplevel *toplevel,
5124 int x,
5125 int x_right,
5126 gboolean x_centered)
5127{
5128 gboolean changed = FALSE(0);
5129
5130 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
5131
5132 x_centered = x_centered != FALSE(0);
5133
5134 g_object_freeze_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
);
5135
5136 if (toplevel->priv->x != x) {
5137 toplevel->priv->x = x;
5138 changed = TRUE(!(0));
5139 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "x");
5140 }
5141
5142 if (toplevel->priv->x_right != x_right) {
5143 toplevel->priv->x_right = x_right;
5144 changed = TRUE(!(0));
5145 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "x-right");
5146 }
5147
5148 if (toplevel->priv->x_centered != x_centered) {
5149 toplevel->priv->x_centered = (x_centered != FALSE(0));
5150 changed = TRUE(!(0));
5151 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "x-centered");
5152 }
5153
5154 if (changed)
5155 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
5156
5157 g_object_thaw_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
);
5158}
5159
5160void
5161panel_toplevel_set_y (PanelToplevel *toplevel,
5162 int y,
5163 int y_bottom,
5164 gboolean y_centered)
5165{
5166 gboolean changed = FALSE(0);
5167
5168 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
5169
5170 y_centered = y_centered != FALSE(0);
5171
5172 g_object_freeze_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
);
5173
5174 if (toplevel->priv->y != y) {
5175 toplevel->priv->y = y;
5176 changed = TRUE(!(0));
5177 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "y");
5178 }
5179
5180 if (toplevel->priv->y_bottom != y_bottom) {
5181 toplevel->priv->y_bottom = y_bottom;
5182 changed = TRUE(!(0));
5183 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "y-bottom");
5184 }
5185
5186 if (toplevel->priv->y_centered != y_centered) {
5187 toplevel->priv->y_centered = (y_centered != FALSE(0));
5188 changed = TRUE(!(0));
5189 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "y-centered");
5190 }
5191
5192 if (changed)
5193 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
5194
5195 g_object_thaw_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
);
5196}
5197
5198void
5199panel_toplevel_get_position (PanelToplevel *toplevel,
5200 int *x,
5201 int *x_right,
5202 int *y,
5203 int *y_bottom)
5204{
5205 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
5206
5207 if (x)
5208 *x = toplevel->priv->x;
5209
5210 if (y)
5211 *y = toplevel->priv->y;
5212
5213 if (x_right)
5214 *x_right = toplevel->priv->x_right;
5215
5216 if (y_bottom)
5217 *y_bottom = toplevel->priv->y_bottom;
5218}
5219
5220gboolean
5221panel_toplevel_get_x_centered (PanelToplevel *toplevel)
5222{
5223 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return ((0));
} } while (0)
;
5224
5225 return toplevel->priv->x_centered;
5226}
5227
5228gboolean
5229panel_toplevel_get_y_centered (PanelToplevel *toplevel)
5230{
5231 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return ((0));
} } while (0)
;
5232
5233 return toplevel->priv->y_centered;
5234}
5235
5236/**
5237 * panel_toplevel_set_monitor_internal:
5238 *
5239 * Sets the monitor of the toplevel, but only the internal state. We need to
5240 * make the difference between the internal state and the configuration of the
5241 * user because internal constraints might affect the monitor of the toplevel.
5242 *
5243 * panel_toplevel_set_monitor_internal() won't update the configuration of the
5244 * user.
5245 **/
5246static void
5247panel_toplevel_set_monitor_internal (PanelToplevel *toplevel,
5248 int monitor,
5249 gboolean force_resize)
5250{
5251 if (toplevel->priv->monitor == monitor)
5252 return;
5253
5254 toplevel->priv->monitor = monitor;
5255
5256 if (force_resize)
5257 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
5258}
5259
5260/**
5261 * panel_toplevel_update_monitor:
5262 *
5263 * Moves the toplevel to its configured monitor or the first one, if needed.
5264 * This generally happens when the configured monitor was non-existing before,
5265 * and it appeared at runtime, or if it was existing and disappeared.
5266 *
5267 * This must only be called at the beginning of the size request of the
5268 * toplevel because it doesn't queue a size request.
5269 **/
5270static void
5271panel_toplevel_update_monitor (PanelToplevel *toplevel)
5272{
5273 /* If we were not using the configured monitor, can we use it now? */
5274 if ((toplevel->priv->configured_monitor != -1) &&
5275 (toplevel->priv->configured_monitor != toplevel->priv->monitor) &&
5276 toplevel->priv->configured_monitor < panel_multimonitor_monitors ()) {
5277 panel_toplevel_set_monitor_internal (toplevel,
5278 toplevel->priv->configured_monitor,
5279 FALSE(0));
5280
5281 /* else, can we still use the monitor we were using? */
5282 } else if (toplevel->priv->monitor >= panel_multimonitor_monitors ()) {
5283 panel_toplevel_set_monitor_internal (toplevel,
5284 0,
5285 FALSE(0));
5286 }
5287}
5288
5289void
5290panel_toplevel_set_monitor (PanelToplevel *toplevel,
5291 int monitor)
5292{
5293 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
5294
5295 if (toplevel->priv->configured_monitor == monitor)
5296 return;
5297
5298 toplevel->priv->configured_monitor = monitor;
5299
5300 /* Only use the configured monitor if it's existing. Else, we ignore
5301 * the non-existing monitor, and keep the old one. The main use case is
5302 * when logging in after having used a multimonitor environment.
5303 * We will put the panel on the monitor 0 for this session, and it will
5304 * move back to the right monitor next time. */
5305 if (monitor < panel_multimonitor_monitors ())
5306 panel_toplevel_set_monitor_internal (toplevel, monitor, TRUE(!(0)));
5307
5308 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "monitor");
5309}
5310
5311int
5312panel_toplevel_get_monitor (PanelToplevel *toplevel)
5313{
5314 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), -1)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return (-1); }
} while (0)
;
5315
5316 return toplevel->priv->monitor;
5317}
5318
5319void
5320panel_toplevel_set_auto_hide (PanelToplevel *toplevel,
5321 gboolean auto_hide)
5322{
5323 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
5324
5325 auto_hide = auto_hide != FALSE(0);
5326
5327 if (toplevel->priv->auto_hide == auto_hide)
5328 return;
5329
5330 toplevel->priv->auto_hide = (auto_hide != FALSE(0));
5331
5332 if (toplevel->priv->auto_hide)
5333 panel_toplevel_queue_auto_hide (toplevel);
5334 else
5335 panel_toplevel_queue_auto_unhide (toplevel);
5336
5337 if (panel_toplevel_update_struts (toplevel, FALSE(0)))
5338 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
5339
5340 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "auto-hide");
5341}
5342
5343gboolean
5344panel_toplevel_get_auto_hide (PanelToplevel *toplevel)
5345{
5346 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return ((0));
} } while (0)
;
5347
5348 return toplevel->priv->auto_hide;
5349}
5350
5351void
5352panel_toplevel_set_hide_delay (PanelToplevel *toplevel,
5353 int hide_delay)
5354{
5355 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
5356
5357 if (toplevel->priv->hide_delay == hide_delay)
5358 return;
5359
5360 toplevel->priv->hide_delay = hide_delay;
5361
5362 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "hide-delay");
5363}
5364
5365int
5366panel_toplevel_get_hide_delay (PanelToplevel *toplevel)
5367{
5368 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), -1)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return (-1); }
} while (0)
;
5369
5370 return toplevel->priv->hide_delay;
5371}
5372
5373void
5374panel_toplevel_set_unhide_delay (PanelToplevel *toplevel,
5375 int unhide_delay)
5376{
5377 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
5378
5379 if (toplevel->priv->unhide_delay == unhide_delay)
5380 return;
5381
5382 toplevel->priv->unhide_delay = unhide_delay;
5383
5384 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "unhide-delay");
5385}
5386
5387int
5388panel_toplevel_get_unhide_delay (PanelToplevel *toplevel)
5389{
5390 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), -1)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return (-1); }
} while (0)
;
5391
5392 return toplevel->priv->unhide_delay;
5393}
5394
5395void
5396panel_toplevel_set_animate (PanelToplevel *toplevel,
5397 gboolean animate)
5398{
5399 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
5400
5401 animate = animate != FALSE(0);
5402
5403 if (toplevel->priv->animate == animate)
5404 return;
5405
5406 toplevel->priv->animate = (animate != FALSE(0));
5407
5408 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "animate");
5409}
5410
5411gboolean
5412panel_toplevel_get_animate (PanelToplevel *toplevel)
5413{
5414 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return ((0));
} } while (0)
;
5415
5416 return toplevel->priv->animate;
5417}
5418
5419void
5420panel_toplevel_set_animation_speed (PanelToplevel *toplevel,
5421 PanelAnimationSpeed animation_speed)
5422{
5423 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
5424
5425 if (toplevel->priv->animation_speed == animation_speed)
5426 return;
5427
5428 toplevel->priv->animation_speed = animation_speed;
5429
5430 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "animation-speed");
5431}
5432
5433PanelAnimationSpeed
5434panel_toplevel_get_animation_speed (PanelToplevel *toplevel)
5435{
5436 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), 0)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return (0); }
} while (0)
;
5437
5438 return toplevel->priv->animation_speed;
5439}
5440
5441void
5442panel_toplevel_set_enable_buttons (PanelToplevel *toplevel,
5443 gboolean enable_buttons)
5444{
5445 enable_buttons = enable_buttons != FALSE(0);
5446
5447 if (toplevel->priv->buttons_enabled == enable_buttons)
5448 return;
5449
5450 toplevel->priv->buttons_enabled = enable_buttons;
5451
5452 panel_toplevel_update_hide_buttons (toplevel);
5453
5454 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "buttons-enabled");
5455}
5456
5457gboolean
5458panel_toplevel_get_enable_buttons (PanelToplevel *toplevel)
5459{
5460 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return ((0));
} } while (0)
;
5461
5462 return toplevel->priv->buttons_enabled;
5463}
5464
5465void
5466panel_toplevel_set_enable_arrows (PanelToplevel *toplevel,
5467 gboolean enable_arrows)
5468{
5469 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
5470
5471 enable_arrows = enable_arrows != FALSE(0);
5472
5473 if (toplevel->priv->arrows_enabled == enable_arrows)
5474 return;
5475
5476 toplevel->priv->arrows_enabled = (enable_arrows != FALSE(0));
5477
5478 panel_toplevel_update_hide_buttons (toplevel);
5479
5480 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "arrows-enabled");
5481}
5482
5483gboolean
5484panel_toplevel_get_enable_arrows (PanelToplevel *toplevel)
5485{
5486 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return ((0));
} } while (0)
;
5487
5488 return toplevel->priv->arrows_enabled;
5489}
5490
5491void
5492panel_toplevel_rotate (PanelToplevel *toplevel,
5493 gboolean clockwise)
5494{
5495 PanelOrientation orientation;
5496
5497 /* Relies on PanelOrientation definition:
5498 *
5499 * typedef enum {
5500 * PANEL_ORIENTATION_TOP = 1 << 0,
5501 * PANEL_ORIENTATION_RIGHT = 1 << 1,
5502 * PANEL_ORIENTATION_BOTTOM = 1 << 2,
5503 * PANEL_ORIENTATION_LEFT = 1 << 3
5504 * } PanelOrientation;
5505 */
5506
5507 orientation = toplevel->priv->orientation;
5508
5509 if (clockwise)
5510 orientation <<= 1;
5511 else
5512 orientation >>= 1;
5513
5514 if (orientation == 0)
5515 orientation = PANEL_ORIENTATION_LEFT;
5516
5517 else if (orientation > PANEL_ORIENTATION_LEFT)
5518 orientation = PANEL_ORIENTATION_TOP;
5519
5520 panel_toplevel_set_orientation (toplevel, orientation);
5521}
5522
5523PanelState
5524panel_toplevel_get_state (PanelToplevel *toplevel)
5525{
5526 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), 0)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return (0); }
} while (0)
;
5527
5528 return toplevel->priv->state;
5529}
5530
5531gboolean
5532panel_toplevel_get_is_hidden (PanelToplevel *toplevel)
5533{
5534 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return ((0));
} } while (0)
;
5535
5536 if (toplevel->priv->state == PANEL_STATE_HIDDEN_UP ||
5537 toplevel->priv->state == PANEL_STATE_HIDDEN_DOWN ||
5538 toplevel->priv->state == PANEL_STATE_HIDDEN_LEFT ||
5539 toplevel->priv->state == PANEL_STATE_HIDDEN_RIGHT)
5540 return TRUE(!(0));
5541
5542 return FALSE(0);
5543}
5544
5545int
5546panel_toplevel_get_minimum_size (PanelToplevel *toplevel)
5547{
5548 return calculate_minimum_height (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
,
5549 toplevel->priv->orientation);
5550}
5551
5552int
5553panel_toplevel_get_maximum_size (PanelToplevel *toplevel)
5554{
5555 GdkRectangle monitor_geom;
5556
5557 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
5558
5559 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM))
5560 return monitor_geom.height / MAXIMUM_SIZE_SCREEN_RATIO5;
5561 else
5562 return monitor_geom.width / MAXIMUM_SIZE_SCREEN_RATIO5;
5563}
diff --git a/2024-06-18-172109-13286-1@e182420b844f_master/report-f493c1.html b/2024-06-18-172109-13286-1@e182420b844f_master/report-f493c1.html new file mode 100644 index 00000000..a4b29f15 --- /dev/null +++ b/2024-06-18-172109-13286-1@e182420b844f_master/report-f493c1.html @@ -0,0 +1,3246 @@ + + + +mate-panel-applet.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:libmate-panel-applet/mate-panel-applet.c
Warning:line 2246, column 33
Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name mate-panel-applet.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/libmate-panel-applet -fcoverage-compilation-dir=/rootdir/libmate-panel-applet -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I .. -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/gio-unix-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I ../libmate-panel-applet -D MATELOCALEDIR="/usr/local/share/locale" -D PIC -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-18-172109-13286-1 -x c mate-panel-applet.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * mate-panel-applet.c: panel applet writing library.
3 *
4 * Copyright (c) 2010 Carlos Garcia Campos <carlosgc@gnome.org>
5 * Copyright (C) 2001 Sun Microsystems, Inc.
6 * Copyright (C) 2012-2021 MATE Developers
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
17 *
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the
20 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22 *
23 * Authors:
24 * Mark McLoughlin <mark@skynet.ie>
25 */
26
27#ifdef HAVE_CONFIG_H1
28#include <config.h>
29#endif
30
31#include <unistd.h>
32#include <stdlib.h>
33#include <string.h>
34
35#include <glib/gi18n-lib.h>
36#include <cairo.h>
37#include <gdk/gdk.h>
38#include <gdk/gdkkeysyms.h>
39#include <gtk/gtk.h>
40
41#ifdef HAVE_X111
42#include <cairo-xlib.h>
43#include <gdk/gdkx.h>
44#include <gtk/gtkx.h>
45#include <X11/Xatom.h>
46#include "panel-plug-private.h"
47#endif
48
49#include "mate-panel-applet.h"
50#include "panel-applet-private.h"
51#include "mate-panel-applet-factory.h"
52#include "mate-panel-applet-marshal.h"
53#include "mate-panel-applet-enums.h"
54
55typedef struct {
56 GtkWidget *plug;
57 GDBusConnection *connection;
58
59 gboolean out_of_process;
60
61 char *id;
62 GClosure *closure;
63 char *object_path;
64 guint object_id;
65 char *prefs_path;
66
67 GtkUIManager *ui_manager;
68 GtkActionGroup *applet_action_group;
69 GtkActionGroup *panel_action_group;
70
71 MatePanelAppletFlags flags;
72 MatePanelAppletOrient orient;
73 guint size;
74 char *background;
75
76 int previous_width;
77 int previous_height;
78
79 int *size_hints;
80 int size_hints_len;
81
82 gboolean moving_focus_out;
83
84 gboolean locked;
85 gboolean locked_down;
86} MatePanelAppletPrivate;
87
88enum {
89 CHANGE_ORIENT,
90 CHANGE_SIZE,
91 CHANGE_BACKGROUND,
92 MOVE_FOCUS_OUT_OF_APPLET,
93 LAST_SIGNAL
94};
95
96static guint mate_panel_applet_signals[LAST_SIGNAL] = { 0 };
97
98enum {
99 PROP_0,
100 PROP_OUT_OF_PROCESS,
101 PROP_ID,
102 PROP_CLOSURE,
103 PROP_CONNECTION,
104 PROP_PREFS_PATH,
105 PROP_ORIENT,
106 PROP_SIZE,
107 PROP_BACKGROUND,
108 PROP_FLAGS,
109 PROP_SIZE_HINTS,
110 PROP_LOCKED,
111 PROP_LOCKED_DOWN
112};
113
114static void mate_panel_applet_handle_background (MatePanelApplet *applet);
115static GtkAction *mate_panel_applet_menu_get_action (MatePanelApplet *applet,
116 const gchar *action);
117static void mate_panel_applet_menu_update_actions (MatePanelApplet *applet);
118static void mate_panel_applet_menu_cmd_remove (GtkAction *action,
119 MatePanelApplet *applet);
120static void mate_panel_applet_menu_cmd_move (GtkAction *action,
121 MatePanelApplet *applet);
122static void mate_panel_applet_menu_cmd_lock (GtkAction *action,
123 MatePanelApplet *applet);
124static void mate_panel_applet_register_object (MatePanelApplet *applet);
125void _mate_panel_applet_apply_css (GtkWidget* widget, MatePanelAppletBackgroundType type);
126
127static const gchar panel_menu_ui[] =
128 "<ui>\n"
129 " <popup name=\"MatePanelAppletPopup\" action=\"PopupAction\">\n"
130 " <placeholder name=\"AppletItems\"/>\n"
131 " <separator/>\n"
132 " <menuitem name=\"RemoveItem\" action=\"Remove\"/>\n"
133 " <menuitem name=\"MoveItem\" action=\"Move\"/>\n"
134 " <separator/>\n"
135 " <menuitem name=\"LockItem\" action=\"Lock\"/>\n"
136 " </popup>\n"
137 "</ui>\n";
138
139static const GtkActionEntry menu_entries[] = {
140 { "Remove", "list-remove", N_("_Remove From Panel")("_Remove From Panel"),
141 NULL((void*)0), NULL((void*)0),
142 G_CALLBACK (mate_panel_applet_menu_cmd_remove)((GCallback) (mate_panel_applet_menu_cmd_remove)) },
143 { "Move", NULL((void*)0), N_("_Move")("_Move"),
144 NULL((void*)0), NULL((void*)0),
145 G_CALLBACK (mate_panel_applet_menu_cmd_move)((GCallback) (mate_panel_applet_menu_cmd_move)) }
146};
147
148static const GtkToggleActionEntry menu_toggle_entries[] = {
149 { "Lock", NULL((void*)0), N_("Loc_k To Panel")("Loc_k To Panel"),
150 NULL((void*)0), NULL((void*)0),
151 G_CALLBACK (mate_panel_applet_menu_cmd_lock)((GCallback) (mate_panel_applet_menu_cmd_lock)),
152 FALSE(0) }
153};
154
155G_DEFINE_TYPE_WITH_PRIVATE (MatePanelApplet, mate_panel_applet, GTK_TYPE_EVENT_BOX)static void mate_panel_applet_init (MatePanelApplet *self); static
void mate_panel_applet_class_init (MatePanelAppletClass *klass
); static GType mate_panel_applet_get_type_once (void); static
gpointer mate_panel_applet_parent_class = ((void*)0); static
gint MatePanelApplet_private_offset; static void mate_panel_applet_class_intern_init
(gpointer klass) { mate_panel_applet_parent_class = g_type_class_peek_parent
(klass); if (MatePanelApplet_private_offset != 0) g_type_class_adjust_private_offset
(klass, &MatePanelApplet_private_offset); mate_panel_applet_class_init
((MatePanelAppletClass*) klass); } __attribute__ ((__unused__
)) static inline gpointer mate_panel_applet_get_instance_private
(MatePanelApplet *self) { return (((gpointer) ((guint8*) (self
) + (glong) (MatePanelApplet_private_offset)))); } GType mate_panel_applet_get_type
(void) { static GType static_g_define_type_id = 0; if ((__extension__
({ _Static_assert (sizeof *(&static_g_define_type_id) ==
sizeof (gpointer), "Expression evaluates to false"); (void) (
0 ? (gpointer) * (&static_g_define_type_id) : ((void*)0))
; (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter_pointer (
&static_g_define_type_id)); })) ) { GType g_define_type_id
= mate_panel_applet_get_type_once (); (__extension__ ({ _Static_assert
(sizeof *(&static_g_define_type_id) == sizeof (gpointer)
, "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id
) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer
((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id
)); })) ; } return static_g_define_type_id; } __attribute__ (
(__noinline__)) static GType mate_panel_applet_get_type_once (
void) { GType g_define_type_id = g_type_register_static_simple
((gtk_event_box_get_type ()), g_intern_static_string ("MatePanelApplet"
), sizeof (MatePanelAppletClass), (GClassInitFunc)(void (*)(void
)) mate_panel_applet_class_intern_init, sizeof (MatePanelApplet
), (GInstanceInitFunc)(void (*)(void)) mate_panel_applet_init
, (GTypeFlags) 0); { {{ MatePanelApplet_private_offset = g_type_add_instance_private
(g_define_type_id, sizeof (MatePanelAppletPrivate)); };} } return
g_define_type_id; }
156
157#define MATE_PANEL_APPLET_INTERFACE"org.mate.panel.applet.Applet" "org.mate.panel.applet.Applet"
158#define MATE_PANEL_APPLET_OBJECT_PATH"/org/mate/panel/applet/%s/%d" "/org/mate/panel/applet/%s/%d"
159
160char *
161mate_panel_applet_get_preferences_path (MatePanelApplet *applet)
162{
163 MatePanelAppletPrivate *priv;
164
165 g_return_val_if_fail (MATE_PANEL_IS_APPLET (applet), NULL)do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return (((void*)0)); } } while (0)
;
166
167 priv = mate_panel_applet_get_instance_private (applet);
168 if (!priv->prefs_path)
169 return NULL((void*)0);
170
171 return g_strdup (priv->prefs_path)g_strdup_inline (priv->prefs_path);
172}
173
174static void
175mate_panel_applet_set_preferences_path (MatePanelApplet *applet,
176 const char *prefs_path)
177{
178 MatePanelAppletPrivate *priv;
179
180 priv = mate_panel_applet_get_instance_private (applet);
181
182 if (priv->prefs_path == prefs_path)
183 return;
184
185 if (g_strcmp0 (priv->prefs_path, prefs_path) == 0)
186 return;
187
188 if (prefs_path)
189 priv->prefs_path = g_strdup (prefs_path)g_strdup_inline (prefs_path);
190
191 g_object_notify (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
, "prefs-path");
192}
193
194MatePanelAppletFlags
195mate_panel_applet_get_flags (MatePanelApplet *applet)
196{
197 MatePanelAppletPrivate *priv;
198
199 g_return_val_if_fail (MATE_PANEL_IS_APPLET (applet), MATE_PANEL_APPLET_FLAGS_NONE)do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return (MATE_PANEL_APPLET_FLAGS_NONE); } } while (0)
;
200
201 priv = mate_panel_applet_get_instance_private (applet);
202
203 return priv->flags;
204}
205
206void
207mate_panel_applet_set_flags (MatePanelApplet *applet,
208 MatePanelAppletFlags flags)
209{
210 MatePanelAppletPrivate *priv;
211
212 g_return_if_fail (MATE_PANEL_IS_APPLET (applet))do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return; } } while (0)
;
213
214 priv = mate_panel_applet_get_instance_private (applet);
215
216 if (priv->flags == flags)
217 return;
218
219 priv->flags = flags;
220
221 g_object_notify (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
, "flags");
222
223 if (priv->connection) {
224 GVariantBuilder builder;
225 GVariantBuilder invalidated_builder;
226 GError *error = NULL((void*)0);
227
228 g_variant_builder_init (&builder, G_VARIANT_TYPE_ARRAY((const GVariantType *) "a*"));
229 g_variant_builder_init (&invalidated_builder, G_VARIANT_TYPE ("as")(g_variant_type_checked_ (("as"))));
230
231 g_variant_builder_add (&builder, "{sv}", "Flags",
232 g_variant_new_uint32 (priv->flags));
233
234 g_dbus_connection_emit_signal (priv->connection,
235 NULL((void*)0),
236 priv->object_path,
237 "org.freedesktop.DBus.Properties",
238 "PropertiesChanged",
239 g_variant_new ("(sa{sv}as)",
240 MATE_PANEL_APPLET_INTERFACE"org.mate.panel.applet.Applet",
241 &builder,
242 &invalidated_builder),
243 &error);
244 if (error) {
245 g_printerr ("Failed to send signal PropertiesChanged::Flags: %s\n",
246 error->message);
247 g_error_free (error);
248 }
249 g_variant_builder_clear (&builder);
250 g_variant_builder_clear (&invalidated_builder);
251 }
252}
253
254static void
255mate_panel_applet_size_hints_ensure (MatePanelApplet *applet,
256 int new_size)
257{
258 MatePanelAppletPrivate *priv;
259
260 priv = mate_panel_applet_get_instance_private (applet);
261 if (priv->size_hints && priv->size_hints_len < new_size) {
262 g_free (priv->size_hints);
263 priv->size_hints = g_new (gint, new_size)((gint *) g_malloc_n ((new_size), sizeof (gint)));
264 } else if (!priv->size_hints) {
265 priv->size_hints = g_new (gint, new_size)((gint *) g_malloc_n ((new_size), sizeof (gint)));
266 }
267 priv->size_hints_len = new_size;
268}
269
270static gboolean
271mate_panel_applet_size_hints_changed (MatePanelApplet *applet,
272 const int *size_hints,
273 int n_elements,
274 int base_size)
275{
276 MatePanelAppletPrivate *priv;
277 gint i;
278
279 priv = mate_panel_applet_get_instance_private (applet);
280
281 if (!priv->size_hints)
282 return TRUE(!(0));
283
284 if (priv->size_hints_len != n_elements)
285 return TRUE(!(0));
286
287 for (i = 0; i < n_elements; i++) {
288 if (size_hints[i] + base_size != priv->size_hints[i])
289 return TRUE(!(0));
290 }
291
292 return FALSE(0);
293}
294
295/**
296 * mate_panel_applet_set_size_hints:
297 * @applet: applet
298 * @size_hints: (array length=n_elements): List of integers
299 * @n_elements: Length of @size_hints
300 * @base_size: base_size
301 */
302void
303mate_panel_applet_set_size_hints (MatePanelApplet *applet,
304 const int *size_hints,
305 int n_elements,
306 int base_size)
307{
308 MatePanelAppletPrivate *priv;
309 gint i;
310
311 /* Make sure property has really changed to avoid bus traffic */
312 if (!mate_panel_applet_size_hints_changed (applet, size_hints, n_elements, base_size))
313 return;
314
315 priv = mate_panel_applet_get_instance_private (applet);
316
317 mate_panel_applet_size_hints_ensure (applet, n_elements);
318 for (i = 0; i < n_elements; i++)
319 priv->size_hints[i] = size_hints[i] + base_size;
320
321 g_object_notify (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
, "size-hints");
322
323 if (priv->connection) {
324 GVariantBuilder builder;
325 GVariantBuilder invalidated_builder;
326 GVariant **children;
327 GError *error = NULL((void*)0);
328
329 g_variant_builder_init (&builder, G_VARIANT_TYPE_ARRAY((const GVariantType *) "a*"));
330 g_variant_builder_init (&invalidated_builder, G_VARIANT_TYPE ("as")(g_variant_type_checked_ (("as"))));
331
332 children = g_new (GVariant *, priv->size_hints_len)((GVariant * *) g_malloc_n ((priv->size_hints_len), sizeof
(GVariant *)))
;
333 for (i = 0; i < n_elements; i++)
334 children[i] = g_variant_new_int32 (priv->size_hints[i]);
335 g_variant_builder_add (&builder, "{sv}", "SizeHints",
336 g_variant_new_array (G_VARIANT_TYPE_INT32((const GVariantType *) "i"),
337 children, priv->size_hints_len));
338 g_free (children);
339
340 g_dbus_connection_emit_signal (priv->connection,
341 NULL((void*)0),
342 priv->object_path,
343 "org.freedesktop.DBus.Properties",
344 "PropertiesChanged",
345 g_variant_new ("(sa{sv}as)",
346 MATE_PANEL_APPLET_INTERFACE"org.mate.panel.applet.Applet",
347 &builder,
348 &invalidated_builder),
349 &error);
350 if (error) {
351 g_printerr ("Failed to send signal PropertiesChanged::SizeHints: %s\n",
352 error->message);
353 g_error_free (error);
354 }
355 g_variant_builder_clear (&builder);
356 g_variant_builder_clear (&invalidated_builder);
357 }
358}
359
360guint
361mate_panel_applet_get_size (MatePanelApplet *applet)
362{
363 MatePanelAppletPrivate *priv;
364
365 g_return_val_if_fail (MATE_PANEL_IS_APPLET (applet), 0)do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return (0); } } while (0)
;
366
367 priv = mate_panel_applet_get_instance_private (applet);
368
369 return priv->size;
370}
371
372/* Applets cannot set their size, so API is not public. */
373static void
374mate_panel_applet_set_size (MatePanelApplet *applet,
375 guint size)
376{
377 MatePanelAppletPrivate *priv;
378
379 g_return_if_fail (MATE_PANEL_IS_APPLET (applet))do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return; } } while (0)
;
380
381 priv = mate_panel_applet_get_instance_private (applet);
382
383 if (priv->size == size)
384 return;
385
386 priv->size = size;
387 g_signal_emit (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
,
388 mate_panel_applet_signals [CHANGE_SIZE],
389 0, size);
390
391 g_object_notify (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
, "size");
392}
393
394MatePanelAppletOrient
395mate_panel_applet_get_orient (MatePanelApplet *applet)
396{
397 MatePanelAppletPrivate *priv;
398
399 g_return_val_if_fail (MATE_PANEL_IS_APPLET (applet), 0)do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return (0); } } while (0)
;
400
401 priv = mate_panel_applet_get_instance_private (applet);
402
403 return priv->orient;
404}
405
406/* Applets cannot set their orientation, so API is not public. */
407static void
408mate_panel_applet_set_orient (MatePanelApplet *applet,
409 MatePanelAppletOrient orient)
410{
411 MatePanelAppletPrivate *priv;
412
413 g_return_if_fail (MATE_PANEL_IS_APPLET (applet))do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return; } } while (0)
;
414
415 priv = mate_panel_applet_get_instance_private (applet);
416
417 if (priv->orient == orient)
418 return;
419
420 priv->orient = orient;
421 g_signal_emit (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
,
422 mate_panel_applet_signals [CHANGE_ORIENT],
423 0, orient);
424
425 g_object_notify (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
, "orient");
426}
427
428static void
429mate_panel_applet_set_locked (MatePanelApplet *applet,
430 gboolean locked)
431{
432 MatePanelAppletPrivate *priv;
433 GtkAction *action;
434
435 g_return_if_fail (MATE_PANEL_IS_APPLET (applet))do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return; } } while (0)
;
436
437 priv = mate_panel_applet_get_instance_private (applet);
438
439 if (priv->locked == locked)
440 return;
441
442 priv->locked = locked;
443
444 action = mate_panel_applet_menu_get_action (applet, "Lock");
445 g_signal_handlers_block_by_func (action,g_signal_handlers_block_matched ((action), (GSignalMatchType)
(G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0
), (mate_panel_applet_menu_cmd_lock), (applet))
446 mate_panel_applet_menu_cmd_lock,g_signal_handlers_block_matched ((action), (GSignalMatchType)
(G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0
), (mate_panel_applet_menu_cmd_lock), (applet))
447 applet)g_signal_handlers_block_matched ((action), (GSignalMatchType)
(G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0
), (mate_panel_applet_menu_cmd_lock), (applet))
;
448 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action)((((GtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((gtk_toggle_action_get_type ()))))))
, locked);
449 g_signal_handlers_unblock_by_func (action,g_signal_handlers_unblock_matched ((action), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (mate_panel_applet_menu_cmd_lock), (applet))
450 mate_panel_applet_menu_cmd_lock,g_signal_handlers_unblock_matched ((action), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (mate_panel_applet_menu_cmd_lock), (applet))
451 applet)g_signal_handlers_unblock_matched ((action), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (mate_panel_applet_menu_cmd_lock), (applet))
;
452
453 mate_panel_applet_menu_update_actions (applet);
454
455 g_object_notify (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
, "locked");
456
457 if (priv->connection) {
458 GError *error = NULL((void*)0);
459
460 g_dbus_connection_emit_signal (priv->connection,
461 NULL((void*)0),
462 priv->object_path,
463 MATE_PANEL_APPLET_INTERFACE"org.mate.panel.applet.Applet",
464 locked ? "Lock" : "Unlock",
465 NULL((void*)0), &error);
466 if (error) {
467 g_printerr ("Failed to send signal %s: %s\n",
468 locked ? "Lock" : "Unlock",
469 error->message);
470 g_error_free (error);
471 }
472 }
473}
474
475gboolean
476mate_panel_applet_get_locked_down (MatePanelApplet *applet)
477{
478 MatePanelAppletPrivate *priv;
479
480 g_return_val_if_fail (MATE_PANEL_IS_APPLET (applet), FALSE)do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return ((0)); } } while (0)
;
481
482 priv = mate_panel_applet_get_instance_private (applet);
483
484 return priv->locked_down;
485}
486
487/* Applets cannot set the lockdown state, so API is not public. */
488static void
489mate_panel_applet_set_locked_down (MatePanelApplet *applet,
490 gboolean locked_down)
491{
492 MatePanelAppletPrivate *priv;
493
494 g_return_if_fail (MATE_PANEL_IS_APPLET (applet))do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return; } } while (0)
;
495
496 priv = mate_panel_applet_get_instance_private (applet);
497
498 if (priv->locked_down == locked_down)
499 return;
500
501 priv->locked_down = locked_down;
502 mate_panel_applet_menu_update_actions (applet);
503
504 g_object_notify (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
, "locked-down");
505}
506
507#ifdef HAVE_X111
508
509static Atom _net_wm_window_type = None0L;
510static Atom _net_wm_window_type_dock = None0L;
511static Atom _net_active_window = None0L;
512
513static void
514mate_panel_applet_init_atoms (Display *xdisplay)
515{
516 if (_net_wm_window_type == None0L)
517 _net_wm_window_type = XInternAtom (xdisplay,
518 "_NET_WM_WINDOW_TYPE",
519 False0);
520
521 if (_net_wm_window_type_dock == None0L)
522 _net_wm_window_type_dock = XInternAtom (xdisplay,
523 "_NET_WM_WINDOW_TYPE_DOCK",
524 False0);
525
526 if (_net_active_window == None0L)
527 _net_active_window = XInternAtom (xdisplay,
528 "_NET_ACTIVE_WINDOW",
529 False0);
530}
531
532static Window
533mate_panel_applet_find_toplevel_dock_window (MatePanelApplet *applet,
534 Display *xdisplay)
535{
536 GtkWidget *toplevel;
537 Window xwin;
538 Window root, parent, *child;
539 int num_children;
540
541 toplevel = gtk_widget_get_toplevel (GTK_WIDGET (applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
);
542 if (!gtk_widget_get_realized (toplevel))
543 return None0L;
544
545 xwin = GDK_WINDOW_XID (gtk_widget_get_window (toplevel))(gdk_x11_window_get_xid (gtk_widget_get_window (toplevel)));
546
547 child = NULL((void*)0);
548 parent = root = None0L;
549 do {
550 Atom type_return;
551 Atom window_type;
552 int format_return;
553 gulong number_return, bytes_after_return;
554 guchar *data_return;
555
556 XGetWindowProperty (xdisplay,
557 xwin,
558 _net_wm_window_type,
559 0, 1, False0,
560 XA_ATOM((Atom) 4),
561 &type_return, &format_return,
562 &number_return,
563 &bytes_after_return,
564 &data_return);
565
566 if (type_return == XA_ATOM((Atom) 4)) {
567 window_type = *(Atom *) data_return;
568
569 XFree (data_return);
570 data_return = NULL((void*)0);
571
572 if (window_type == _net_wm_window_type_dock)
573 return xwin;
574 }
575
576 if (!XQueryTree (xdisplay,
577 xwin,
578 &root, &parent, &child,
579 (guint *) &num_children)) {
580 return None0L;
581 }
582
583 if (child && num_children > 0)
584 XFree (child);
585
586 xwin = parent;
587
588 } while (xwin != None0L && xwin != root);
589
590 return None0L;
591}
592
593#endif /* HAVE_X11 */
594
595/* This function
596 * 1) Gets the window id of the panel that contains the applet
597 * using XQueryTree and XGetWindowProperty to find an ancestor
598 * window with the _NET_WM_WINDOW_TYPE_DOCK window type.
599 * 2) Sends a _NET_ACTIVE_WINDOW message to get that panel focused
600 */
601void
602mate_panel_applet_request_focus (MatePanelApplet *applet,
603 guint32 timestamp)
604{
605#ifdef HAVE_X111
606 GdkScreen *screen;
607 GdkWindow *root;
608 GdkDisplay *display;
609 Display *xdisplay;
610 Window dock_xwindow;
611 Window xroot;
612 XEvent xev;
613
614 if (!GDK_IS_X11_DISPLAY (gdk_display_get_default ())(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gdk_display_get_default ())); GType __t = ((gdk_x11_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
)
615 return;
616
617 g_return_if_fail (MATE_PANEL_IS_APPLET (applet))do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return; } } while (0)
;
618
619 screen = gdk_screen_get_default(); /*There is only one screen since GTK 3.22*/
620 root = gdk_screen_get_root_window (screen);
621 display = gdk_screen_get_display (screen);
622
623 xdisplay = GDK_DISPLAY_XDISPLAY (display)(gdk_x11_display_get_xdisplay (display));
624 xroot = GDK_WINDOW_XID (root)(gdk_x11_window_get_xid (root));
625
626 mate_panel_applet_init_atoms (xdisplay);
627
628 dock_xwindow = mate_panel_applet_find_toplevel_dock_window (applet, xdisplay);
629 if (dock_xwindow == None0L)
630 return;
631
632 xev.xclient.type = ClientMessage33;
633 xev.xclient.serial = 0;
634 xev.xclient.send_event = True1;
635 xev.xclient.window = dock_xwindow;
636 xev.xclient.message_type = _net_active_window;
637 xev.xclient.format = 32;
638 xev.xclient.data.l[0] = 1; /* requestor type; we're an app, I guess */
639 xev.xclient.data.l[1] = timestamp;
640 xev.xclient.data.l[2] = None0L; /* "currently active window", supposedly */
641 xev.xclient.data.l[3] = 0;
642 xev.xclient.data.l[4] = 0;
643
644 XSendEvent (xdisplay,
645 xroot, False0,
646 SubstructureRedirectMask(1L<<20) | SubstructureNotifyMask(1L<<19),
647 &xev);
648#endif
649}
650
651static GtkAction *
652mate_panel_applet_menu_get_action (MatePanelApplet *applet,
653 const gchar *action)
654{
655 MatePanelAppletPrivate *priv;
656
657 priv = mate_panel_applet_get_instance_private (applet);
658
659 return gtk_action_group_get_action (priv->panel_action_group, action);
660}
661
662static void
663mate_panel_applet_menu_update_actions (MatePanelApplet *applet)
664{
665 MatePanelAppletPrivate *priv;
666
667 priv = mate_panel_applet_get_instance_private (applet);
668 g_object_set (mate_panel_applet_menu_get_action (applet, "Lock"),
669 "visible", !priv->locked_down,
670 NULL((void*)0));
671 g_object_set (mate_panel_applet_menu_get_action (applet, "Move"),
672 "sensitive", !priv->locked,
673 "visible", !priv->locked_down,
674 NULL((void*)0));
675 g_object_set (mate_panel_applet_menu_get_action (applet, "Remove"),
676 "sensitive", !priv->locked,
677 "visible", !priv->locked_down,
678 NULL((void*)0));
679}
680
681static void
682mate_panel_applet_menu_cmd_remove (GtkAction *action,
683 MatePanelApplet *applet)
684{
685 MatePanelAppletPrivate *priv;
686 GError *error = NULL((void*)0);
687
688 priv = mate_panel_applet_get_instance_private (applet);
689
690 if (!priv->connection)
691 return;
692
693 g_dbus_connection_emit_signal (priv->connection,
694 NULL((void*)0),
695 priv->object_path,
696 MATE_PANEL_APPLET_INTERFACE"org.mate.panel.applet.Applet",
697 "RemoveFromPanel",
698 NULL((void*)0), &error);
699 if (error) {
700 g_printerr ("Failed to send signal RemoveFromPanel: %s\n",
701 error->message);
702 g_error_free (error);
703 }
704}
705
706static void
707mate_panel_applet_menu_cmd_move (GtkAction *action,
708 MatePanelApplet *applet)
709{
710 MatePanelAppletPrivate *priv;
711 GError *error = NULL((void*)0);
712
713 priv = mate_panel_applet_get_instance_private (applet);
714
715 if (!priv->connection)
716 return;
717
718 g_dbus_connection_emit_signal (priv->connection,
719 NULL((void*)0),
720 priv->object_path,
721 MATE_PANEL_APPLET_INTERFACE"org.mate.panel.applet.Applet",
722 "Move",
723 NULL((void*)0), &error);
724 if (error) {
725 g_printerr ("Failed to send signal RemoveFromPanel: %s\n",
726 error->message);
727 g_error_free (error);
728 }
729}
730
731static void
732mate_panel_applet_menu_cmd_lock (GtkAction *action,
733 MatePanelApplet *applet)
734{
735 gboolean locked;
736
737 locked = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)((((GtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((gtk_toggle_action_get_type ()))))))
);
738 mate_panel_applet_set_locked (applet, locked);
739}
740
741void
742mate_panel_applet_setup_menu (MatePanelApplet *applet,
743 const gchar *xml,
744 GtkActionGroup *applet_action_group)
745{
746 MatePanelAppletPrivate *priv;
747 gchar *new_xml;
748 GError *error = NULL((void*)0);
749
750 g_return_if_fail (MATE_PANEL_IS_APPLET (applet))do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return; } } while (0)
;
751 g_return_if_fail (xml != NULL)do { if ((xml != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "xml != NULL"); return
; } } while (0)
;
752
753 priv = mate_panel_applet_get_instance_private (applet);
754
755 if (priv->applet_action_group)
756 return;
757
758 priv->applet_action_group = g_object_ref (applet_action_group)((__typeof__ (applet_action_group)) (g_object_ref) (applet_action_group
))
;
759 gtk_ui_manager_insert_action_group (priv->ui_manager,
760 applet_action_group, 0);
761
762 new_xml = g_strdup_printf ("<ui><popup name=\"MatePanelAppletPopup\" action=\"AppletItems\">"
763 "<placeholder name=\"AppletItems\">%s\n</placeholder>\n"
764 "</popup></ui>\n", xml);
765 gtk_ui_manager_add_ui_from_string (priv->ui_manager, new_xml, -1, &error);
766 g_free (new_xml);
767 gtk_ui_manager_ensure_update (priv->ui_manager);
768 if (error) {
769 g_warning ("Error merging menus: %s\n", error->message);
770 g_error_free (error);
771 }
772}
773
774void
775mate_panel_applet_setup_menu_from_file (MatePanelApplet *applet,
776 const gchar *filename,
777 GtkActionGroup *applet_action_group)
778{
779 gchar *xml = NULL((void*)0);
780 GError *error = NULL((void*)0);
781
782 if (g_file_get_contents (filename, &xml, NULL((void*)0), &error)) {
783 mate_panel_applet_setup_menu (applet, xml, applet_action_group);
784 } else {
785 g_warning ("%s", error->message);
786 g_error_free (error);
787 }
788
789 g_free (xml);
790}
791
792/**
793 * mate_panel_applet_setup_menu_from_resource:
794 * @applet: a #MatePanelApplet.
795 * @resource_path: a resource path
796 * @action_group: a #GtkActionGroup.
797 *
798 * Sets up the context menu of @applet. @filename is a resource path to a menu
799 * XML file, containing a #GtkUIManager UI definition that describes how to
800 * display the menu items. @action_group contains the various #GtkAction that
801 * are referenced in @xml.
802 *
803 * See also the <link linkend="getting-started.context-menu">Context
804 * Menu</link> section.
805 *
806 * Since: 1.20.1
807 **/
808void
809mate_panel_applet_setup_menu_from_resource (MatePanelApplet *applet,
810 const gchar *resource_path,
811 GtkActionGroup *action_group)
812{
813 GBytes *bytes;
814 GError *error = NULL((void*)0);
815
816 bytes = g_resources_lookup_data (resource_path,
817 G_RESOURCE_LOOKUP_FLAGS_NONE,
818 &error);
819
820 if (bytes) {
821 mate_panel_applet_setup_menu (applet,
822 g_bytes_get_data (bytes, NULL((void*)0)),
823 action_group);
824 } else {
825 g_warning ("%s", error->message);
826 g_error_free (error);
827 }
828
829 g_bytes_unref (bytes);
830}
831
832static void
833mate_panel_applet_finalize (GObject *object)
834{
835 MatePanelApplet *applet;
836 MatePanelAppletPrivate *priv;
837
838 applet = MATE_PANEL_APPLET (object);
839 priv = mate_panel_applet_get_instance_private (applet);
840
841 if (priv->connection) {
842 if (priv->object_id)
843 g_dbus_connection_unregister_object (priv->connection,
844 priv->object_id);
845 priv->object_id = 0;
846 g_clear_object (&priv->connection)do { _Static_assert (sizeof *((&priv->connection)) == sizeof
(gpointer), "Expression evaluates to false"); __typeof__ (((
&priv->connection))) _pp = ((&priv->connection)
); __typeof__ (*((&priv->connection))) _ptr = *_pp; *_pp
= ((void*)0); if (_ptr) (g_object_unref) (_ptr); } while (0)
;
847 }
848
849 g_clear_pointer (&priv->object_path, g_free)do { _Static_assert (sizeof *(&priv->object_path) == sizeof
(gpointer), "Expression evaluates to false"); __typeof__ ((&
priv->object_path)) _pp = (&priv->object_path); __typeof__
(*(&priv->object_path)) _ptr = *_pp; *_pp = ((void*)0
); if (_ptr) (g_free) (_ptr); } while (0)
;
850
851 mate_panel_applet_set_preferences_path (applet, NULL((void*)0));
852
853 g_clear_object (&priv->applet_action_group)do { _Static_assert (sizeof *((&priv->applet_action_group
)) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(((&priv->applet_action_group))) _pp = ((&priv->
applet_action_group)); __typeof__ (*((&priv->applet_action_group
))) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (g_object_unref
) (_ptr); } while (0)
;
854 g_clear_object (&priv->panel_action_group)do { _Static_assert (sizeof *((&priv->panel_action_group
)) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(((&priv->panel_action_group))) _pp = ((&priv->
panel_action_group)); __typeof__ (*((&priv->panel_action_group
))) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (g_object_unref
) (_ptr); } while (0)
;
855 g_clear_object (&priv->ui_manager)do { _Static_assert (sizeof *((&priv->ui_manager)) == sizeof
(gpointer), "Expression evaluates to false"); __typeof__ (((
&priv->ui_manager))) _pp = ((&priv->ui_manager)
); __typeof__ (*((&priv->ui_manager))) _ptr = *_pp; *_pp
= ((void*)0); if (_ptr) (g_object_unref) (_ptr); } while (0)
;
856
857 g_clear_pointer (&priv->size_hints, g_free)do { _Static_assert (sizeof *(&priv->size_hints) == sizeof
(gpointer), "Expression evaluates to false"); __typeof__ ((&
priv->size_hints)) _pp = (&priv->size_hints); __typeof__
(*(&priv->size_hints)) _ptr = *_pp; *_pp = ((void*)0)
; if (_ptr) (g_free) (_ptr); } while (0)
;
858 g_clear_pointer (&priv->prefs_path, g_free)do { _Static_assert (sizeof *(&priv->prefs_path) == sizeof
(gpointer), "Expression evaluates to false"); __typeof__ ((&
priv->prefs_path)) _pp = (&priv->prefs_path); __typeof__
(*(&priv->prefs_path)) _ptr = *_pp; *_pp = ((void*)0)
; if (_ptr) (g_free) (_ptr); } while (0)
;
859 g_clear_pointer (&priv->background, g_free)do { _Static_assert (sizeof *(&priv->background) == sizeof
(gpointer), "Expression evaluates to false"); __typeof__ ((&
priv->background)) _pp = (&priv->background); __typeof__
(*(&priv->background)) _ptr = *_pp; *_pp = ((void*)0)
; if (_ptr) (g_free) (_ptr); } while (0)
;
860 g_clear_pointer (&priv->id, g_free)do { _Static_assert (sizeof *(&priv->id) == sizeof (gpointer
), "Expression evaluates to false"); __typeof__ ((&priv->
id)) _pp = (&priv->id); __typeof__ (*(&priv->id
)) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (g_free) (_ptr);
} while (0)
;
861
862 /* closure is owned by the factory */
863 priv->closure = NULL((void*)0);
864
865 G_OBJECT_CLASS (mate_panel_applet_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((mate_panel_applet_parent_class)), (((GType) ((20) <<
(2))))))))
->finalize (object);
866}
867
868static gboolean
869container_has_focusable_child (GtkContainer *container)
870{
871 GList *list;
872 GList *t;
873 gboolean retval = FALSE(0);
874
875 list = gtk_container_get_children (container);
876
877 for (t = list; t; t = t->next) {
878 GtkWidget *child = GTK_WIDGET (t->data)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((t->data)), ((gtk_widget_get_type ()))))))
;
879 if (gtk_widget_get_can_focus (child)) {
880 retval = TRUE(!(0));
881 break;
882 } else if (GTK_IS_CONTAINER (child)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(child)); GType __t = ((gtk_container_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; }))))
) {
883 retval = container_has_focusable_child (GTK_CONTAINER (child)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((child)), ((gtk_container_get_type ()))))))
);
884 if (retval)
885 break;
886 }
887 }
888 g_list_free (list);
889 return retval;
890}
891
892static void
893mate_panel_applet_menu_popup (MatePanelApplet *applet,
894 GdkEvent *event)
895{
896 MatePanelAppletPrivate *priv;
897 GtkWidget *menu;
898
899 priv = mate_panel_applet_get_instance_private (applet);
900 menu = gtk_ui_manager_get_widget (priv->ui_manager,
901 "/MatePanelAppletPopup");
902
903/* Set up theme and transparency support */
904 GtkWidget *toplevel = gtk_widget_get_toplevel (menu);
905/* Fix any failures of compiz/other wm's to communicate with gtk for transparency */
906 GdkScreen *screen = gtk_widget_get_screen(GTK_WIDGET(toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
907 GdkVisual *visual = gdk_screen_get_rgba_visual(screen);
908 gtk_widget_set_visual(GTK_WIDGET(toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
, visual);
909/* Set menu and it's toplevel window to follow panel theme */
910 GtkStyleContext *context;
911 context = gtk_widget_get_style_context (GTK_WIDGET(toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
912 gtk_style_context_add_class(context,"gnome-panel-menu-bar");
913 gtk_style_context_add_class(context,"mate-panel-menu-bar");
914 GdkGravity widget_anchor = GDK_GRAVITY_NORTH_WEST;
915 GdkGravity menu_anchor = GDK_GRAVITY_NORTH_WEST;
916 switch (priv->orient) {
917 case MATE_PANEL_APPLET_ORIENT_UP:
918 menu_anchor = GDK_GRAVITY_SOUTH_WEST;
919 break;
920 case MATE_PANEL_APPLET_ORIENT_DOWN:
921 widget_anchor = GDK_GRAVITY_SOUTH_WEST;
922 break;
923 case MATE_PANEL_APPLET_ORIENT_LEFT:
924 menu_anchor = GDK_GRAVITY_NORTH_EAST;
925 break;
926 case MATE_PANEL_APPLET_ORIENT_RIGHT:
927 widget_anchor = GDK_GRAVITY_NORTH_EAST;
928 break;
929 }
930 gtk_menu_popup_at_widget (GTK_MENU (menu)((((GtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((menu)), ((gtk_menu_get_type ()))))))
,
931 GTK_WIDGET (applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
,
932 widget_anchor,
933 menu_anchor,
934 event);
935}
936
937static gboolean
938mate_panel_applet_can_focus (GtkWidget *widget)
939{
940 /*
941 * A MatePanelApplet widget can focus if it has a tooltip or it does
942 * not have any focusable children.
943 */
944 if (gtk_widget_get_has_tooltip (widget))
945 return TRUE(!(0));
946
947 if (!MATE_PANEL_IS_APPLET (widget))
948 return FALSE(0);
949
950 return !container_has_focusable_child (GTK_CONTAINER (widget)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_container_get_type ()))))))
);
951}
952
953/* Taken from libmatecomponentui/matecomponent/matecomponent-plug.c */
954static gboolean
955mate_panel_applet_button_event (MatePanelApplet *applet,
956 GdkEventButton *event)
957{
958#ifdef HAVE_X111
959 MatePanelAppletPrivate *priv;
960 GtkWidget *widget;
961 GdkWindow *window;
962 GdkWindow *socket_window;
963 XEvent xevent;
964 GdkDisplay *display;
965
966 priv = mate_panel_applet_get_instance_private (applet);
967
968 if (!priv->out_of_process)
969 return FALSE(0);
970
971 widget = priv->plug;
972
973 if (!gtk_widget_is_toplevel (widget))
974 return FALSE(0);
975
976 window = gtk_widget_get_window (widget);
977 socket_window = gtk_plug_get_socket_window (GTK_PLUG (widget)((((GtkPlug*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_plug_get_type ()))))))
);
978
979 display = gdk_display_get_default ();
980
981 if (!GDK_IS_X11_DISPLAY (display)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(display)); GType __t = ((gdk_x11_display_get_type())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
)
982 return FALSE(0);
983
984 if (event->type == GDK_BUTTON_PRESS) {
985 GdkSeat *seat;
986
987 xevent.xbutton.type = ButtonPress4;
988
989 seat = gdk_display_get_default_seat (display);
990
991 /* X does an automatic pointer grab on button press
992 * if we have both button press and release events
993 * selected.
994 * We don't want to hog the pointer on our parent.
995 */
996 gdk_seat_ungrab (seat);
997 } else {
998 xevent.xbutton.type = ButtonRelease5;
999 }
1000
1001 xevent.xbutton.display = GDK_WINDOW_XDISPLAY (window)((gdk_x11_display_get_xdisplay (gdk_window_get_display (window
))))
;
1002 xevent.xbutton.window = GDK_WINDOW_XID (socket_window)(gdk_x11_window_get_xid (socket_window));
1003 xevent.xbutton.root = GDK_WINDOW_XID (gdk_screen_get_root_window(gdk_x11_window_get_xid (gdk_screen_get_root_window (gdk_window_get_screen
(window))))
1004 (gdk_window_get_screen (window)))(gdk_x11_window_get_xid (gdk_screen_get_root_window (gdk_window_get_screen
(window))))
;
1005 /*
1006 * FIXME: the following might cause
1007 * big problems for non-GTK apps
1008 */
1009 xevent.xbutton.x = 0;
1010 xevent.xbutton.y = 0;
1011 xevent.xbutton.x_root = 0;
1012 xevent.xbutton.y_root = 0;
1013 xevent.xbutton.state = event->state;
1014 xevent.xbutton.button = event->button;
1015 xevent.xbutton.same_screen = TRUE(!(0)); /* FIXME ? */
1016
1017 gdk_x11_display_error_trap_push (display);
1018
1019 XSendEvent (GDK_WINDOW_XDISPLAY (window)((gdk_x11_display_get_xdisplay (gdk_window_get_display (window
))))
,
1020 GDK_WINDOW_XID (socket_window)(gdk_x11_window_get_xid (socket_window)),
1021 False0, NoEventMask0L, &xevent);
1022
1023 gdk_display_flush (display);
1024 gdk_x11_display_error_trap_pop_ignored (display);
1025
1026 return TRUE(!(0));
1027#else
1028 return FALSE(0);
1029#endif
1030}
1031
1032static gboolean
1033mate_panel_applet_button_press (GtkWidget *widget,
1034 GdkEventButton *event)
1035{
1036 MatePanelApplet *applet = MATE_PANEL_APPLET (widget);
1037
1038 if (!container_has_focusable_child (GTK_CONTAINER (applet)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_container_get_type ()))))))
)) {
1039 if (!gtk_widget_has_focus (widget)) {
1040 gtk_widget_set_can_focus (widget, TRUE(!(0)));
1041 gtk_widget_grab_focus (widget);
1042 }
1043 }
1044
1045#ifdef HAVE_WAYLAND1
1046 /*Limit the window list's applet menu to the handle area*/
1047 if (!(GDK_IS_X11_DISPLAY (gdk_display_get_default ())(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gdk_display_get_default ())); GType __t = ((gdk_x11_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
))
1048 {
1049 MatePanelAppletFlags flags;
1050 flags = mate_panel_applet_get_flags (applet);
1051 if (flags & MATE_PANEL_APPLET_EXPAND_MAJOR)
1052 return FALSE(0);
1053 }
1054#endif
1055
1056 if (event->button == 3) {
1057 mate_panel_applet_menu_popup (applet, (GdkEvent *) event);
1058
1059 return TRUE(!(0));
1060 }
1061 return mate_panel_applet_button_event (applet, event);
1062}
1063
1064static gboolean
1065mate_panel_applet_button_release (GtkWidget *widget,
1066 GdkEventButton *event)
1067{
1068 MatePanelApplet *applet = MATE_PANEL_APPLET (widget);
1069
1070 return mate_panel_applet_button_event (applet, event);
1071}
1072
1073/*Open the applet context menu only on Menu key
1074 *Do not open it on Return or some applets won't work
1075 */
1076static gboolean
1077mate_panel_applet_key_press_event (GtkWidget *widget,
1078 GdkEventKey *event)
1079{
1080 if (event->keyval == GDK_KEY_Menu0xff67) {
1081 mate_panel_applet_menu_popup (MATE_PANEL_APPLET (widget), (GdkEvent *) event);
1082 return TRUE(!(0));
1083 }
1084 else
1085 return FALSE(0);
1086}
1087
1088static void
1089mate_panel_applet_get_preferred_width (GtkWidget *widget,
1090 int *minimum_width,
1091 int *natural_width)
1092{
1093 GTK_WIDGET_CLASS (mate_panel_applet_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((mate_panel_applet_parent_class)), ((gtk_widget_get_type (
)))))))
->get_preferred_width (widget,
1094 minimum_width,
1095 natural_width);
1096
1097#if !GTK_CHECK_VERSION (3, 23, 0)((3) > (3) || ((3) == (3) && (24) > (23)) || ((
3) == (3) && (24) == (23) && (42) >= (0)))
1098 MatePanelAppletPrivate *priv;
1099
1100 priv = mate_panel_applet_get_instance_private (MATE_PANEL_APPLET (widget));
1101 if (priv->out_of_process) {
1102 /* Out-of-process applets end up scaled up doubly with GTK 3.22.
1103 * For these builds divide by the scale factor to ensure
1104 * they are back at their own intended size.
1105 */
1106 gint scale;
1107 scale = gtk_widget_get_scale_factor (widget);
1108 *minimum_width /= scale;
1109 *natural_width /= scale;
1110 }
1111#endif
1112}
1113
1114static void
1115mate_panel_applet_get_preferred_height (GtkWidget *widget,
1116 int *minimum_height,
1117 int *natural_height)
1118{
1119 GTK_WIDGET_CLASS (mate_panel_applet_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((mate_panel_applet_parent_class)), ((gtk_widget_get_type (
)))))))
->get_preferred_height (widget,
1120 minimum_height,
1121 natural_height);
1122
1123#if !GTK_CHECK_VERSION (3, 23, 0)((3) > (3) || ((3) == (3) && (24) > (23)) || ((
3) == (3) && (24) == (23) && (42) >= (0)))
1124 MatePanelAppletPrivate *priv;
1125
1126 priv = mate_panel_applet_get_instance_private (MATE_PANEL_APPLET (widget));
1127 if (priv->out_of_process) {
1128 gint scale;
1129 /* Out-of-process applets end up scaled up doubly with GTK 3.22.
1130 * For these builds divide by the scale factor to ensure
1131 * they are back at their own intended size.
1132 */
1133 scale = gtk_widget_get_scale_factor (widget);
1134 *minimum_height /= scale;
1135 *natural_height /= scale;
1136 }
1137#endif
1138}
1139
1140static GtkSizeRequestMode
1141mate_panel_applet_get_request_mode (GtkWidget *widget)
1142{
1143 /* Do not use GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH
1144 * or GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT
1145 * to avoid problems with in-process applets
1146 * when the panel is not expanded
1147 * See https://github.com/mate-desktop/mate-panel/issues/797
1148 * and https://github.com/mate-desktop/mate-panel/issues/799
1149 * Out of process applets already use GTK_SIZE_REQUEST_CONSTANT_SIZE
1150 */
1151 return GTK_SIZE_REQUEST_CONSTANT_SIZE;
1152}
1153
1154static void
1155mate_panel_applet_size_allocate (GtkWidget *widget,
1156 GtkAllocation *allocation)
1157{
1158 MatePanelAppletPrivate *priv;
1159 GtkAllocation child_allocation;
1160 MatePanelApplet *applet;
1161
1162 if (!mate_panel_applet_can_focus (widget)) {
1163 GTK_WIDGET_CLASS (mate_panel_applet_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((mate_panel_applet_parent_class)), ((gtk_widget_get_type (
)))))))
->size_allocate (widget, allocation);
1164 } else {
1165 int border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_container_get_type ()))))))
);
1166
1167 gtk_widget_set_allocation (widget, allocation);
1168 GtkBin *bin = GTK_BIN (widget)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_bin_get_type ()))))))
;
1169
1170 child_allocation.x = 0;
1171 child_allocation.y = 0;
1172
1173 child_allocation.width = MAX (allocation->width - border_width * 2, 0)(((allocation->width - border_width * 2) > (0)) ? (allocation
->width - border_width * 2) : (0))
;
1174 child_allocation.height = MAX (allocation->height - border_width * 2, 0)(((allocation->height - border_width * 2) > (0)) ? (allocation
->height - border_width * 2) : (0))
;
1175
1176 if (gtk_widget_get_realized (widget))
1177 gdk_window_move_resize (gtk_widget_get_window (widget),
1178 allocation->x + border_width,
1179 allocation->y + border_width,
1180 child_allocation.width,
1181 child_allocation.height);
1182
1183 GtkWidget *child = gtk_bin_get_child (bin);
1184 if (child)
1185 gtk_widget_size_allocate (child, &child_allocation);
1186 }
1187
1188 applet = MATE_PANEL_APPLET (widget);
1189 priv = mate_panel_applet_get_instance_private (applet);
1190
1191 if ((priv->previous_height != allocation->height) ||
1192 (priv->previous_width != allocation->width)) {
1193 priv->previous_height = allocation->height;
1194 priv->previous_width = allocation->width;
1195 mate_panel_applet_handle_background (applet);
1196 }
1197}
1198
1199static gboolean mate_panel_applet_draw(GtkWidget* widget, cairo_t* cr)
1200{
1201 GtkStyleContext *context;
1202 int border_width;
1203 gdouble x, y, width, height;
1204
1205 GTK_WIDGET_CLASS (mate_panel_applet_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((mate_panel_applet_parent_class)), ((gtk_widget_get_type (
)))))))
->draw(widget, cr);
1206
1207 if (!gtk_widget_has_focus (widget))
1208 return FALSE(0);
1209
1210 width = gtk_widget_get_allocated_width (widget);
1211 height = gtk_widget_get_allocated_height (widget);
1212
1213 border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_container_get_type ()))))))
);
1214
1215 x = 0;
1216 y = 0;
1217
1218 width -= 2 * border_width;
1219 height -= 2 * border_width;
1220
1221 context = gtk_widget_get_style_context (widget);
1222 gtk_style_context_save (context);
1223
1224 cairo_save (cr);
1225 gtk_render_focus (context, cr, x, y, width, height);
1226 cairo_restore (cr);
1227
1228 gtk_style_context_restore (context);
1229
1230 return FALSE(0);
1231}
1232
1233static gboolean
1234mate_panel_applet_focus (GtkWidget *widget,
1235 GtkDirectionType dir)
1236{
1237 MatePanelAppletPrivate *priv;
1238 gboolean ret;
1239 GtkWidget *previous_focus_child;
1240
1241 g_return_val_if_fail (MATE_PANEL_IS_APPLET (widget), FALSE)do { if ((MATE_PANEL_IS_APPLET (widget))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (widget)"
); return ((0)); } } while (0)
;
1242
1243 priv = mate_panel_applet_get_instance_private (MATE_PANEL_APPLET (widget));
1244 if (priv->moving_focus_out) {
1245 /*
1246 * Applet will retain focus if there is nothing else on the
1247 * panel to get focus
1248 */
1249 priv->moving_focus_out = FALSE(0);
1250 return FALSE(0);
1251 }
1252
1253 previous_focus_child = gtk_container_get_focus_child (GTK_CONTAINER (widget)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_container_get_type ()))))))
);
1254 if (!previous_focus_child && !gtk_widget_has_focus (widget)) {
1255 if (gtk_widget_get_has_tooltip (widget)) {
1256 gtk_widget_set_can_focus (widget, TRUE(!(0)));
1257 gtk_widget_grab_focus (widget);
1258 gtk_widget_set_can_focus (widget, FALSE(0));
1259 return TRUE(!(0));
1260 }
1261 }
1262 ret = GTK_WIDGET_CLASS (mate_panel_applet_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((mate_panel_applet_parent_class)), ((gtk_widget_get_type (
)))))))
->focus (widget, dir);
1263
1264 if (!ret && !previous_focus_child) {
1265 if (!gtk_widget_has_focus (widget)) {
1266 /*
1267 * Applet does not have a widget which can focus so set
1268 * the focus on the applet unless it already had focus
1269 * because it had a tooltip.
1270 */
1271 gtk_widget_set_can_focus (widget, TRUE(!(0)));
1272 gtk_widget_grab_focus (widget);
1273 gtk_widget_set_can_focus (widget, FALSE(0));
1274 ret = TRUE(!(0));
1275 }
1276 }
1277
1278 return ret;
1279}
1280
1281static gboolean
1282mate_panel_applet_parse_color (const gchar *color_str,
1283 GdkRGBA *color)
1284{
1285 g_assert (color_str && color)do { if (color_str && color) ; else g_assertion_message_expr
(((gchar*) 0), "mate-panel-applet.c", 1285, ((const char*) (
__func__)), "color_str && color"); } while (0)
;
1286
1287 return gdk_rgba_parse (color, color_str);
1288}
1289
1290#ifdef HAVE_X111
1291static gboolean
1292mate_panel_applet_parse_pixmap_str (const char *str,
1293 Window *xid,
1294 int *x,
1295 int *y)
1296{
1297 char **elements;
1298 char *tmp;
1299
1300 g_return_val_if_fail (str != NULL, FALSE)do { if ((str != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "str != NULL"); return
((0)); } } while (0)
;
1301 g_return_val_if_fail (xid != NULL, FALSE)do { if ((xid != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "xid != NULL"); return
((0)); } } while (0)
;
1302 g_return_val_if_fail (x != NULL, FALSE)do { if ((x != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "x != NULL"); return
((0)); } } while (0)
;
1303 g_return_val_if_fail (y != NULL, FALSE)do { if ((y != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "y != NULL"); return
((0)); } } while (0)
;
1304
1305 elements = g_strsplit (str, ",", -1);
1306
1307 if (!elements)
1308 return FALSE(0);
1309
1310 if (!elements [0] || !*elements [0] ||
1311 !elements [1] || !*elements [1] ||
1312 !elements [2] || !*elements [2])
1313 goto ERROR_AND_FREE;
1314
1315 *xid = strtol (elements [0], &tmp, 10);
1316 if (tmp == elements [0])
1317 goto ERROR_AND_FREE;
1318
1319 *x = strtol (elements [1], &tmp, 10);
1320 if (tmp == elements [1])
1321 goto ERROR_AND_FREE;
1322
1323 *y = strtol (elements [2], &tmp, 10);
1324 if (tmp == elements [2])
1325 goto ERROR_AND_FREE;
1326
1327 g_strfreev (elements);
1328 return TRUE(!(0));
1329
1330ERROR_AND_FREE:
1331 g_strfreev (elements);
1332 return FALSE(0);
1333}
1334
1335static cairo_surface_t *
1336mate_panel_applet_create_foreign_surface_for_display (GdkDisplay *display,
1337 GdkVisual *visual,
1338 Window xid)
1339{
1340 Statusint result = 0;
1341 Window window;
1342 gint x, y;
1343 guint width, height, border, depth;
1344
1345 gdk_x11_display_error_trap_push (display);
1346 result = XGetGeometry (GDK_DISPLAY_XDISPLAY (display)(gdk_x11_display_get_xdisplay (display)), xid, &window,
1347 &x, &y, &width, &height, &border, &depth);
1348 gdk_x11_display_error_trap_pop_ignored (display);
1349
1350 if (result == 0)
1351 return NULL((void*)0);
1352
1353 return cairo_xlib_surface_create (GDK_DISPLAY_XDISPLAY (display)(gdk_x11_display_get_xdisplay (display)),
1354 xid, gdk_x11_visual_get_xvisual (visual),
1355 width, height);
1356}
1357
1358static cairo_pattern_t *
1359mate_panel_applet_get_pattern_from_pixmap (MatePanelApplet *applet,
1360 Window xid,
1361 int x,
1362 int y)
1363{
1364 cairo_surface_t *background;
1365 cairo_surface_t *surface;
1366 GdkWindow *window;
1367 int width;
1368 int height;
1369 GdkDisplay *display;
1370 cairo_t *cr;
1371 cairo_pattern_t *pattern;
1372
1373 g_return_val_if_fail (MATE_PANEL_IS_APPLET (applet), NULL)do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return (((void*)0)); } } while (0)
;
1374
1375 if (!gtk_widget_get_realized (GTK_WIDGET (applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
))
1376 return NULL((void*)0);
1377
1378 window = gtk_widget_get_window (GTK_WIDGET (applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
);
1379 display = gdk_window_get_display (window);
1380
1381 background = mate_panel_applet_create_foreign_surface_for_display (display,
1382 gdk_window_get_visual (window),
1383 xid);
1384
1385 /* background can be NULL if the user changes the background very fast.
1386 * We'll get the next update, so it's not a big deal. */
1387 if (!background || cairo_surface_status (background) != CAIRO_STATUS_SUCCESS) {
1388 if (background)
1389 cairo_surface_destroy (background);
1390 return NULL((void*)0);
1391 }
1392
1393 width = gdk_window_get_width(window);
1394 height = gdk_window_get_height(window);
1395 surface = gdk_window_create_similar_surface (window,
1396 CAIRO_CONTENT_COLOR_ALPHA,
1397 width,
1398 height);
1399 gdk_x11_display_error_trap_push (display);
1400 cr = cairo_create (surface);
1401 cairo_set_source_surface (cr, background, -x, -y);
1402 cairo_rectangle (cr, 0, 0, width, height);
1403 cairo_fill (cr);
1404 gdk_x11_display_error_trap_pop_ignored (display);
1405
1406 cairo_surface_destroy (background);
1407 pattern = NULL((void*)0);
1408
1409 if (cairo_status (cr) == CAIRO_STATUS_SUCCESS) {
1410 pattern = cairo_pattern_create_for_surface (surface);
1411 }
1412
1413 cairo_destroy (cr);
1414 cairo_surface_destroy (surface);
1415
1416 return pattern;
1417}
1418#endif
1419
1420static MatePanelAppletBackgroundType
1421mate_panel_applet_handle_background_string (MatePanelApplet *applet,
1422 GdkRGBA *color,
1423 cairo_pattern_t **pattern)
1424{
1425 MatePanelAppletPrivate *priv;
1426 MatePanelAppletBackgroundType retval;
1427 char **elements;
1428
1429 priv = mate_panel_applet_get_instance_private (applet);
1430 retval = PANEL_NO_BACKGROUND;
1431
1432 if (!gtk_widget_get_realized (GTK_WIDGET (applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
) || !priv->background)
1433 return retval;
1434
1435 elements = g_strsplit (priv->background, ":", -1);
1436
1437 if (elements [0] && !strcmp (elements [0], "none" )) {
1438 retval = PANEL_NO_BACKGROUND;
1439
1440 } else if (elements [0] && !strcmp (elements [0], "color")) {
1441 g_return_val_if_fail (color != NULL, PANEL_NO_BACKGROUND)do { if ((color != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "color != NULL");
return (PANEL_NO_BACKGROUND); } } while (0)
;
1442
1443 if (!elements [1] || !mate_panel_applet_parse_color (elements [1], color)) {
1444
1445 g_warning ("Incomplete '%s' background type received", elements [0]);
1446 g_strfreev (elements);
1447 return PANEL_NO_BACKGROUND;
1448 }
1449
1450 retval = PANEL_COLOR_BACKGROUND;
1451
1452 } else if (elements [0] && !strcmp (elements [0], "pixmap")) {
1453#ifdef HAVE_X111
1454 if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gdk_display_get_default ())); GType __t = ((gdk_x11_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
) {
1455 Window pixmap_id;
1456 int x, y;
1457
1458 g_return_val_if_fail (pattern != NULL, PANEL_NO_BACKGROUND)do { if ((pattern != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "pattern != NULL"
); return (PANEL_NO_BACKGROUND); } } while (0)
;
1459
1460 if (!mate_panel_applet_parse_pixmap_str (elements [1], &pixmap_id, &x, &y)) {
1461 g_warning ("Incomplete '%s' background type received: %s",
1462 elements [0], elements [1]);
1463
1464 g_strfreev (elements);
1465 return PANEL_NO_BACKGROUND;
1466 }
1467
1468 *pattern = mate_panel_applet_get_pattern_from_pixmap (applet, pixmap_id, x, y);
1469 if (!*pattern) {
1470 g_warning ("Failed to get pattern %s", elements [1]);
1471 g_strfreev (elements);
1472 return PANEL_NO_BACKGROUND;
1473 }
1474
1475 retval = PANEL_PIXMAP_BACKGROUND;
1476 } else
1477#endif
1478 { /* not using X11 */
1479 g_warning("Received pixmap background type, which is only supported on X11");
1480 }
1481 } else
1482 g_warning ("Unknown background type received");
1483
1484 g_strfreev (elements);
1485
1486 return retval;
1487}
1488
1489MatePanelAppletBackgroundType
1490mate_panel_applet_get_background (MatePanelApplet *applet,
1491 GdkRGBA *color,
1492 cairo_pattern_t **pattern)
1493{
1494 g_return_val_if_fail (MATE_PANEL_IS_APPLET (applet), PANEL_NO_BACKGROUND)do { if ((MATE_PANEL_IS_APPLET (applet))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "MATE_PANEL_IS_APPLET (applet)"
); return (PANEL_NO_BACKGROUND); } } while (0)
;
1495
1496 /* initial sanity */
1497 if (pattern != NULL((void*)0))
1498 *pattern = NULL((void*)0);
1499
1500 if (color != NULL((void*)0))
1501 memset (color, 0, sizeof (GdkRGBA));
1502
1503 return mate_panel_applet_handle_background_string (applet, color, pattern);
1504}
1505
1506static void
1507mate_panel_applet_set_background_string (MatePanelApplet *applet,
1508 const gchar *background)
1509{
1510 MatePanelAppletPrivate *priv;
1511
1512 priv = mate_panel_applet_get_instance_private (applet);
1513
1514 if (priv->background == background)
1515 return;
1516
1517 if (g_strcmp0 (priv->background, background) == 0)
1518 return;
1519
1520 g_free (priv->background);
1521 priv->background = background ? g_strdup (background)g_strdup_inline (background) : NULL((void*)0);
1522 mate_panel_applet_handle_background (applet);
1523
1524 g_object_notify (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
, "background");
1525}
1526
1527static void
1528mate_panel_applet_handle_background (MatePanelApplet *applet)
1529{
1530 MatePanelAppletBackgroundType type;
1531
1532 GdkRGBA color;
1533 cairo_pattern_t *pattern;
1534
1535 type = mate_panel_applet_get_background (applet, &color, &pattern);
1536
1537 if (!gdk_screen_is_composited (gdk_screen_get_default ())) {
1538 color.alpha = 1.;
1539 }
1540
1541 switch (type) {
1542 case PANEL_NO_BACKGROUND:
1543 g_signal_emit (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
,
1544 mate_panel_applet_signals [CHANGE_BACKGROUND],
1545 0, PANEL_NO_BACKGROUND, NULL((void*)0), NULL((void*)0));
1546 break;
1547 case PANEL_COLOR_BACKGROUND:
1548 g_signal_emit (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
,
1549 mate_panel_applet_signals [CHANGE_BACKGROUND],
1550 0, PANEL_COLOR_BACKGROUND, &color, NULL((void*)0));
1551 break;
1552 case PANEL_PIXMAP_BACKGROUND:
1553 g_signal_emit (G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
,
1554 mate_panel_applet_signals [CHANGE_BACKGROUND],
1555
1556 0, PANEL_PIXMAP_BACKGROUND, NULL((void*)0), pattern);
1557
1558 cairo_pattern_destroy (pattern);
1559
1560 break;
1561 default:
1562 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "mate-panel-applet.c"
, 1562, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1563 break;
1564 }
1565}
1566
1567static void
1568mate_panel_applet_realize (GtkWidget *widget)
1569{
1570 MatePanelApplet *applet;
1571 MatePanelAppletPrivate *priv;
1572
1573 GTK_WIDGET_CLASS (mate_panel_applet_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((mate_panel_applet_parent_class)), ((gtk_widget_get_type (
)))))))
->realize (widget);
1574
1575 applet = MATE_PANEL_APPLET (widget);
1576 priv = mate_panel_applet_get_instance_private (applet);
1577 if (priv->background)
1578 mate_panel_applet_handle_background (applet);
1579}
1580
1581static void
1582mate_panel_applet_move_focus_out_of_applet (MatePanelApplet *applet,
1583 GtkDirectionType dir)
1584{
1585 MatePanelAppletPrivate *priv;
1586 GtkWidget *toplevel;
1587
1588 priv = mate_panel_applet_get_instance_private (applet);
1589 priv->moving_focus_out = TRUE(!(0));
1590 toplevel = gtk_widget_get_toplevel (GTK_WIDGET (applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
);
1591 g_return_if_fail (toplevel)do { if ((toplevel)) { } else { g_return_if_fail_warning (((gchar
*) 0), ((const char*) (__func__)), "toplevel"); return; } } while
(0)
;
1592
1593 gtk_widget_child_focus (toplevel, dir);
1594 priv->moving_focus_out = FALSE(0);
1595}
1596
1597static void
1598mate_panel_applet_change_background(MatePanelApplet *applet,
1599 MatePanelAppletBackgroundType type,
1600 GdkRGBA* color,
1601 cairo_pattern_t *pattern)
1602{
1603 MatePanelAppletPrivate *priv;
1604 GdkWindow *window;
1605
1606 priv = mate_panel_applet_get_instance_private (applet);
1607
1608 if (priv->out_of_process)
1609 window = gtk_widget_get_window (GTK_WIDGET (priv->plug)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->plug)), ((gtk_widget_get_type ()))))))
);
1610 else
1611 window = gtk_widget_get_window (GTK_WIDGET (applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
);
1612
1613 gtk_widget_set_app_paintable (GTK_WIDGET (applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
,TRUE(!(0)));
1614
1615 if (priv->out_of_process)
1616 _mate_panel_applet_apply_css (GTK_WIDGET (priv->plug)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->plug)), ((gtk_widget_get_type ()))))))
,type);
1617
1618 switch (type) {
1619 case PANEL_NO_BACKGROUND:
1620 if (priv->out_of_process){
1621 cairo_pattern_t *transparent = cairo_pattern_create_rgba (0, 0, 0, 0); /* Using NULL here breaks transparent */
1622 gdk_window_set_background_pattern (window, transparent); /* backgrounds set by GTK theme */
1623 cairo_pattern_destroy (transparent);
1624 }
1625 break;
1626 case PANEL_COLOR_BACKGROUND:
1627 if (priv->out_of_process){
1628 gdk_window_set_background_rgba(window,color);
1629 gtk_widget_queue_draw (priv->plug); /*change the bg right away always */
1630 }
1631 break;
1632 case PANEL_PIXMAP_BACKGROUND:
1633 if (priv->out_of_process){
1634 gdk_window_set_background_pattern(window,pattern);
1635 gtk_widget_queue_draw (priv->plug); /*change the bg right away always */
1636 }
1637 break;
1638 default:
1639 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "mate-panel-applet.c"
, 1639, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1640 break;
1641 }
1642
1643 if (priv->out_of_process){
1644 GtkStyleContext *context;
1645
1646 context = gtk_widget_get_style_context (GTK_WIDGET (priv->plug)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->plug)), ((gtk_widget_get_type ()))))))
);
1647
1648 if (priv->orient == MATE_PANEL_APPLET_ORIENT_UP ||
1649 priv->orient == MATE_PANEL_APPLET_ORIENT_DOWN)
1650 gtk_style_context_add_class (context, "horizontal");
1651 else
1652 gtk_style_context_add_class (context, "vertical");
1653 }
1654}
1655
1656static void
1657mate_panel_applet_get_property (GObject *object,
1658 guint prop_id,
1659 GValue *value,
1660 GParamSpec *pspec)
1661{
1662 MatePanelApplet *applet;
1663 MatePanelAppletPrivate *priv;
1664
1665 applet = MATE_PANEL_APPLET (object);
1666 priv = mate_panel_applet_get_instance_private (applet);
1667
1668 switch (prop_id) {
1669 case PROP_OUT_OF_PROCESS:
1670 g_value_set_boolean (value, priv->out_of_process);
1671 break;
1672 case PROP_ID:
1673 g_value_set_string (value, priv->id);
1674 break;
1675 case PROP_CLOSURE:
1676 g_value_set_pointer (value, priv->closure);
1677 break;
1678 case PROP_CONNECTION:
1679 g_value_set_object (value, priv->connection);
1680 break;
1681 case PROP_PREFS_PATH:
1682 g_value_set_string (value, priv->prefs_path);
1683 break;
1684 case PROP_ORIENT:
1685 g_value_set_uint (value, priv->orient);
1686 break;
1687 case PROP_SIZE:
1688 g_value_set_uint (value, priv->size);
1689 break;
1690 case PROP_BACKGROUND:
1691 g_value_set_string (value, priv->background);
1692 break;
1693 case PROP_FLAGS:
1694 g_value_set_uint (value, priv->flags);
1695 break;
1696 case PROP_SIZE_HINTS: {
1697 GVariant **children;
1698 GVariant *variant;
1699 gint i;
1700
1701 children = g_new (GVariant *, priv->size_hints_len)((GVariant * *) g_malloc_n ((priv->size_hints_len), sizeof
(GVariant *)))
;
1702 for (i = 0; i < priv->size_hints_len; i++)
1703 children[i] = g_variant_new_int32 (priv->size_hints[i]);
1704 variant = g_variant_new_array (G_VARIANT_TYPE_INT32((const GVariantType *) "i"),
1705 children, priv->size_hints_len);
1706 g_free (children);
1707 g_value_set_pointer (value, variant);
1708 break;
1709 }
1710 case PROP_LOCKED:
1711 g_value_set_boolean (value, priv->locked);
1712 break;
1713 case PROP_LOCKED_DOWN:
1714 g_value_set_boolean (value, priv->locked_down);
1715 break;
1716 default:
1717 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "mate-panel-applet.c", 1717, ("property"), _glib__property_id
, _glib__pspec->name, g_type_name ((((((GTypeClass*) (((GTypeInstance
*) (_glib__pspec))->g_class))->g_type)))), (g_type_name
((((((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
1718 }
1719}
1720
1721static void
1722mate_panel_applet_set_property (GObject *object,
1723 guint prop_id,
1724 const GValue *value,
1725 GParamSpec *pspec)
1726{
1727 MatePanelApplet *applet;
1728 MatePanelAppletPrivate *priv;
1729
1730 applet = MATE_PANEL_APPLET (object);
1731 priv = mate_panel_applet_get_instance_private (applet);
1732
1733 switch (prop_id) {
1734 case PROP_OUT_OF_PROCESS:
1735 priv->out_of_process = g_value_get_boolean (value);
1736 break;
1737 case PROP_ID:
1738 priv->id = g_value_dup_string (value);
1739 break;
1740 case PROP_CLOSURE:
1741 priv->closure = g_value_get_pointer (value);
1742 g_closure_set_marshal (priv->closure,
1743 mate_panel_applet_marshal_BOOLEAN__STRING);
1744 break;
1745 case PROP_CONNECTION:
1746 priv->connection = g_value_dup_object (value);
1747 break;
1748 case PROP_PREFS_PATH:
1749 mate_panel_applet_set_preferences_path (applet, g_value_get_string (value));
1750 break;
1751 case PROP_ORIENT:
1752 mate_panel_applet_set_orient (applet, g_value_get_uint (value));
1753 break;
1754 case PROP_SIZE:
1755 mate_panel_applet_set_size (applet, g_value_get_uint (value));
1756 break;
1757 case PROP_BACKGROUND:
1758 mate_panel_applet_set_background_string (applet, g_value_get_string (value));
1759 break;
1760 case PROP_FLAGS:
1761 mate_panel_applet_set_flags (applet, g_value_get_uint (value));
1762 break;
1763 case PROP_SIZE_HINTS: {
1764 const int *size_hints;
1765 gsize n_elements;
1766
1767 size_hints = g_variant_get_fixed_array (g_value_get_pointer (value),
1768 &n_elements, sizeof (gint32));
1769 mate_panel_applet_set_size_hints (applet, size_hints, n_elements, 0);
1770 }
1771 break;
1772 case PROP_LOCKED:
1773 mate_panel_applet_set_locked (applet, g_value_get_boolean (value));
1774 break;
1775 case PROP_LOCKED_DOWN:
1776 mate_panel_applet_set_locked_down (applet, g_value_get_boolean (value));
1777 break;
1778 default:
1779 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "mate-panel-applet.c", 1779, ("property"), _glib__property_id
, _glib__pspec->name, g_type_name ((((((GTypeClass*) (((GTypeInstance
*) (_glib__pspec))->g_class))->g_type)))), (g_type_name
((((((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
1780 }
1781}
1782
1783static void
1784add_tab_bindings (GtkBindingSet *binding_set,
1785 GdkModifierType modifiers,
1786 GtkDirectionType direction)
1787{
1788 gtk_binding_entry_add_signal (binding_set, GDK_KEY_Tab0xff09, modifiers,
1789 "move_focus_out_of_applet", 1,
1790 GTK_TYPE_DIRECTION_TYPE(gtk_direction_type_get_type ()), direction);
1791 gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Tab0xff89, modifiers,
1792 "move_focus_out_of_applet", 1,
1793 GTK_TYPE_DIRECTION_TYPE(gtk_direction_type_get_type ()), direction);
1794}
1795
1796static void
1797mate_panel_applet_setup (MatePanelApplet *applet)
1798{
1799 MatePanelAppletPrivate *priv;
1800 GValue value = {0, };
1801 GArray *params;
1802 guint i;
1803 gboolean ret;
1804
1805 priv = mate_panel_applet_get_instance_private (applet);
1806
1807 g_assert ((priv->id != NULL) && (priv->closure != NULL))do { if ((priv->id != ((void*)0)) && (priv->closure
!= ((void*)0))) ; else g_assertion_message_expr (((gchar*) 0
), "mate-panel-applet.c", 1807, ((const char*) (__func__)), "(priv->id != NULL) && (priv->closure != NULL)"
); } while (0)
;
1808
1809 params = g_array_sized_new (FALSE(0), TRUE(!(0)), sizeof (GValue), 2);
1810 value.g_type = 0;
1811 g_value_init (&value, G_TYPE_OBJECT((GType) ((20) << (2))));
1812 g_value_set_object (&value, G_OBJECT (applet)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), (((GType) ((20) << (2))))))))
);
1813 g_array_append_val (params, value)g_array_append_vals (params, &(value), 1);
1814
1815 value.g_type = 0;
1816 g_value_init (&value, G_TYPE_STRING((GType) ((16) << (2))));
1817 g_value_set_string (&value, priv->id);
1818 g_array_append_val (params, value)g_array_append_vals (params, &(value), 1);
1819
1820 value.g_type = 0;
1821 g_value_init (&value, G_TYPE_BOOLEAN((GType) ((5) << (2))));
1822
1823 g_closure_invoke (priv->closure,
1824 &value, params->len,
1825 (GValue *) params->data,
1826 NULL((void*)0));
1827
1828 for (i = 0; i < params->len; i++)
1829 g_value_unset (&g_array_index (params, GValue, i)(((GValue*) (void *) (params)->data) [(i)]));
1830 g_array_free (params, TRUE(!(0)));
1831
1832 ret = g_value_get_boolean (&value);
1833 g_value_unset (&value);
1834
1835 if (!ret) { /* FIXME */
1836 g_warning ("need to free the control here");
1837
1838 return;
1839 }
1840}
1841
1842void _mate_panel_applet_apply_css(GtkWidget* widget, MatePanelAppletBackgroundType type)
1843{
1844 GtkStyleContext* context;
1845
1846 context = gtk_widget_get_style_context (widget);
1847
1848 switch (type) {
1849 case PANEL_NO_BACKGROUND:
1850 gtk_style_context_remove_class (context, "mate-custom-panel-background");
1851 break;
1852 case PANEL_COLOR_BACKGROUND:
1853 case PANEL_PIXMAP_BACKGROUND:
1854 gtk_style_context_add_class (context, "mate-custom-panel-background");
1855 break;
1856 default:
1857 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "mate-panel-applet.c"
, 1857, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1858 break;
1859 }
1860}
1861
1862#ifdef HAVE_X111
1863static void _mate_panel_applet_prepare_css (GtkStyleContext *context)
1864{
1865 GtkCssProvider *provider;
1866
1867 g_return_if_fail (GDK_IS_X11_DISPLAY (gdk_display_get_default ()))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((gdk_display_get_default ())); GType __t = ((gdk_x11_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0
), ((const char*) (__func__)), "GDK_IS_X11_DISPLAY (gdk_display_get_default ())"
); return; } } while (0)
;
1868 provider = gtk_css_provider_new ();
1869 gtk_css_provider_load_from_data (provider,
1870 "#PanelPlug {\n"
1871 " background-repeat: no-repeat;\n" /*disable in gtk theme features */
1872 " background-size: cover; " /*that don't work on panel-toplevel */
1873 " }\n"
1874 ".mate-custom-panel-background{\n" /*prepare CSS for user set theme */
1875 " background-color: rgba (0, 0, 0, 0);\n"
1876 " background-image: none;\n"
1877 "}",
1878 -1, NULL((void*)0));
1879
1880 gtk_style_context_add_provider (context,
1881 GTK_STYLE_PROVIDER (provider)((((GtkStyleProvider*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((provider)), ((gtk_style_provider_get_type (
)))))))
,
1882 GTK_STYLE_PROVIDER_PRIORITY_APPLICATION600);
1883 g_object_unref (provider);
1884}
1885#endif /* HAVE_X11 */
1886
1887static void
1888mate_panel_applet_init (MatePanelApplet *applet)
1889{
1890 MatePanelAppletPrivate *priv;
1891
1892 priv = mate_panel_applet_get_instance_private (applet);
1893
1894 priv->flags = MATE_PANEL_APPLET_FLAGS_NONE;
1895 priv->orient = MATE_PANEL_APPLET_ORIENT_UP;
1896 priv->size = 24;
1897
1898 priv->panel_action_group = gtk_action_group_new ("PanelActions");
1899 gtk_action_group_set_translation_domain (priv->panel_action_group, GETTEXT_PACKAGE"mate-panel");
1900 gtk_action_group_add_actions (priv->panel_action_group,
1901 menu_entries,
1902 G_N_ELEMENTS (menu_entries)(sizeof (menu_entries) / sizeof ((menu_entries)[0])),
1903 applet);
1904 gtk_action_group_add_toggle_actions (priv->panel_action_group,
1905 menu_toggle_entries,
1906 G_N_ELEMENTS (menu_toggle_entries)(sizeof (menu_toggle_entries) / sizeof ((menu_toggle_entries)
[0]))
,
1907 applet);
1908
1909 priv->ui_manager = gtk_ui_manager_new ();
1910 gtk_ui_manager_insert_action_group (priv->ui_manager,
1911 priv->panel_action_group, 1);
1912 gtk_ui_manager_add_ui_from_string (priv->ui_manager,
1913 panel_menu_ui, -1, NULL((void*)0));
1914
1915 gtk_widget_set_events (GTK_WIDGET (applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
,
1916 GDK_BUTTON_PRESS_MASK |
1917 GDK_BUTTON_RELEASE_MASK);
1918}
1919
1920static GObject *
1921mate_panel_applet_constructor (GType type,
1922 guint n_construct_properties,
1923 GObjectConstructParam *construct_properties)
1924{
1925 GObject *object;
1926 MatePanelApplet *applet;
1927 MatePanelAppletPrivate *priv;
1928
1929 object = G_OBJECT_CLASS (mate_panel_applet_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((mate_panel_applet_parent_class)), (((GType) ((20) <<
(2))))))))
->constructor (type,
1930 n_construct_properties,
1931 construct_properties);
1932 applet = MATE_PANEL_APPLET (object);
1933 priv = mate_panel_applet_get_instance_private (applet);
1934
1935 if (!priv->out_of_process)
1936 return object;
1937
1938#ifdef HAVE_X111
1939 if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gdk_display_get_default ())); GType __t = ((gdk_x11_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
)
1940 {
1941 GtkStyleContext *context;
1942 GtkWidget *widget;
1943
1944 priv->plug = gtk_plug_new (0);
1945 widget = GTK_WIDGET (priv->plug)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->plug)), ((gtk_widget_get_type ()))))))
;
1946 gtk_widget_set_visual (widget,
1947 gdk_screen_get_rgba_visual (gtk_widget_get_screen (widget)));
1948 context = gtk_widget_get_style_context (widget);
1949 gtk_style_context_add_class (context, "gnome-panel-menu-bar");
1950 gtk_style_context_add_class (context, "mate-panel-menu-bar");
1951 gtk_widget_set_name (widget, "PanelPlug");
1952 _mate_panel_applet_prepare_css (context);
1953
1954 g_signal_connect_swapped (priv->plug, "embedded",g_signal_connect_data ((priv->plug), ("embedded"), (((GCallback
) (mate_panel_applet_setup))), (applet), ((void*)0), G_CONNECT_SWAPPED
)
1955 G_CALLBACK (mate_panel_applet_setup),g_signal_connect_data ((priv->plug), ("embedded"), (((GCallback
) (mate_panel_applet_setup))), (applet), ((void*)0), G_CONNECT_SWAPPED
)
1956 applet)g_signal_connect_data ((priv->plug), ("embedded"), (((GCallback
) (mate_panel_applet_setup))), (applet), ((void*)0), G_CONNECT_SWAPPED
)
;
1957
1958 gtk_container_add (GTK_CONTAINER (priv->plug)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->plug)), ((gtk_container_get_type ()))))))
, GTK_WIDGET (applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
);
1959 } else
1960#endif
1961 { /* not using X11 */
1962 g_warning ("Requested construction of an out-of-process applet, which is only possible on X11");
1963 }
1964
1965 return object;
1966}
1967
1968static void
1969mate_panel_applet_constructed (GObject* object)
1970{
1971 MatePanelApplet* applet = MATE_PANEL_APPLET(object);
1972
1973 /* Rename the class to have compatibility with all GTK2 themes
1974 * https://github.com/perberos/Mate-Desktop-Environment/issues/27
1975 */
1976 gtk_widget_set_name(GTK_WIDGET(applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
, "PanelApplet");
1977
1978 mate_panel_applet_register_object (applet);
1979}
1980
1981static void
1982mate_panel_applet_class_init (MatePanelAppletClass *klass)
1983{
1984 GObjectClass *gobject_class = (GObjectClass *) klass;
1985 GtkWidgetClass *widget_class = (GtkWidgetClass *) klass;
1986 GtkBindingSet *binding_set;
1987
1988 gobject_class->get_property = mate_panel_applet_get_property;
1989 gobject_class->set_property = mate_panel_applet_set_property;
1990 gobject_class->constructor = mate_panel_applet_constructor;
1991 gobject_class->constructed = mate_panel_applet_constructed;
1992 klass->move_focus_out_of_applet = mate_panel_applet_move_focus_out_of_applet;
1993 klass->change_background = mate_panel_applet_change_background;
1994 widget_class->button_press_event = mate_panel_applet_button_press;
1995 widget_class->button_release_event = mate_panel_applet_button_release;
1996 widget_class->get_request_mode = mate_panel_applet_get_request_mode;
1997 widget_class->get_preferred_width = mate_panel_applet_get_preferred_width;
1998 widget_class->get_preferred_height = mate_panel_applet_get_preferred_height;
1999 widget_class->draw = mate_panel_applet_draw;
2000 widget_class->size_allocate = mate_panel_applet_size_allocate;
2001 widget_class->focus = mate_panel_applet_focus;
2002 widget_class->realize = mate_panel_applet_realize;
2003 widget_class->key_press_event = mate_panel_applet_key_press_event;
2004
2005 gobject_class->finalize = mate_panel_applet_finalize;
2006
2007 g_object_class_install_property (gobject_class,
2008 PROP_OUT_OF_PROCESS,
2009 g_param_spec_boolean ("out-of-process",
2010 "out-of-process",
2011 "out-of-process",
2012 TRUE(!(0)),
2013 G_PARAM_CONSTRUCT_ONLY |
2014 G_PARAM_READWRITE));
2015 g_object_class_install_property (gobject_class,
2016 PROP_ID,
2017 g_param_spec_string ("id",
2018 "Id",
2019 "The Applet identifier",
2020 NULL((void*)0),
2021 G_PARAM_CONSTRUCT_ONLY |
2022 G_PARAM_READWRITE));
2023 g_object_class_install_property (gobject_class,
2024 PROP_CLOSURE,
2025 g_param_spec_pointer ("closure",
2026 "GClosure",
2027 "The Applet closure",
2028 G_PARAM_CONSTRUCT_ONLY |
2029 G_PARAM_READWRITE));
2030 g_object_class_install_property (gobject_class,
2031 PROP_CONNECTION,
2032 g_param_spec_object ("connection",
2033 "Connection",
2034 "The DBus Connection",
2035 G_TYPE_DBUS_CONNECTION(g_dbus_connection_get_type ()),
2036 G_PARAM_CONSTRUCT_ONLY |
2037 G_PARAM_READWRITE));
2038 g_object_class_install_property (gobject_class,
2039 PROP_PREFS_PATH,
2040 g_param_spec_string ("prefs-path",
2041 "PrefsPath",
2042 "GSettings Preferences Path",
2043 NULL((void*)0),
2044 G_PARAM_READWRITE));
2045 g_object_class_install_property (gobject_class,
2046 PROP_ORIENT,
2047 g_param_spec_uint ("orient",
2048 "Orient",
2049 "Panel Applet Orientation",
2050 MATE_PANEL_APPLET_ORIENT_FIRSTMATE_PANEL_APPLET_ORIENT_UP,
2051 MATE_PANEL_APPLET_ORIENT_LASTMATE_PANEL_APPLET_ORIENT_RIGHT,
2052 MATE_PANEL_APPLET_ORIENT_UP,
2053 G_PARAM_READWRITE));
2054 g_object_class_install_property (gobject_class,
2055 PROP_SIZE,
2056 g_param_spec_uint ("size",
2057 "Size",
2058 "Panel Applet Size",
2059 0, G_MAXUINT(2147483647 *2U +1U), 0,
2060 G_PARAM_READWRITE));
2061 g_object_class_install_property (gobject_class,
2062 PROP_BACKGROUND,
2063 g_param_spec_string ("background",
2064 "Background",
2065 "Panel Applet Background",
2066 NULL((void*)0),
2067 G_PARAM_READWRITE));
2068 g_object_class_install_property (gobject_class,
2069 PROP_FLAGS,
2070 g_param_spec_uint ("flags",
2071 "Flags",
2072 "Panel Applet flags",
2073 MATE_PANEL_APPLET_FLAGS_NONE,
2074 MATE_PANEL_APPLET_FLAGS_ALL(MATE_PANEL_APPLET_EXPAND_MAJOR|MATE_PANEL_APPLET_EXPAND_MINOR
|MATE_PANEL_APPLET_HAS_HANDLE)
,
2075 MATE_PANEL_APPLET_FLAGS_NONE,
2076 G_PARAM_READWRITE));
2077 g_object_class_install_property (gobject_class,
2078 PROP_SIZE_HINTS,
2079 /* FIXME: value_array? */
2080 g_param_spec_pointer ("size-hints",
2081 "SizeHints",
2082 "Panel Applet Size Hints",
2083 G_PARAM_READWRITE));
2084 g_object_class_install_property (gobject_class,
2085 PROP_LOCKED,
2086 g_param_spec_boolean ("locked",
2087 "Locked",
2088 "Whether Panel Applet is locked",
2089 FALSE(0),
2090 G_PARAM_READWRITE));
2091 g_object_class_install_property (gobject_class,
2092 PROP_LOCKED_DOWN,
2093 g_param_spec_boolean ("locked-down",
2094 "LockedDown",
2095 "Whether Panel Applet is locked down",
2096 FALSE(0),
2097 G_PARAM_READWRITE));
2098
2099 mate_panel_applet_signals [CHANGE_ORIENT] =
2100 g_signal_new ("change-orient",
2101 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2102 G_SIGNAL_RUN_LAST,
2103 G_STRUCT_OFFSET (MatePanelAppletClass, change_orient)((glong) __builtin_offsetof(MatePanelAppletClass, change_orient
))
,
2104 NULL((void*)0),
2105 NULL((void*)0),
2106 mate_panel_applet_marshal_VOID__UINTg_cclosure_marshal_VOID__UINT,
2107 G_TYPE_NONE((GType) ((1) << (2))),
2108 1,
2109 G_TYPE_UINT((GType) ((7) << (2))));
2110
2111 mate_panel_applet_signals [CHANGE_SIZE] =
2112 g_signal_new ("change-size",
2113 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2114 G_SIGNAL_RUN_LAST,
2115 G_STRUCT_OFFSET (MatePanelAppletClass, change_size)((glong) __builtin_offsetof(MatePanelAppletClass, change_size
))
,
2116 NULL((void*)0),
2117 NULL((void*)0),
2118 mate_panel_applet_marshal_VOID__INTg_cclosure_marshal_VOID__INT,
2119 G_TYPE_NONE((GType) ((1) << (2))),
2120 1,
2121 G_TYPE_INT((GType) ((6) << (2))));
2122
2123 mate_panel_applet_signals [CHANGE_BACKGROUND] =
2124 g_signal_new ("change-background",
2125 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2126 G_SIGNAL_RUN_LAST,
2127 G_STRUCT_OFFSET (MatePanelAppletClass, change_background)((glong) __builtin_offsetof(MatePanelAppletClass, change_background
))
,
2128 NULL((void*)0),
2129 NULL((void*)0),
2130 mate_panel_applet_marshal_VOID__ENUM_BOXED_OBJECT,
2131 G_TYPE_NONE((GType) ((1) << (2))),
2132 3,
2133 PANEL_TYPE_MATE_PANEL_APPLET_BACKGROUND_TYPEmate_panel_applet_background_type_get_type(),
2134 GDK_TYPE_RGBA(gdk_rgba_get_type ()),
2135 CAIRO_GOBJECT_TYPE_PATTERNcairo_gobject_pattern_get_type ());
2136
2137 mate_panel_applet_signals [MOVE_FOCUS_OUT_OF_APPLET] =
2138 g_signal_new ("move_focus_out_of_applet",
2139 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2140 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
2141 G_STRUCT_OFFSET (MatePanelAppletClass, move_focus_out_of_applet)((glong) __builtin_offsetof(MatePanelAppletClass, move_focus_out_of_applet
))
,
2142 NULL((void*)0),
2143 NULL((void*)0),
2144 mate_panel_applet_marshal_VOID__ENUMg_cclosure_marshal_VOID__ENUM,
2145 G_TYPE_NONE((GType) ((1) << (2))),
2146 1,
2147 GTK_TYPE_DIRECTION_TYPE(gtk_direction_type_get_type ()));
2148
2149 binding_set = gtk_binding_set_by_class (gobject_class);
2150 add_tab_bindings (binding_set, 0, GTK_DIR_TAB_FORWARD);
2151 add_tab_bindings (binding_set, GDK_SHIFT_MASK, GTK_DIR_TAB_BACKWARD);
2152 add_tab_bindings (binding_set, GDK_CONTROL_MASK, GTK_DIR_TAB_FORWARD);
2153 add_tab_bindings (binding_set, GDK_CONTROL_MASK | GDK_SHIFT_MASK, GTK_DIR_TAB_BACKWARD);
2154
2155 gtk_widget_class_set_css_name (widget_class, "PanelApplet");
2156}
2157
2158GtkWidget* mate_panel_applet_new(void)
2159{
2160 MatePanelApplet* applet = g_object_new(PANEL_TYPE_APPLETmate_panel_applet_get_type (), NULL((void*)0));
2161
2162 return GTK_WIDGET(applet)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_widget_get_type ()))))))
;
2163}
2164
2165static GdkEvent *
2166button_press_event_new (MatePanelApplet *applet,
2167 guint button,
2168 guint time)
2169{
2170 GdkDisplay *display;
2171 GdkSeat *seat;
2172 GdkDevice *device;
2173 GdkEvent *event;
2174
2175 display = gdk_display_get_default ();
2176 seat = gdk_display_get_default_seat (display);
2177 device = gdk_seat_get_pointer (seat);
2178
2179 event = gdk_event_new (GDK_BUTTON_PRESS);
2180
2181 event->button.time = time;
2182 event->button.button = button;
2183
2184 gdk_event_set_device (event, device);
2185
2186 return event;
2187}
2188
2189static void
2190method_call_cb (GDBusConnection *connection,
2191 const gchar *sender,
2192 const gchar *object_path,
2193 const gchar *interface_name,
2194 const gchar *method_name,
2195 GVariant *parameters,
2196 GDBusMethodInvocation *invocation,
2197 gpointer user_data)
2198{
2199 MatePanelApplet *applet = MATE_PANEL_APPLET (user_data);
2200
2201 if (g_strcmp0 (method_name, "PopupMenu") == 0) {
2202 guint button;
2203 guint time;
2204
2205 g_variant_get (parameters, "(uu)", &button, &time);
2206
2207 GdkEvent *event = button_press_event_new (applet, button, time);
2208 mate_panel_applet_menu_popup (applet, event);
2209 gdk_event_free (event);
2210
2211 g_dbus_method_invocation_return_value (invocation, NULL((void*)0));
2212 }
2213}
2214
2215static GVariant *
2216get_property_cb (GDBusConnection *connection,
2217 const gchar *sender,
2218 const gchar *object_path,
2219 const gchar *interface_name,
2220 const gchar *property_name,
2221 GError **error,
2222 gpointer user_data)
2223{
2224 MatePanelAppletPrivate *priv;
2225 GVariant *retval = NULL((void*)0);
2226
2227 priv = mate_panel_applet_get_instance_private (MATE_PANEL_APPLET (user_data));
2228
2229 if (g_strcmp0 (property_name, "PrefsPath") == 0) {
2230 retval = g_variant_new_string (priv->prefs_path ? priv->prefs_path : "");
2231 } else if (g_strcmp0 (property_name, "Orient") == 0) {
2232 retval = g_variant_new_uint32 (priv->orient);
2233 } else if (g_strcmp0 (property_name, "Size") == 0) {
2234 retval = g_variant_new_uint32 (priv->size);
2235 } else if (g_strcmp0 (property_name, "Background") == 0) {
2236 retval = g_variant_new_string (priv->background ? priv->background : "");
2237 } else if (g_strcmp0 (property_name, "Flags") == 0) {
2238 retval = g_variant_new_uint32 (priv->flags);
2239 } else if (g_strcmp0 (property_name, "SizeHints") == 0) {
2240 GVariant **children;
2241 gint i;
2242
2243 children = g_new (GVariant *, priv->size_hints_len)((GVariant * *) g_malloc_n ((priv->size_hints_len), sizeof
(GVariant *)))
;
2244 for (i = 0; i < priv->size_hints_len; i++)
2245 children[i] = g_variant_new_int32 (priv->size_hints[i]);
2246 retval = g_variant_new_array (G_VARIANT_TYPE_INT32((const GVariantType *) "i"),
Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption
2247 children, priv->size_hints_len);
2248 g_free (children);
2249 } else if (g_strcmp0 (property_name, "Locked") == 0) {
2250 retval = g_variant_new_boolean (priv->locked);
2251 } else if (g_strcmp0 (property_name, "LockedDown") == 0) {
2252 retval = g_variant_new_boolean (priv->locked_down);
2253 }
2254
2255 return retval;
2256}
2257
2258static gboolean
2259set_property_cb (GDBusConnection *connection,
2260 const gchar *sender,
2261 const gchar *object_path,
2262 const gchar *interface_name,
2263 const gchar *property_name,
2264 GVariant *value,
2265 GError **error,
2266 gpointer user_data)
2267{
2268 MatePanelApplet *applet = MATE_PANEL_APPLET (user_data);
2269
2270 if (g_strcmp0 (property_name, "PrefsPath") == 0) {
2271 mate_panel_applet_set_preferences_path (applet, g_variant_get_string (value, NULL((void*)0)));
2272 } else if (g_strcmp0 (property_name, "Orient") == 0) {
2273 mate_panel_applet_set_orient (applet, g_variant_get_uint32 (value));
2274 } else if (g_strcmp0 (property_name, "Size") == 0) {
2275 mate_panel_applet_set_size (applet, g_variant_get_uint32 (value));
2276 } else if (g_strcmp0 (property_name, "Background") == 0) {
2277 mate_panel_applet_set_background_string (applet, g_variant_get_string (value, NULL((void*)0)));
2278 } else if (g_strcmp0 (property_name, "Flags") == 0) {
2279 mate_panel_applet_set_flags (applet, g_variant_get_uint32 (value));
2280 } else if (g_strcmp0 (property_name, "SizeHints") == 0) {
2281 const int *size_hints;
2282 gsize n_elements;
2283
2284 size_hints = g_variant_get_fixed_array (value, &n_elements, sizeof (gint32));
2285 mate_panel_applet_set_size_hints (applet, size_hints, n_elements, 0);
2286 } else if (g_strcmp0 (property_name, "Locked") == 0) {
2287 mate_panel_applet_set_locked (applet, g_variant_get_boolean (value));
2288 } else if (g_strcmp0 (property_name, "LockedDown") == 0) {
2289 mate_panel_applet_set_locked_down (applet, g_variant_get_boolean (value));
2290 }
2291
2292 return TRUE(!(0));
2293}
2294
2295static const gchar introspection_xml[] =
2296 "<node>"
2297 "<interface name='org.mate.panel.applet.Applet'>"
2298 "<method name='PopupMenu'>"
2299 "<arg name='button' type='u' direction='in'/>"
2300 "<arg name='time' type='u' direction='in'/>"
2301 "</method>"
2302 "<property name='PrefsPath' type='s' access='readwrite'/>"
2303 "<property name='Orient' type='u' access='readwrite' />"
2304 "<property name='Size' type='u' access='readwrite'/>"
2305 "<property name='Background' type='s' access='readwrite'/>"
2306 "<property name='Flags' type='u' access='readwrite'/>"
2307 "<property name='SizeHints' type='ai' access='readwrite'/>"
2308 "<property name='Locked' type='b' access='readwrite'/>"
2309 "<property name='LockedDown' type='b' access='readwrite'/>"
2310 "<signal name='Move' />"
2311 "<signal name='RemoveFromPanel' />"
2312 "<signal name='Lock' />"
2313 "<signal name='Unlock' />"
2314 "</interface>"
2315 "</node>";
2316
2317static const GDBusInterfaceVTable interface_vtable = {
2318 method_call_cb,
2319 get_property_cb,
2320 set_property_cb,
2321 { 0 }
2322};
2323
2324static GDBusNodeInfo *introspection_data = NULL((void*)0);
2325
2326static void
2327mate_panel_applet_register_object (MatePanelApplet *applet)
2328{
2329 MatePanelAppletPrivate *priv;
2330 GError *error = NULL((void*)0);
2331 static gint id = 0;
2332
2333 if (!introspection_data)
2334 introspection_data = g_dbus_node_info_new_for_xml (introspection_xml, NULL((void*)0));
2335
2336 priv = mate_panel_applet_get_instance_private (applet);
2337 priv->object_path = g_strdup_printf (MATE_PANEL_APPLET_OBJECT_PATH"/org/mate/panel/applet/%s/%d", priv->id, id++);
2338 priv->object_id =
2339 g_dbus_connection_register_object (priv->connection,
2340 priv->object_path,
2341 introspection_data->interfaces[0],
2342 &interface_vtable,
2343 applet, NULL((void*)0),
2344 &error);
2345 if (!priv->object_id) {
2346 g_printerr ("Failed to register object %s: %s\n", priv->object_path, error->message);
2347 g_error_free (error);
2348 }
2349}
2350
2351static void mate_panel_applet_factory_main_finalized(gpointer data, GObject* object)
2352{
2353 gtk_main_quit();
2354
2355 if (introspection_data)
2356 {
2357 g_dbus_node_info_unref(introspection_data);
2358 introspection_data = NULL((void*)0);
2359 }
2360}
2361
2362#ifdef HAVE_X111
2363static int (*_x_error_func) (Display *, XErrorEvent *);
2364
2365static int
2366_x_error_handler (Display *display, XErrorEvent *error)
2367{
2368 if (!error->error_code)
2369 return 0;
2370
2371 /* If we got a BadDrawable or a BadWindow, we ignore it for now.
2372 * FIXME: We need to somehow distinguish real errors from
2373 * X-server-induced errors. Keeping a list of windows for which we
2374 * will ignore BadDrawables would be a good idea. */
2375 if (error->error_code == BadDrawable9 ||
2376 error->error_code == BadWindow3)
2377 return 0;
2378
2379 return _x_error_func (display, error);
2380}
2381
2382/*
2383 * To do graphical embedding in the X window system, MATE Panel
2384 * uses the classic foreign-window-reparenting trick. The
2385 * GtkPlug/GtkSocket widgets are used for this purpose. However,
2386 * serious robustness problems arise if the GtkSocket end of the
2387 * connection unexpectedly dies. The X server sends out DestroyNotify
2388 * events for the descendants of the GtkPlug (i.e., your embedded
2389 * component's windows) in effectively random order. Furthermore, if
2390 * you happened to be drawing on any of those windows when the
2391 * GtkSocket was destroyed (a common state of affairs), an X error
2392 * will kill your application.
2393 *
2394 * To solve this latter problem, MATE Panel sets up its own X error
2395 * handler which ignores certain X errors that might have been
2396 * caused by such a scenario. Other X errors get passed to gdk_x_error
2397 * normally.
2398 */
2399static void
2400_mate_panel_applet_setup_x_error_handler (void)
2401{
2402 static gboolean error_handler_setup = FALSE(0);
2403
2404 if (error_handler_setup)
2405 return;
2406
2407 error_handler_setup = TRUE(!(0));
2408
2409 _x_error_func = XSetErrorHandler (_x_error_handler);
2410}
2411#endif
2412
2413static int
2414_mate_panel_applet_factory_main_internal (const gchar *factory_id,
2415 gboolean out_process,
2416 GType applet_type,
2417 MatePanelAppletFactoryCallback callback,
2418 gpointer user_data)
2419{
2420 MatePanelAppletFactory* factory;
2421 GClosure* closure;
2422
2423 g_return_val_if_fail(factory_id != NULL, 1)do { if ((factory_id != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "factory_id != NULL"
); return (1); } } while (0)
;
2424 g_return_val_if_fail(callback != NULL, 1)do { if ((callback != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "callback != NULL"
); return (1); } } while (0)
;
2425 g_assert(g_type_is_a(applet_type, PANEL_TYPE_APPLET))do { if (((applet_type) == (mate_panel_applet_get_type ()) ||
(g_type_is_a) ((applet_type), (mate_panel_applet_get_type ()
)))) ; else g_assertion_message_expr (((gchar*) 0), "mate-panel-applet.c"
, 2425, ((const char*) (__func__)), "g_type_is_a(applet_type, PANEL_TYPE_APPLET)"
); } while (0)
;
2426
2427#ifdef HAVE_X111
2428 if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gdk_display_get_default ())); GType __t = ((gdk_x11_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
) {
2429 /*Use this both in and out of process as the tray applet always uses GtkSocket
2430 *to handle GtkStatusIcons whether the tray itself is built in or out of process
2431 */
2432 _mate_panel_applet_setup_x_error_handler();
2433 } else
2434#endif
2435 { /* not using X11 */
2436 if (out_process) {
2437 g_warning("Requested out-of-process applet, which is only supported on X11");
2438 return 1;
2439 }
2440 }
2441
2442 closure = g_cclosure_new(G_CALLBACK(callback)((GCallback) (callback)), user_data, NULL((void*)0));
2443 factory = mate_panel_applet_factory_new(factory_id, out_process, applet_type, closure);
2444 g_closure_unref(closure);
2445
2446 if (mate_panel_applet_factory_register_service(factory))
2447 {
2448 if (out_process)
2449 {
2450 g_object_weak_ref(G_OBJECT(factory)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((factory)), (((GType) ((20) << (2))))))))
, mate_panel_applet_factory_main_finalized, NULL((void*)0));
2451 gtk_main();
2452 }
2453
2454 return 0;
2455 }
2456
2457 g_object_unref (factory);
2458
2459 return 1;
2460}
2461
2462/**
2463 * mate_panel_applet_factory_main:
2464 * @out_process: boolean, dummy to support applets sending it
2465 * @factory_id: Factory ID.
2466 * @applet_type: GType of the applet this factory creates.
2467 * @callback: (scope call): Callback to be called when a new applet is to be created.
2468 * @data: (closure): Callback data.
2469 *
2470 * Returns: 0 on success, 1 if there is an error.
2471 */
2472int
2473mate_panel_applet_factory_main (const gchar *factory_id,
2474 gboolean out_process, /*Dummy to support applets w issues with this */
2475 GType applet_type,
2476 MatePanelAppletFactoryCallback callback,
2477 gpointer user_data)
2478{
2479 return _mate_panel_applet_factory_main_internal (factory_id, TRUE(!(0)), applet_type,
2480 callback, user_data);
2481}
2482
2483/**
2484 * mate_panel_applet_factory_setup_in_process: (skip)
2485 * @factory_id: Factory ID.
2486 * @applet_type: GType of the applet this factory creates.
2487 * @callback: (scope call): Callback to be called when a new applet is to be created.
2488 * @data: (closure): Callback data.
2489 *
2490 * Returns: 0 on success, 1 if there is an error.
2491 */
2492int
2493mate_panel_applet_factory_setup_in_process (const gchar *factory_id,
2494 GType applet_type,
2495 MatePanelAppletFactoryCallback callback,
2496 gpointer user_data)
2497{
2498 return _mate_panel_applet_factory_main_internal (factory_id, FALSE(0), applet_type,
2499 callback, user_data);
2500}
2501
2502/**
2503 * mate_panel_applet_set_background_widget:
2504 * @applet: a #PanelApplet.
2505 * @widget: a #GtkWidget.
2506 *
2507 * Configure #PanelApplet to automatically draw the background of the applet on
2508 * @widget. It is generally enough to call this function with @applet as
2509 * @widget.
2510 *
2511 * Deprecated: 3.20: Do not use this API. Since 3.20 this function does nothing.
2512 **/
2513
2514void
2515mate_panel_applet_set_background_widget (MatePanelApplet *applet,
2516 GtkWidget *widget)
2517{
2518}
2519
2520guint32
2521mate_panel_applet_get_xid (MatePanelApplet *applet,
2522 GdkScreen *screen)
2523{
2524 MatePanelAppletPrivate *priv;
2525
2526 priv = mate_panel_applet_get_instance_private (applet);
2527
2528 /* out_of_process should only be true on X11, so an extra runtime Wayland check is not needed */
2529 if (priv->out_of_process == FALSE(0))
2530 return 0;
2531
2532#ifdef HAVE_X111
2533 gtk_window_set_screen (GTK_WINDOW (priv->plug)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->plug)), ((gtk_window_get_type ()))))))
, screen);
2534 gtk_widget_show (priv->plug);
2535
2536 return gtk_plug_get_id (GTK_PLUG (priv->plug)((((GtkPlug*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->plug)), ((gtk_plug_get_type ()))))))
);
2537#else
2538 return 0;
2539#endif
2540}
2541
2542const gchar *
2543mate_panel_applet_get_object_path (MatePanelApplet *applet)
2544{
2545 MatePanelAppletPrivate *priv;
2546
2547 priv = mate_panel_applet_get_instance_private (applet);
2548
2549 return priv->object_path;
2550}
2551
2552G_MODULE_EXPORT__attribute__((visibility("default"))) GtkWidget *
2553mate_panel_applet_get_applet_widget (const gchar *factory_id,
2554 guint uid)
2555{
2556 GtkWidget *widget;
2557
2558 widget = mate_panel_applet_factory_get_applet_widget (factory_id, uid);
2559 if (!widget) {
2560 return NULL((void*)0);
2561 }
2562
2563 mate_panel_applet_setup (MATE_PANEL_APPLET (widget));
2564
2565 return widget;
2566}
diff --git a/2024-06-18-172109-13286-1@e182420b844f_master/report-fb6164.html b/2024-06-18-172109-13286-1@e182420b844f_master/report-fb6164.html new file mode 100644 index 00000000..1357b10e --- /dev/null +++ b/2024-06-18-172109-13286-1@e182420b844f_master/report-fb6164.html @@ -0,0 +1,1493 @@ + + + +/rootdir/libmate-panel-applet/tmp-introspectems2xjmx/MatePanelApplet-4.0.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:libmate-panel-applet/tmp-introspectems2xjmx/MatePanelApplet-4.0.c
Warning:line 239, column 11
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name MatePanelApplet-4.0.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/libmate-panel-applet -fcoverage-compilation-dir=/rootdir/libmate-panel-applet -resource-dir /usr/bin/../lib/clang/18 -D WITH_GZFILEOP -D WITH_GZFILEOP -D MATELOCALEDIR="/usr/local/share/locale" -I /usr/include/gtk-3.0 -I /usr/include/atk-1.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/cairo -I /usr/include/gio-unix-2.0 -I /usr/include/freetype2 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/webp -I /usr/include/cloudproviders -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/libpng16 -I /usr/include/pixman-1 -I /usr/include/sysprof-6 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/gio-unix-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /rootdir/libmate-panel-applet -I /rootdir/libmate-panel-applet -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-deprecated-declarations -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-18-172109-13286-1 -x c /rootdir/libmate-panel-applet/tmp-introspectems2xjmx/MatePanelApplet-4.0.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* This file is generated, do not edit */
2
3#undef GLIB_VERSION_MIN_REQUIRED((((2) << 16 | (80) << 8)))
4#undef GLIB_VERSION_MAX_ALLOWED((((2) << 16 | (80) << 8)))
5
6#include <glib.h>
7#include <string.h>
8#include <stdlib.h>
9
10/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
11 * GObject introspection: Dump introspection data
12 *
13 * Copyright (C) 2008 Colin Walters <walters@verbum.org>
14 *
15 * SPDX-License-Identifier: LGPL-2.1-or-later
16 *
17 * This library is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU Lesser General Public
19 * License as published by the Free Software Foundation; either
20 * version 2 of the License, or (at your option) any later version.
21 *
22 * This library is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25 * Lesser General Public License for more details.
26 *
27 * You should have received a copy of the GNU Lesser General Public
28 * License along with this library; if not, write to the
29 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
30 * Boston, MA 02111-1307, USA.
31 */
32
33/* This file is both compiled into libgirepository.so, and installed
34 * on the filesystem. But for the dumper, we want to avoid linking
35 * to libgirepository; see
36 * https://bugzilla.gnome.org/show_bug.cgi?id=630342
37 */
38#ifdef G_IREPOSITORY_COMPILATION
39#include "config.h"
40#include "girepository.h"
41#endif
42
43#include <glib.h>
44#include <glib-object.h>
45#include <gmodule.h>
46
47#include <stdlib.h>
48#include <stdio.h>
49#include <string.h>
50
51/* Analogue of g_output_stream_write_all(). */
52static gboolean
53write_all (FILE *out,
54 const void *buffer,
55 gsize count,
56 gsize *bytes_written,
57 GError **error)
58{
59 size_t ret;
60
61 ret = fwrite (buffer, 1, count, out);
62
63 if (bytes_written != NULL((void*)0))
64 *bytes_written = ret;
65
66 if (ret < count)
67 {
68 g_set_error (error, G_FILE_ERRORg_file_error_quark (), G_FILE_ERROR_FAILED,
69 "Failed to write to file");
70 return FALSE(0);
71 }
72
73 return TRUE(!(0));
74}
75
76/* Analogue of g_data_input_stream_read_line(). */
77static char *
78read_line (FILE *input,
79 size_t *len_out)
80{
81 GByteArray *buffer = g_byte_array_new ();
82 const guint8 nul = '\0';
83
84 while (TRUE(!(0)))
85 {
86 size_t ret;
87 guint8 byte;
88
89 ret = fread (&byte, 1, 1, input);
90 if (ret == 0)
91 break;
92
93 if (byte == '\n')
94 break;
95
96 g_byte_array_append (buffer, &byte, 1);
97 }
98
99 g_byte_array_append (buffer, &nul, 1);
100
101 if (len_out != NULL((void*)0))
102 *len_out = buffer->len - 1; /* don’t include terminating nul */
103
104 return (char *) g_byte_array_free (buffer, FALSE(0));
105}
106
107static void
108escaped_printf (FILE *out, const char *fmt, ...) G_GNUC_PRINTF (2, 3)__attribute__((__format__ (__printf__, 2, 3)));
109
110static void
111escaped_printf (FILE *out, const char *fmt, ...)
112{
113 char *str;
114 va_list args;
115 gsize written;
116 GError *error = NULL((void*)0);
117
118 va_start (args, fmt)__builtin_va_start(args, fmt);
119
120 str = g_markup_vprintf_escaped (fmt, args);
121 if (!write_all (out, str, strlen (str), &written, &error))
122 {
123 g_critical ("failed to write to iochannel: %s", error->message);
124 g_clear_error (&error);
125 }
126 g_free (str);
127
128 va_end (args)__builtin_va_end(args);
129}
130
131static void
132goutput_write (FILE *out, const char *str)
133{
134 gsize written;
135 GError *error = NULL((void*)0);
136 if (!write_all (out, str, strlen (str), &written, &error))
137 {
138 g_critical ("failed to write to iochannel: %s", error->message);
139 g_clear_error (&error);
140 }
141}
142
143typedef GType (*GetTypeFunc)(void);
144typedef GQuark (*ErrorQuarkFunc)(void);
145
146static GType
147invoke_get_type (GModule *self, const char *symbol, GError **error)
148{
149 GetTypeFunc sym;
150 GType ret;
151
152 if (!g_module_symbol (self, symbol, (void**)&sym))
153 {
154 g_set_error (error,
155 G_FILE_ERRORg_file_error_quark (),
156 G_FILE_ERROR_FAILED,
157 "Failed to find symbol '%s'", symbol);
158 return G_TYPE_INVALID((GType) ((0) << (2)));
159 }
160
161 ret = sym ();
162 if (ret == G_TYPE_INVALID((GType) ((0) << (2))))
163 {
164 g_set_error (error,
165 G_FILE_ERRORg_file_error_quark (),
166 G_FILE_ERROR_FAILED,
167 "Function '%s' returned G_TYPE_INVALID", symbol);
168 }
169 return ret;
170}
171
172static GQuark
173invoke_error_quark (GModule *self, const char *symbol, GError **error)
174{
175 ErrorQuarkFunc sym;
176
177 if (!g_module_symbol (self, symbol, (void**)&sym))
178 {
179 g_set_error (error,
180 G_FILE_ERRORg_file_error_quark (),
181 G_FILE_ERROR_FAILED,
182 "Failed to find symbol '%s'", symbol);
183 return G_TYPE_INVALID((GType) ((0) << (2)));
184 }
185
186 return sym ();
187}
188
189static char *
190value_transform_to_string (const GValue *value)
191{
192 GValue tmp = G_VALUE_INIT{ 0, { { 0 } } };
193 char *s = NULL((void*)0);
194
195 g_value_init (&tmp, G_TYPE_STRING((GType) ((16) << (2))));
196
197 if (g_value_transform (value, &tmp))
198 {
199 const char *str = g_value_get_string (&tmp);
200
201 if (str != NULL((void*)0))
202 s = g_strescape (str, NULL((void*)0));
203 }
204
205 g_value_unset (&tmp);
206
207 return s;
208}
209
210/* A simpler version of g_strdup_value_contents(), but with stable
211 * output and less complex semantics
212 */
213static char *
214value_to_string (const GValue *value)
215{
216 if (value == NULL((void*)0))
217 return NULL((void*)0);
218
219 if (G_VALUE_HOLDS_STRING (value)(((__extension__ ({ const GValue *__val = (const GValue*) ((value
)); GType __t = (((GType) ((16) << (2)))); gboolean __r
; if (!__val) __r = (0); else if (__val->g_type == __t) __r
= (!(0)); else __r = g_type_check_value_holds (__val, __t); __r
; }))))
)
220 {
221 const char *s = g_value_get_string (value);
222
223 if (s == NULL((void*)0))
224 return g_strdup ("NULL")g_strdup_inline ("NULL");
225
226 return g_strescape (s, NULL((void*)0));
227 }
228 else
229 {
230 GType value_type = G_VALUE_TYPE (value)(((GValue*) (value))->g_type);
231
232 switch (G_TYPE_FUNDAMENTAL (value_type)(g_type_fundamental (value_type)))
233 {
234 case G_TYPE_BOXED((GType) ((18) << (2))):
235 if (g_value_get_boxed (value) == NULL((void*)0))
236 return NULL((void*)0);
237 else
238 return value_transform_to_string (value);
239 break;
This statement is never executed
240
241 case G_TYPE_OBJECT((GType) ((20) << (2))):
242 if (g_value_get_object (value) == NULL((void*)0))
243 return NULL((void*)0);
244 else
245 return value_transform_to_string (value);
246 break;
247
248 case G_TYPE_POINTER((GType) ((17) << (2))):
249 return NULL((void*)0);
250
251 default:
252 return value_transform_to_string (value);
253 }
254 }
255
256 return NULL((void*)0);
257}
258
259static void
260dump_properties (GType type, FILE *out)
261{
262 guint i;
263 guint n_properties = 0;
264 GParamSpec **props;
265
266 if (G_TYPE_FUNDAMENTAL (type)(g_type_fundamental (type)) == G_TYPE_OBJECT((GType) ((20) << (2))))
267 {
268 GObjectClass *klass;
269 klass = g_type_class_ref (type);
270 props = g_object_class_list_properties (klass, &n_properties);
271 }
272 else
273 {
274 void *klass;
275 klass = g_type_default_interface_ref (type);
276 props = g_object_interface_list_properties (klass, &n_properties);
277 }
278
279 for (i = 0; i < n_properties; i++)
280 {
281 GParamSpec *prop;
282
283 prop = props[i];
284 if (prop->owner_type != type)
285 continue;
286
287 const GValue *v = g_param_spec_get_default_value (prop);
288 char *default_value = value_to_string (v);
289
290 if (v != NULL((void*)0) && default_value != NULL((void*)0))
291 {
292 escaped_printf (out, " <property name=\"%s\" type=\"%s\" flags=\"%d\" default-value=\"%s\"/>\n",
293 prop->name,
294 g_type_name (prop->value_type),
295 prop->flags,
296 default_value);
297 }
298 else
299 {
300 escaped_printf (out, " <property name=\"%s\" type=\"%s\" flags=\"%d\"/>\n",
301 prop->name,
302 g_type_name (prop->value_type),
303 prop->flags);
304 }
305
306 g_free (default_value);
307 }
308
309 g_free (props);
310}
311
312static void
313dump_signals (GType type, FILE *out)
314{
315 guint i;
316 guint n_sigs;
317 guint *sig_ids;
318
319 sig_ids = g_signal_list_ids (type, &n_sigs);
320 for (i = 0; i < n_sigs; i++)
321 {
322 guint sigid;
323 GSignalQuery query;
324 guint j;
325
326 sigid = sig_ids[i];
327 g_signal_query (sigid, &query);
328
329 escaped_printf (out, " <signal name=\"%s\" return=\"%s\"",
330 query.signal_name, g_type_name (query.return_type));
331
332 if (query.signal_flags & G_SIGNAL_RUN_FIRST)
333 escaped_printf (out, " when=\"first\"");
334 else if (query.signal_flags & G_SIGNAL_RUN_LAST)
335 escaped_printf (out, " when=\"last\"");
336 else if (query.signal_flags & G_SIGNAL_RUN_CLEANUP)
337 escaped_printf (out, " when=\"cleanup\"");
338 else if (query.signal_flags & G_SIGNAL_MUST_COLLECT)
339 escaped_printf (out, " when=\"must-collect\"");
340 if (query.signal_flags & G_SIGNAL_NO_RECURSE)
341 escaped_printf (out, " no-recurse=\"1\"");
342
343 if (query.signal_flags & G_SIGNAL_DETAILED)
344 escaped_printf (out, " detailed=\"1\"");
345
346 if (query.signal_flags & G_SIGNAL_ACTION)
347 escaped_printf (out, " action=\"1\"");
348
349 if (query.signal_flags & G_SIGNAL_NO_HOOKS)
350 escaped_printf (out, " no-hooks=\"1\"");
351
352 goutput_write (out, ">\n");
353
354 for (j = 0; j < query.n_params; j++)
355 {
356 escaped_printf (out, " <param type=\"%s\"/>\n",
357 g_type_name (query.param_types[j]));
358 }
359 goutput_write (out, " </signal>\n");
360 }
361 g_free (sig_ids);
362}
363
364static void
365dump_object_type (GType type, const char *symbol, FILE *out)
366{
367 guint n_interfaces;
368 guint i;
369 GType *interfaces;
370
371 escaped_printf (out, " <class name=\"%s\" get-type=\"%s\"",
372 g_type_name (type), symbol);
373 if (type != G_TYPE_OBJECT((GType) ((20) << (2))))
374 {
375 GString *parent_str;
376 GType parent;
377 gboolean first = TRUE(!(0));
378
379 parent = g_type_parent (type);
380 parent_str = g_string_new ("");
381 while (parent != G_TYPE_INVALID((GType) ((0) << (2))))
382 {
383 if (first)
384 first = FALSE(0);
385 else
386 g_string_append_c (parent_str, ',')g_string_append_c_inline (parent_str, ',');
387 g_string_append (parent_str, g_type_name (parent))(__builtin_constant_p (g_type_name (parent)) ? __extension__ (
{ const char * const __val = (g_type_name (parent)); g_string_append_len_inline
(parent_str, __val, (__val != ((void*)0)) ? (gssize) strlen (
((__val) + !(__val))) : (gssize) -1); }) : g_string_append_len_inline
(parent_str, g_type_name (parent), (gssize) -1))
;
388 parent = g_type_parent (parent);
389 }
390
391 escaped_printf (out, " parents=\"%s\"", parent_str->str);
392
393 g_string_free (parent_str, TRUE)(__builtin_constant_p ((!(0))) ? (((!(0))) ? (g_string_free) (
(parent_str), ((!(0)))) : g_string_free_and_steal (parent_str
)) : (g_string_free) ((parent_str), ((!(0)))))
;
394 }
395
396 if (G_TYPE_IS_ABSTRACT (type)(g_type_test_flags ((type), G_TYPE_FLAG_ABSTRACT)))
397 escaped_printf (out, " abstract=\"1\"");
398
399 if (G_TYPE_IS_FINAL (type)(g_type_test_flags ((type), G_TYPE_FLAG_FINAL)))
400 escaped_printf (out, " final=\"1\"");
401
402 goutput_write (out, ">\n");
403
404 interfaces = g_type_interfaces (type, &n_interfaces);
405 for (i = 0; i < n_interfaces; i++)
406 {
407 GType itype = interfaces[i];
408 escaped_printf (out, " <implements name=\"%s\"/>\n",
409 g_type_name (itype));
410 }
411 g_free (interfaces);
412
413 dump_properties (type, out);
414 dump_signals (type, out);
415 goutput_write (out, " </class>\n");
416}
417
418static void
419dump_interface_type (GType type, const char *symbol, FILE *out)
420{
421 guint n_interfaces;
422 guint i;
423 GType *interfaces;
424
425 escaped_printf (out, " <interface name=\"%s\" get-type=\"%s\">\n",
426 g_type_name (type), symbol);
427
428 interfaces = g_type_interface_prerequisites (type, &n_interfaces);
429 for (i = 0; i < n_interfaces; i++)
430 {
431 GType itype = interfaces[i];
432 if (itype == G_TYPE_OBJECT((GType) ((20) << (2))))
433 {
434 /* Treat this as implicit for now; in theory GInterfaces are
435 * supported on things like GstMiniObject, but right now
436 * the introspection system only supports GObject.
437 * http://bugzilla.gnome.org/show_bug.cgi?id=559706
438 */
439 continue;
440 }
441 escaped_printf (out, " <prerequisite name=\"%s\"/>\n",
442 g_type_name (itype));
443 }
444 g_free (interfaces);
445
446 dump_properties (type, out);
447 dump_signals (type, out);
448 goutput_write (out, " </interface>\n");
449}
450
451static void
452dump_boxed_type (GType type, const char *symbol, FILE *out)
453{
454 escaped_printf (out, " <boxed name=\"%s\" get-type=\"%s\"/>\n",
455 g_type_name (type), symbol);
456}
457
458static void
459dump_flags_type (GType type, const char *symbol, FILE *out)
460{
461 guint i;
462 GFlagsClass *klass;
463
464 klass = g_type_class_ref (type);
465 escaped_printf (out, " <flags name=\"%s\" get-type=\"%s\">\n",
466 g_type_name (type), symbol);
467
468 for (i = 0; i < klass->n_values; i++)
469 {
470 GFlagsValue *value = &(klass->values[i]);
471
472 escaped_printf (out, " <member name=\"%s\" nick=\"%s\" value=\"%u\"/>\n",
473 value->value_name, value->value_nick, value->value);
474 }
475 goutput_write (out, " </flags>\n");
476}
477
478static void
479dump_enum_type (GType type, const char *symbol, FILE *out)
480{
481 guint i;
482 GEnumClass *klass;
483
484 klass = g_type_class_ref (type);
485 escaped_printf (out, " <enum name=\"%s\" get-type=\"%s\">\n",
486 g_type_name (type), symbol);
487
488 for (i = 0; i < klass->n_values; i++)
489 {
490 GEnumValue *value = &(klass->values[i]);
491
492 escaped_printf (out, " <member name=\"%s\" nick=\"%s\" value=\"%d\"/>\n",
493 value->value_name, value->value_nick, value->value);
494 }
495 goutput_write (out, " </enum>");
496}
497
498static void
499dump_fundamental_type (GType type, const char *symbol, FILE *out)
500{
501 guint n_interfaces;
502 guint i;
503 GType *interfaces;
504 GString *parent_str;
505 GType parent;
506 gboolean first = TRUE(!(0));
507
508
509 escaped_printf (out, " <fundamental name=\"%s\" get-type=\"%s\"",
510 g_type_name (type), symbol);
511
512 if (G_TYPE_IS_ABSTRACT (type)(g_type_test_flags ((type), G_TYPE_FLAG_ABSTRACT)))
513 escaped_printf (out, " abstract=\"1\"");
514
515 if (G_TYPE_IS_FINAL (type)(g_type_test_flags ((type), G_TYPE_FLAG_FINAL)))
516 escaped_printf (out, " final=\"1\"");
517
518 if (G_TYPE_IS_INSTANTIATABLE (type)(g_type_test_flags ((type), G_TYPE_FLAG_INSTANTIATABLE)))
519 escaped_printf (out, " instantiatable=\"1\"");
520
521 parent = g_type_parent (type);
522 parent_str = g_string_new ("");
523 while (parent != G_TYPE_INVALID((GType) ((0) << (2))))
524 {
525 if (first)
526 first = FALSE(0);
527 else
528 g_string_append_c (parent_str, ',')g_string_append_c_inline (parent_str, ',');
529 if (!g_type_name (parent))
530 break;
531 g_string_append (parent_str, g_type_name (parent))(__builtin_constant_p (g_type_name (parent)) ? __extension__ (
{ const char * const __val = (g_type_name (parent)); g_string_append_len_inline
(parent_str, __val, (__val != ((void*)0)) ? (gssize) strlen (
((__val) + !(__val))) : (gssize) -1); }) : g_string_append_len_inline
(parent_str, g_type_name (parent), (gssize) -1))
;
532 parent = g_type_parent (parent);
533 }
534
535 if (parent_str->len > 0)
536 escaped_printf (out, " parents=\"%s\"", parent_str->str);
537 g_string_free (parent_str, TRUE)(__builtin_constant_p ((!(0))) ? (((!(0))) ? (g_string_free) (
(parent_str), ((!(0)))) : g_string_free_and_steal (parent_str
)) : (g_string_free) ((parent_str), ((!(0)))))
;
538
539 goutput_write (out, ">\n");
540
541 interfaces = g_type_interfaces (type, &n_interfaces);
542 for (i = 0; i < n_interfaces; i++)
543 {
544 GType itype = interfaces[i];
545 escaped_printf (out, " <implements name=\"%s\"/>\n",
546 g_type_name (itype));
547 }
548 g_free (interfaces);
549 goutput_write (out, " </fundamental>\n");
550}
551
552static void
553dump_type (GType type, const char *symbol, FILE *out)
554{
555 /* XXX: We need to ensure that global ancillary structures like
556 * GParamSpecPool are initialized before we use the GType and
557 * GObject reflection API to poke at things like properties and
558 * signals; we cannot rely on GObject being instantiated at this
559 * point.
560 */
561 GObjectClass *gobject_class = g_type_class_ref (G_TYPE_OBJECT((GType) ((20) << (2))));
562
563 switch (g_type_fundamental (type))
564 {
565 case G_TYPE_OBJECT((GType) ((20) << (2))):
566 dump_object_type (type, symbol, out);
567 break;
568 case G_TYPE_INTERFACE((GType) ((2) << (2))):
569 dump_interface_type (type, symbol, out);
570 break;
571 case G_TYPE_BOXED((GType) ((18) << (2))):
572 dump_boxed_type (type, symbol, out);
573 break;
574 case G_TYPE_FLAGS((GType) ((13) << (2))):
575 dump_flags_type (type, symbol, out);
576 break;
577 case G_TYPE_ENUM((GType) ((12) << (2))):
578 dump_enum_type (type, symbol, out);
579 break;
580 case G_TYPE_POINTER((GType) ((17) << (2))):
581 /* GValue, etc. Just skip them. */
582 break;
583 default:
584 dump_fundamental_type (type, symbol, out);
585 break;
586 }
587
588 g_type_class_unref ((GTypeClass *) gobject_class);
589}
590
591static void
592dump_error_quark (GQuark quark, const char *symbol, FILE *out)
593{
594 escaped_printf (out, " <error-quark function=\"%s\" domain=\"%s\"/>\n",
595 symbol, g_quark_to_string (quark));
596}
597
598/**
599 * g_irepository_dump:
600 * @input_filename: (type filename): Input filename (for example `input.txt`)
601 * @output_filename: (type filename): Output filename (for example `output.xml`)
602 * @error: a %GError
603 *
604 * Dump the introspection data from the types specified in @input_filename to
605 * @output_filename.
606 *
607 * The input file should be a
608 * UTF-8 Unix-line-ending text file, with each line containing either
609 * `get-type:` followed by the name of a [type@GObject.Type] `_get_type`
610 * function, or `error-quark:` followed by the name of an error quark function.
611 * No extra whitespace is allowed.
612 *
613 * This function will overwrite the contents of the output file.
614 *
615 * Returns: true on success, false on error
616 * Since: 2.80
617 */
618#ifndef G_IREPOSITORY_COMPILATION
619static gboolean
620dump_irepository (const char *arg,
621 GError **error) G_GNUC_UNUSED__attribute__ ((__unused__));
622static gboolean
623dump_irepository (const char *arg,
624 GError **error)
625#else
626gboolean
627g_irepository_dump (const char *arg,
628 GError **error)
629#endif
630{
631 GHashTable *output_types;
632 FILE *input;
633 FILE *output;
634 GModule *self;
635 gboolean caught_error = FALSE(0);
636
637 char **args = g_strsplit (arg, ",", 2);
638 if (args == NULL((void*)0))
639 return FALSE(0);
640
641 const char *input_filename = args[0];
642 const char *output_filename = args[1];
643
644 self = g_module_open (NULL((void*)0), 0);
645 if (!self)
646 {
647 g_set_error (error,
648 G_FILE_ERRORg_file_error_quark (),
649 G_FILE_ERROR_FAILED,
650 "failed to open self: %s",
651 g_module_error ());
652 g_strfreev (args);
653 return FALSE(0);
654 }
655
656 input = fopen (input_filename, "rb");
657 if (input == NULL((void*)0))
658 {
659 int saved_errno = errno(*__errno_location ());
660 g_set_error (error, G_FILE_ERRORg_file_error_quark (), g_file_error_from_errno (saved_errno),
661 "Failed to open ‘%s’: %s", input_filename, g_strerror (saved_errno));
662
663 g_module_close (self);
664 g_strfreev (args);
665
666 return FALSE(0);
667 }
668
669 output = fopen (output_filename, "wb");
670 if (output == NULL((void*)0))
671 {
672 int saved_errno = errno(*__errno_location ());
673 g_set_error (error, G_FILE_ERRORg_file_error_quark (), g_file_error_from_errno (saved_errno),
674 "Failed to open ‘%s’: %s", output_filename, g_strerror (saved_errno));
675
676 fclose (input);
677 g_module_close (self);
678 g_strfreev (args);
679
680 return FALSE(0);
681 }
682
683 goutput_write (output, "<?xml version=\"1.0\"?>\n");
684 goutput_write (output, "<dump>\n");
685
686 output_types = g_hash_table_new (NULL((void*)0), NULL((void*)0));
687
688 while (TRUE(!(0)))
689 {
690 gsize len;
691 char *line = read_line (input, &len);
692 const char *function;
693
694 if (line == NULL((void*)0) || *line == '\0')
695 {
696 g_free (line);
697 break;
698 }
699
700 g_strchomp (line);
701
702 if (strncmp (line, "get-type:", strlen ("get-type:")) == 0)
703 {
704 GType type;
705
706 function = line + strlen ("get-type:");
707
708 type = invoke_get_type (self, function, error);
709
710 if (type == G_TYPE_INVALID((GType) ((0) << (2))))
711 {
712 g_printerr ("Invalid GType function: '%s'\n", function);
713 caught_error = TRUE(!(0));
714 g_free (line);
715 break;
716 }
717
718 if (g_hash_table_lookup (output_types, (gpointer) type))
719 goto next;
720 g_hash_table_insert (output_types, (gpointer) type, (gpointer) type);
721
722 dump_type (type, function, output);
723 }
724 else if (strncmp (line, "error-quark:", strlen ("error-quark:")) == 0)
725 {
726 GQuark quark;
727 function = line + strlen ("error-quark:");
728 quark = invoke_error_quark (self, function, error);
729
730 if (quark == 0)
731 {
732 g_printerr ("Invalid error quark function: '%s'\n", function);
733 caught_error = TRUE(!(0));
734 g_free (line);
735 break;
736 }
737
738 dump_error_quark (quark, function, output);
739 }
740
741
742 next:
743 g_free (line);
744 }
745
746 g_hash_table_destroy (output_types);
747
748 goutput_write (output, "</dump>\n");
749
750 {
751 /* Avoid overwriting an earlier set error */
752 if (fclose (input) != 0 && !caught_error)
753 {
754 int saved_errno = errno(*__errno_location ());
755
756 g_set_error (error, G_FILE_ERRORg_file_error_quark (), g_file_error_from_errno (saved_errno),
757 "Error closing input file ‘%s’: %s", input_filename,
758 g_strerror (saved_errno));
759 caught_error = TRUE(!(0));
760 }
761
762 if (fclose (output) != 0 && !caught_error)
763 {
764 int saved_errno = errno(*__errno_location ());
765
766 g_set_error (error, G_FILE_ERRORg_file_error_quark (), g_file_error_from_errno (saved_errno),
767 "Error closing output file ‘%s’: %s", output_filename,
768 g_strerror (saved_errno));
769 caught_error = TRUE(!(0));
770 }
771 }
772
773 g_strfreev (args);
774
775 return !caught_error;
776}
777
778
779int
780main(int argc, char **argv)
781{
782 GError *error = NULL((void*)0);
783 const char *introspect_dump_prefix = "--introspect-dump=";
784
785#if !GLIB_CHECK_VERSION(2,35,0)(2 > (2) || (2 == (2) && 80 > (35)) || (2 == (2
) && 80 == (35) && 2 >= (0)))
786 g_type_init ();
787#endif
788
789
790
791 if (argc != 2 || !g_str_has_prefix (argv[1], introspect_dump_prefix)(__builtin_constant_p (introspect_dump_prefix)? __extension__
({ const char * const __str = (argv[1]); const char * const __prefix
= (introspect_dump_prefix); gboolean __result = (0); if (__str
== ((void*)0) || __prefix == ((void*)0)) __result = (g_str_has_prefix
) (__str, __prefix); else { const size_t __str_len = strlen (
((__str) + !(__str))); const size_t __prefix_len = strlen (((
__prefix) + !(__prefix))); if (__str_len >= __prefix_len) __result
= memcmp (((__str) + !(__str)), ((__prefix) + !(__prefix)), __prefix_len
) == 0; } __result; }) : (g_str_has_prefix) (argv[1], introspect_dump_prefix
) )
)
792 {
793 g_printerr ("Usage: %s --introspect-dump=input,output", argv[0]);
794 exit (1);
795 }
796
797 if (!dump_irepository (argv[1] + strlen(introspect_dump_prefix), &error))
798 {
799 g_printerr ("%s\n", error->message);
800 exit (1);
801 }
802 exit (0);
803}
804extern GType mate_panel_applet_get_type(void);
805extern GType mate_panel_applet_orient_get_type(void);
806extern GType mate_panel_applet_background_type_get_type(void);
807extern GType mate_panel_applet_flags_get_type(void);
808G_MODULE_EXPORT__attribute__((visibility("default"))) GType (*GI_GET_TYPE_FUNCS_[])(void) = {
809 mate_panel_applet_get_type,
810 mate_panel_applet_orient_get_type,
811 mate_panel_applet_background_type_get_type,
812 mate_panel_applet_flags_get_type
813};
diff --git a/2024-06-18-172109-13286-1@e182420b844f_master/report-fd4917.html b/2024-06-18-172109-13286-1@e182420b844f_master/report-fd4917.html new file mode 100644 index 00000000..abb376e6 --- /dev/null +++ b/2024-06-18-172109-13286-1@e182420b844f_master/report-fd4917.html @@ -0,0 +1,6243 @@ + + + +panel-toplevel.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:mate-panel/panel-toplevel.c
Warning:line 2063, column 2
Value stored to 'y' is never read
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name panel-toplevel.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/mate-panel -fcoverage-compilation-dir=/rootdir/mate-panel -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I .. -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/startup-notification-1.0 -I /usr/include/mate-menus -I /usr/include/gio-unix-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/dconf -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/dconf -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I . -I . -I ../mate-panel -I ../mate-panel/mate-submodules -I ../mate-panel/libpanel-util -D MATELOCALEDIR="/usr/local/share/locale" -D PANELDATADIR="/usr/local/share/mate-panel" -I /usr/include/gtk-layer-shell -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/gtk-3.0 -I /usr/include/cloudproviders -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/atk-1.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/gio-unix-2.0 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -D PANEL_MODULES_DIR="/usr/local/lib/mate-panel/modules" -D MATEMENU_I_KNOW_THIS_IS_UNSTABLE -I /usr/include/gtk-layer-shell -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/gtk-3.0 -I /usr/include/cloudproviders -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/atk-1.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/gio-unix-2.0 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-18-172109-13286-1 -x c panel-toplevel.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
2 *
3 * panel-toplevel.c: The panel's toplevel window object.
4 *
5 * Copyright (C) 2003 Sun Microsystems, Inc.
6 * Copyright (C) 2004 Rob Adams
7 * Copyright (C) 2012-2021 MATE Developers
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of the
12 * License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
22 * 02110-1301, USA.
23 *
24 * Authors:
25 * Mark McLoughlin <mark@skynet.ie>
26 */
27
28#include <config.h>
29
30#include "panel-toplevel.h"
31
32#include <stdlib.h>
33#include <string.h>
34
35#include <gtk/gtk.h>
36#include <gdk/gdkkeysyms.h>
37#include <glib/gi18n.h>
38
39#ifdef HAVE_X111
40#include <gdk/gdkx.h>
41#endif
42
43#include "panel-util.h"
44#include "panel-profile.h"
45#include "panel-frame.h"
46#include "panel-multimonitor.h"
47#include "panel-a11y.h"
48#include "panel-typebuiltins.h"
49#include "panel-marshal.h"
50#include "panel-widget.h"
51#include "panel-bindings.h"
52#include "panel-config-global.h"
53#include "panel-lockdown.h"
54#include "panel-schemas.h"
55
56#ifdef HAVE_X111
57#include "xstuff.h"
58#include "panel-xutils.h"
59#include "panel-struts.h"
60#endif
61#ifdef HAVE_WAYLAND1
62#include "wayland-backend.h"
63#endif
64
65#define DEFAULT_SIZE48 48
66#define DEFAULT_AUTO_HIDE_SIZE1 1
67#define DEFAULT_HIDE_DELAY300 300
68#define DEFAULT_UNHIDE_DELAY100 100
69#define DEFAULT_DND_THRESHOLD8 8
70#define MINIMUM_WIDTH100 100
71#define MAXIMUM_SIZE_SCREEN_RATIO5 5
72#define SNAP_TOLERANCE_FACTOR6 6
73#define DEFAULT_ARROW_SIZE20 20
74#define HANDLE_SIZE10 10
75#define N_ATTACH_TOPLEVEL_SIGNALS5 5
76#define N_ATTACH_WIDGET_SIGNALS5 5
77
78typedef enum {
79 PANEL_GRAB_OP_NONE,
80 PANEL_GRAB_OP_MOVE,
81 PANEL_GRAB_OP_RESIZE,
82 PANEL_GRAB_OP_RESIZE_UP,
83 PANEL_GRAB_OP_RESIZE_DOWN,
84 PANEL_GRAB_OP_RESIZE_LEFT,
85 PANEL_GRAB_OP_RESIZE_RIGHT
86} PanelGrabOpType;
87
88struct _PanelToplevelPrivate {
89 gchar *settings_path;
90
91 gboolean expand;
92 PanelOrientation orientation;
93 int size;
94 gint scale;
95
96 /* relative to the monitor origin */
97 int x;
98 int y;
99 /* relative to the bottom right corner, -1 to ignore and use x, y*/
100 int x_right;
101 int y_bottom;
102
103 int monitor;
104 /* this is used when the configured monitor is missing. We keep it so
105 * we can move the toplevel to the right monitor when it becomes
106 * available */
107 int configured_monitor;
108
109 int hide_delay;
110 int unhide_delay;
111 int auto_hide_size;
112 PanelAnimationSpeed animation_speed;
113
114 int snap_tolerance;
115 GtkSettings *gtk_settings;
116
117 PanelState state;
118
119 char *name;
120 char *description;
121
122 guint hide_timeout;
123 guint unhide_timeout;
124
125 GdkRectangle geometry;
126 PanelFrameEdge edges;
127
128 int original_width;
129 int original_height;
130
131 PanelGrabOpType grab_op;
132
133 /* The offset within the panel from which the panel
134 * drag was initiated relative to the screen origin.
135 */
136 int drag_offset_x;
137 int drag_offset_y;
138
139 /* Saved state before for cancelled grab op */
140 int orig_monitor;
141 int orig_x;
142 int orig_y;
143 int orig_x_right;
144 int orig_y_bottom;
145 int orig_size;
146 int orig_orientation;
147
148 /* relative to the monitor origin */
149 int animation_end_x;
150 int animation_end_y;
151 int animation_end_width;
152 int animation_end_height;
153 gint64 animation_start_time; /* monotonic start time in microseconds */
154 GTimeSpan animation_duration_time; /* monotonic duration time in microseconds */
155 guint animation_timeout;
156
157 PanelWidget *panel_widget;
158 PanelFrame *inner_frame;
159 GtkWidget *grid;
160 GtkWidget *hide_button_top;
161 GtkWidget *hide_button_bottom;
162 GtkWidget *hide_button_left;
163 GtkWidget *hide_button_right;
164
165 PanelToplevel *attach_toplevel;
166 gulong attach_toplevel_signals [N_ATTACH_TOPLEVEL_SIGNALS5];
167 GtkWidget *attach_widget;
168 gulong attach_widget_signals [N_ATTACH_WIDGET_SIGNALS5];
169 gint n_autohide_disablers;
170
171 guint auto_hide : 1;
172 guint animate : 1;
173 guint buttons_enabled : 1;
174 guint arrows_enabled : 1;
175
176 /* The co-ordinates are relative to center screen */
177 guint x_centered : 1;
178 guint y_centered : 1;
179
180 /* The panel is not lined up with th screen edge */
181 guint floating : 1;
182
183 /* We are currently animating a hide/show */
184 guint animating : 1;
185
186 /* This is a keyboard initiated grab operation */
187 guint grab_is_keyboard : 1;
188
189 /* The x-y co-ordinates temporarily specify the panel center.
190 * This is used when the panel is rotating, because the width/height
191 * of the toplevel might change, so we need to compute new values for
192 * those. */
193 guint position_centered : 1;
194
195 /* The toplevel is "attached" to another widget */
196 guint attached : 1;
197
198 /* Hidden temporarily because the attach_toplevel was hidden */
199 guint attach_hidden : 1;
200
201 /* More saved grab op state */
202 guint orig_x_centered : 1;
203 guint orig_y_centered : 1;
204
205 /* flag to see if we have already done geometry updating,
206 if not then we're still loading and can ignore many things */
207 guint updated_geometry_initial : 1;
208 /* flag to see if we have done the initial animation */
209 guint initial_animation_done : 1;
210};
211
212enum {
213 HIDE_SIGNAL,
214 UNHIDE_SIGNAL,
215 POPUP_PANEL_MENU_SIGNAL,
216 TOGGLE_EXPAND_SIGNAL,
217 EXPAND_SIGNAL,
218 UNEXPAND_SIGNAL,
219 TOGGLE_HIDDEN_SIGNAL,
220 BEGIN_MOVE_SIGNAL,
221 BEGIN_RESIZE_SIGNAL,
222 LAST_SIGNAL
223};
224
225enum {
226 PROP_0,
227 PROP_NAME,
228 PROP_SETTINGS_PATH,
229 PROP_EXPAND,
230 PROP_ORIENTATION,
231 PROP_SIZE,
232 PROP_X,
233 PROP_X_RIGHT,
234 PROP_X_CENTERED,
235 PROP_Y,
236 PROP_Y_BOTTOM,
237 PROP_Y_CENTERED,
238 PROP_MONITOR,
239 PROP_AUTOHIDE,
240 PROP_HIDE_DELAY,
241 PROP_UNHIDE_DELAY,
242 PROP_AUTOHIDE_SIZE,
243 PROP_ANIMATE,
244 PROP_ANIMATION_SPEED,
245 PROP_BUTTONS_ENABLED,
246 PROP_ARROWS_ENABLED
247};
248
249G_DEFINE_TYPE_WITH_PRIVATE (PanelToplevel, panel_toplevel, GTK_TYPE_WINDOW)static void panel_toplevel_init (PanelToplevel *self); static
void panel_toplevel_class_init (PanelToplevelClass *klass); static
GType panel_toplevel_get_type_once (void); static gpointer panel_toplevel_parent_class
= ((void*)0); static gint PanelToplevel_private_offset; static
void panel_toplevel_class_intern_init (gpointer klass) { panel_toplevel_parent_class
= g_type_class_peek_parent (klass); if (PanelToplevel_private_offset
!= 0) g_type_class_adjust_private_offset (klass, &PanelToplevel_private_offset
); panel_toplevel_class_init ((PanelToplevelClass*) klass); }
__attribute__ ((__unused__)) static inline gpointer panel_toplevel_get_instance_private
(PanelToplevel *self) { return (((gpointer) ((guint8*) (self
) + (glong) (PanelToplevel_private_offset)))); } GType panel_toplevel_get_type
(void) { static GType static_g_define_type_id = 0; if ((__extension__
({ _Static_assert (sizeof *(&static_g_define_type_id) ==
sizeof (gpointer), "Expression evaluates to false"); (void) (
0 ? (gpointer) * (&static_g_define_type_id) : ((void*)0))
; (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter_pointer (
&static_g_define_type_id)); })) ) { GType g_define_type_id
= panel_toplevel_get_type_once (); (__extension__ ({ _Static_assert
(sizeof *(&static_g_define_type_id) == sizeof (gpointer)
, "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id
) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer
((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id
)); })) ; } return static_g_define_type_id; } __attribute__ (
(__noinline__)) static GType panel_toplevel_get_type_once (void
) { GType g_define_type_id = g_type_register_static_simple ((
gtk_window_get_type ()), g_intern_static_string ("PanelToplevel"
), sizeof (PanelToplevelClass), (GClassInitFunc)(void (*)(void
)) panel_toplevel_class_intern_init, sizeof (PanelToplevel), (
GInstanceInitFunc)(void (*)(void)) panel_toplevel_init, (GTypeFlags
) 0); { {{ PanelToplevel_private_offset = g_type_add_instance_private
(g_define_type_id, sizeof (PanelToplevelPrivate)); };} } return
g_define_type_id; }
250
251static guint toplevel_signals[LAST_SIGNAL] = {0};
252static GSList* toplevel_list = NULL((void*)0);
253
254static void panel_toplevel_calculate_animation_end_geometry(PanelToplevel *toplevel);
255
256static void panel_toplevel_update_monitor(PanelToplevel* toplevel);
257static void panel_toplevel_set_monitor_internal(PanelToplevel* toplevel, int monitor, gboolean force_resize);
258
259static void panel_toplevel_drag_threshold_changed (PanelToplevel *toplevel);
260
261static void
262update_style_classes (PanelToplevel *toplevel)
263{
264 GtkStyleContext *context;
265
266 context = gtk_widget_get_style_context (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
267
268 /*ensure the panel BG can always be themed*/
269 /*Without this gtk3.19/20 cannot set the BG color and resetting the bg to system is not immediately applied*/
270 gtk_style_context_add_class(context,"gnome-panel-menu-bar");
271 gtk_style_context_add_class(context,"mate-panel-menu-bar");
272
273 gtk_style_context_remove_class (context, GTK_STYLE_CLASS_HORIZONTAL"horizontal");
274 gtk_style_context_remove_class (context, GTK_STYLE_CLASS_VERTICAL"vertical");
275 gtk_style_context_remove_class (context, GTK_STYLE_CLASS_RIGHT"right");
276 gtk_style_context_remove_class (context, GTK_STYLE_CLASS_LEFT"left");
277 gtk_style_context_remove_class (context, GTK_STYLE_CLASS_TOP"top");
278 gtk_style_context_remove_class (context, GTK_STYLE_CLASS_BOTTOM"bottom");
279
280 switch (toplevel->priv->orientation) {
281 case PANEL_ORIENTATION_TOP:
282 gtk_style_context_add_class (context, GTK_STYLE_CLASS_HORIZONTAL"horizontal");
283 gtk_style_context_add_class (context, GTK_STYLE_CLASS_TOP"top");
284 break;
285
286 case PANEL_ORIENTATION_LEFT:
287 gtk_style_context_add_class (context, GTK_STYLE_CLASS_VERTICAL"vertical");
288 gtk_style_context_add_class (context, GTK_STYLE_CLASS_LEFT"left");
289 break;
290
291 case PANEL_ORIENTATION_BOTTOM:
292 gtk_style_context_add_class (context, GTK_STYLE_CLASS_HORIZONTAL"horizontal");
293 gtk_style_context_add_class (context, GTK_STYLE_CLASS_BOTTOM"bottom");
294 break;
295
296 case PANEL_ORIENTATION_RIGHT:
297 gtk_style_context_add_class (context, GTK_STYLE_CLASS_VERTICAL"vertical");
298 gtk_style_context_add_class (context, GTK_STYLE_CLASS_RIGHT"right");
299 break;
300
301 default:
302 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 302, ((const char*) (__func__)), ((void*)0)); } while (0)
;
303 break;
304 }
305}
306
307GSList* panel_toplevel_list_toplevels(void)
308{
309 return toplevel_list;
310}
311
312/* Is this the last un-attached toplevel? */
313gboolean panel_toplevel_is_last_unattached(PanelToplevel* toplevel)
314{
315 GSList* l;
316
317 if (panel_toplevel_get_is_attached(toplevel))
318 {
319 return FALSE(0);
320 }
321
322 for (l = toplevel_list; l; l = l->next)
323 {
324 PanelToplevel* t = l->data;
325
326 if (t != toplevel && !panel_toplevel_get_is_attached(t))
327 {
328 return FALSE(0);
329 }
330 }
331
332 return TRUE(!(0));
333}
334
335static void panel_toplevel_get_monitor_geometry(PanelToplevel* toplevel, GdkRectangle *geom)
336{
337 g_return_if_fail(PANEL_IS_TOPLEVEL(toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL(toplevel)"); return; } } while
(0)
;
338 g_return_if_fail(geom)do { if ((geom)) { } else { g_return_if_fail_warning (((gchar
*) 0), ((const char*) (__func__)), "geom"); return; } } while
(0)
;
339
340 geom->x = panel_multimonitor_x(toplevel->priv->monitor);
341 geom->y = panel_multimonitor_y(toplevel->priv->monitor);
342 geom->width = panel_multimonitor_width(toplevel->priv->monitor);
343 geom->height = panel_multimonitor_height(toplevel->priv->monitor);
344}
345
346static GdkCursorType panel_toplevel_grab_op_cursor(PanelToplevel* toplevel, PanelGrabOpType grab_op)
347{
348 GdkCursorType retval = -1;
349
350 switch (grab_op) {
351 case PANEL_GRAB_OP_MOVE:
352 case PANEL_GRAB_OP_RESIZE:
353 if (toplevel->priv->grab_is_keyboard)
354 retval = GDK_CROSS;
355 else
356 retval = GDK_FLEUR;
357 break;
358 case PANEL_GRAB_OP_RESIZE_UP:
359 retval = GDK_TOP_SIDE;
360 break;
361 case PANEL_GRAB_OP_RESIZE_DOWN:
362 retval = GDK_BOTTOM_SIDE;
363 break;
364 case PANEL_GRAB_OP_RESIZE_LEFT:
365 retval = GDK_LEFT_SIDE;
366 break;
367 case PANEL_GRAB_OP_RESIZE_RIGHT:
368 retval = GDK_RIGHT_SIDE;
369 break;
370 default:
371 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 371, ((const char*) (__func__)), ((void*)0)); } while (0)
;
372 break;
373 }
374
375 return retval;
376}
377
378#ifdef HAVE_X111
379static void panel_toplevel_init_resize_drag_offsets(PanelToplevel* toplevel, PanelGrabOpType grab_op)
380{
381 g_assert (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel))))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((gtk_widget_get_display (((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((toplevel)), ((gtk_widget_get_type ()))))
))))); GType __t = ((gdk_x11_display_get_type())); gboolean __r
; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))) ; else
g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c", 381
, ((const char*) (__func__)), "GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel)))"
); } while (0)
;
382
383 toplevel->priv->drag_offset_x = 0;
384 toplevel->priv->drag_offset_y = 0;
385
386 switch (grab_op) {
387 case PANEL_GRAB_OP_RESIZE_DOWN:
388 toplevel->priv->drag_offset_y = toplevel->priv->geometry.y;
389 break;
390 case PANEL_GRAB_OP_RESIZE_UP:
391 toplevel->priv->drag_offset_y =
392 toplevel->priv->geometry.y + toplevel->priv->geometry.height;
393 break;
394 case PANEL_GRAB_OP_RESIZE_RIGHT:
395 toplevel->priv->drag_offset_x = toplevel->priv->geometry.x;
396 break;
397 case PANEL_GRAB_OP_RESIZE_LEFT:
398 toplevel->priv->drag_offset_x =
399 toplevel->priv->geometry.x + toplevel->priv->geometry.width;
400 break;
401 default:
402 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 402, ((const char*) (__func__)), ((void*)0)); } while (0)
;
403 break;
404 }
405}
406
407static void panel_toplevel_warp_pointer(PanelToplevel* toplevel)
408{
409 GtkWidget *widget;
410 GdkRectangle geometry;
411 int x, y;
412
413 widget = GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
;
414 g_return_if_fail (GDK_IS_X11_DISPLAY (gtk_widget_get_display (widget)))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((gtk_widget_get_display (widget))); GType __t = ((gdk_x11_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0
), ((const char*) (__func__)), "GDK_IS_X11_DISPLAY (gtk_widget_get_display (widget))"
); return; } } while (0)
;
415
416 geometry = toplevel->priv->geometry;
417
418 x = y = 0;
419
420 switch (toplevel->priv->grab_op) {
421 case PANEL_GRAB_OP_MOVE:
422 case PANEL_GRAB_OP_RESIZE:
423 x = (geometry.width / 2);
424 y = (geometry.height / 2);
425 break;
426 case PANEL_GRAB_OP_RESIZE_UP:
427 x = (geometry.width / 2);
428 break;
429 case PANEL_GRAB_OP_RESIZE_DOWN:
430 x = (geometry.width / 2);
431 y = geometry.height;
432 break;
433 case PANEL_GRAB_OP_RESIZE_LEFT:
434 y = (geometry.height / 2);
435 break;
436 case PANEL_GRAB_OP_RESIZE_RIGHT:
437 x = geometry.width;
438 y = (geometry.height / 2);
439 break;
440 default:
441 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 441, ((const char*) (__func__)), ((void*)0)); } while (0)
;
442 break;
443 }
444
445 if (toplevel->priv->grab_op == PANEL_GRAB_OP_MOVE ||
446 toplevel->priv->grab_op == PANEL_GRAB_OP_RESIZE) {
447 toplevel->priv->drag_offset_x = x;
448 toplevel->priv->drag_offset_y = y;
449 } else
450 panel_toplevel_init_resize_drag_offsets (toplevel, toplevel->priv->grab_op);
451
452 panel_warp_pointer (gtk_widget_get_window (widget), x, y);
453}
454#endif /* HAVE_X11 */
455
456static void panel_toplevel_begin_attached_move(PanelToplevel* toplevel, gboolean is_keyboard, guint32 time_)
457{
458 PanelWidget *attached_panel_widget;
459
460 attached_panel_widget = panel_toplevel_get_panel_widget (toplevel->priv->attach_toplevel);
461
462 panel_widget_applet_drag_start (attached_panel_widget,
463 toplevel->priv->attach_widget,
464 is_keyboard ? PW_DRAG_OFF_CENTER-2 : PW_DRAG_OFF_CURSOR-1,
465 time_);
466}
467
468static void panel_toplevel_begin_grab_op(PanelToplevel* toplevel, PanelGrabOpType op_type, gboolean grab_keyboard, guint32 time_)
469{
470 GtkWidget *widget;
471 GdkWindow *window;
472 GdkCursorType cursor_type;
473 GdkCursor *cursor;
474 GdkDisplay *display;
475 GdkSeat *seat;
476 GdkSeatCapabilities capabilities;
477
478 if (toplevel->priv->state != PANEL_STATE_NORMAL ||
479 toplevel->priv->grab_op != PANEL_GRAB_OP_NONE)
480 return;
481
482 if (panel_lockdown_get_locked_down ())
483 return;
484
485 /* If any of the position/orientation are not writable,
486 then we can't really move freely */
487 if (op_type == PANEL_GRAB_OP_MOVE &&
488 ! panel_profile_can_be_moved_freely (toplevel))
489 return;
490
491 /* If size is not writable, then we can't resize */
492 if ((op_type == PANEL_GRAB_OP_RESIZE ||
493 op_type == PANEL_GRAB_OP_RESIZE_UP ||
494 op_type == PANEL_GRAB_OP_RESIZE_DOWN ||
495 op_type == PANEL_GRAB_OP_RESIZE_LEFT ||
496 op_type == PANEL_GRAB_OP_RESIZE_RIGHT) &&
497 ! panel_profile_key_is_writable (toplevel, PANEL_TOPLEVEL_SIZE_KEY"size"))
498 return;
499
500 if (toplevel->priv->attached && op_type == PANEL_GRAB_OP_MOVE) {
501 panel_toplevel_begin_attached_move (toplevel, grab_keyboard, time_);
502 return;
503 }
504
505 widget = GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
;
506 window = gtk_widget_get_window (widget);
507
508 toplevel->priv->grab_op = op_type;
509 toplevel->priv->grab_is_keyboard = (grab_keyboard != FALSE(0));
510
511 toplevel->priv->orig_monitor = toplevel->priv->monitor;
512 toplevel->priv->orig_x = toplevel->priv->x;
513 toplevel->priv->orig_x_right = toplevel->priv->x_right;
514 toplevel->priv->orig_x_centered = toplevel->priv->x_centered;
515 toplevel->priv->orig_y = toplevel->priv->y;
516 toplevel->priv->orig_y_bottom = toplevel->priv->y_bottom;
517 toplevel->priv->orig_y_centered = toplevel->priv->y_centered;
518 toplevel->priv->orig_size = toplevel->priv->size;
519 toplevel->priv->orig_orientation = toplevel->priv->orientation;
520
521 gtk_grab_add (widget);
522
523#ifdef HAVE_X111
524 if (GDK_IS_X11_DISPLAY (gtk_widget_get_display (widget))(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gtk_widget_get_display (widget))); GType __t = ((gdk_x11_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
&&
525 toplevel->priv->grab_is_keyboard) {
526 panel_toplevel_warp_pointer (toplevel);
527 }
528#endif /* HAVE_X11 */
529
530 cursor_type = panel_toplevel_grab_op_cursor (
531 toplevel, toplevel->priv->grab_op);
532
533 cursor = gdk_cursor_new_for_display (gdk_display_get_default (),
534 cursor_type);
535 display = gdk_window_get_display (window);
536 seat = gdk_display_get_default_seat (display);
537 capabilities = GDK_SEAT_CAPABILITY_POINTER;
538 if (grab_keyboard)
539 capabilities |= GDK_SEAT_CAPABILITY_KEYBOARD;
540
541 gdk_seat_grab (seat, window, capabilities, FALSE(0), cursor,
542 NULL((void*)0), NULL((void*)0), NULL((void*)0));
543
544 g_object_unref (cursor);
545}
546
547static void panel_toplevel_end_grab_op (PanelToplevel* toplevel, guint32 time_)
548{
549 GtkWidget *widget;
550 GdkDisplay *display;
551 GdkSeat *seat;
552
553 g_return_if_fail (toplevel->priv->grab_op != PANEL_GRAB_OP_NONE)do { if ((toplevel->priv->grab_op != PANEL_GRAB_OP_NONE
)) { } else { g_return_if_fail_warning (((gchar*) 0), ((const
char*) (__func__)), "toplevel->priv->grab_op != PANEL_GRAB_OP_NONE"
); return; } } while (0)
;
554
555 widget = GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
;
556
557 toplevel->priv->grab_op = PANEL_GRAB_OP_NONE;
558 toplevel->priv->grab_is_keyboard = FALSE(0);
559
560 gtk_grab_remove (widget);
561
562 display = gtk_widget_get_display (widget);
563 seat = gdk_display_get_default_seat (display);
564
565 gdk_seat_ungrab (seat);
566}
567
568static void panel_toplevel_cancel_grab_op(PanelToplevel* toplevel, guint32 time_)
569{
570 panel_toplevel_set_orientation (toplevel, toplevel->priv->orig_orientation);
571 panel_toplevel_set_monitor (toplevel, toplevel->priv->orig_monitor);
572 panel_toplevel_set_size (toplevel, toplevel->priv->orig_size);
573 panel_toplevel_set_x (toplevel,
574 toplevel->priv->orig_x,
575 toplevel->priv->orig_x_right,
576 toplevel->priv->orig_x_centered);
577 panel_toplevel_set_y (toplevel,
578 toplevel->priv->orig_y,
579 toplevel->priv->orig_y_bottom,
580 toplevel->priv->orig_y_centered);
581}
582
583static void panel_toplevel_resize_to_pointer(PanelToplevel* toplevel, int x, int y)
584{
585 int new_size;
586 int new_x, new_y;
587 int new_x_right, new_y_bottom;
588 int new_x_centered, new_y_centered;
589 GdkRectangle monitor_geom;
590
591 new_size = toplevel->priv->size;
592 new_x = toplevel->priv->x;
593 new_y = toplevel->priv->y;
594 new_x_right = toplevel->priv->x_right;
595 new_y_bottom = toplevel->priv->y_bottom;
596 new_x_centered = toplevel->priv->x_centered;
597 new_y_centered = toplevel->priv->y_centered;
598
599 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
600
601 switch (toplevel->priv->grab_op) {
602 case PANEL_GRAB_OP_RESIZE_UP:
603 new_size = toplevel->priv->drag_offset_y - y;
604 new_size = CLAMP (new_size, 0, monitor_geom.height / 4)(((new_size) > (monitor_geom.height / 4)) ? (monitor_geom.
height / 4) : (((new_size) < (0)) ? (0) : (new_size)))
;
605 new_y -= (new_size - toplevel->priv->size);
606 if (!toplevel->priv->y_centered && (new_y + new_size / 2) > monitor_geom.height / 2)
607 new_y_bottom = monitor_geom.height - (new_y + new_size);
608 else
609 new_y_bottom = -1;
610 break;
611 case PANEL_GRAB_OP_RESIZE_DOWN:
612 new_size = y - toplevel->priv->drag_offset_y;
613 new_size = CLAMP (new_size, 0, monitor_geom.height / 4)(((new_size) > (monitor_geom.height / 4)) ? (monitor_geom.
height / 4) : (((new_size) < (0)) ? (0) : (new_size)))
;
614 if (!toplevel->priv->y_centered && (new_y + new_size / 2) > monitor_geom.height / 2)
615 new_y_bottom = monitor_geom.height - (new_y + new_size);
616 else
617 new_y_bottom = -1;
618 break;
619 case PANEL_GRAB_OP_RESIZE_LEFT:
620 new_size = toplevel->priv->drag_offset_x - x;
621 new_size = CLAMP (new_size, 0, monitor_geom.width / 4)(((new_size) > (monitor_geom.width / 4)) ? (monitor_geom.width
/ 4) : (((new_size) < (0)) ? (0) : (new_size)))
;
622 new_x -= (new_size - toplevel->priv->size);
623 if (!toplevel->priv->x_centered && (new_x + new_size / 2) > monitor_geom.width / 2)
624 new_x_right = monitor_geom.width - (new_x + new_size);
625 else
626 new_x_right = -1;
627 break;
628 case PANEL_GRAB_OP_RESIZE_RIGHT:
629 new_size = x - toplevel->priv->drag_offset_x;
630 new_size = CLAMP (new_size, 0, monitor_geom.width / 4)(((new_size) > (monitor_geom.width / 4)) ? (monitor_geom.width
/ 4) : (((new_size) < (0)) ? (0) : (new_size)))
;
631 if (!toplevel->priv->x_centered && (new_x + new_size / 2) > monitor_geom.width / 2)
632 new_x_right = monitor_geom.width - (new_x + new_size);
633 else
634 new_x_right = -1;
635 break;
636 default:
637 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 637, ((const char*) (__func__)), ((void*)0)); } while (0)
;
638 break;
639 }
640
641 if (new_size == 0)
642 return;
643
644 panel_toplevel_set_x (toplevel, new_x, new_x_right, new_x_centered);
645 panel_toplevel_set_y (toplevel, new_y, new_y_bottom, new_y_centered);
646 panel_toplevel_set_size (toplevel, new_size);
647}
648
649/* this is called for expanded panels that are dragged around */
650static void panel_toplevel_calc_new_orientation(PanelToplevel* toplevel, int pointer_x, int pointer_y)
651{
652 PanelOrientation new_orientation;
653 int hborder, vborder;
654 int monitor;
655 int monitor_width, monitor_height;
656 int new_x, new_y;
657
658 monitor = panel_multimonitor_get_monitor_at_point (pointer_x, pointer_y);
659
660 if (toplevel->priv->geometry.height < toplevel->priv->geometry.width)
661 vborder = hborder = (3 * toplevel->priv->geometry.height) >> 1;
662 else
663 vborder = hborder = (3 * toplevel->priv->geometry.width) >> 1;
664
665 new_x = pointer_x - panel_multimonitor_x (monitor);
666 new_y = pointer_y - panel_multimonitor_y (monitor);
667 monitor_width = panel_multimonitor_width (monitor);
668 monitor_height = panel_multimonitor_height (monitor);
669
670 new_orientation = toplevel->priv->orientation;
671
672 switch (toplevel->priv->orientation) {
673 case PANEL_ORIENTATION_TOP:
674 if (new_y > (monitor_height - hborder))
675 new_orientation = PANEL_ORIENTATION_BOTTOM;
676
677 else if (new_y > hborder) {
678 if (new_x > (monitor_width - vborder))
679 new_orientation = PANEL_ORIENTATION_RIGHT;
680 else if (new_x < vborder)
681 new_orientation = PANEL_ORIENTATION_LEFT;
682 }
683 break;
684 case PANEL_ORIENTATION_BOTTOM:
685 if (new_y < hborder)
686 new_orientation = PANEL_ORIENTATION_TOP;
687
688 else if (new_y < (monitor_height - hborder)) {
689 if (new_x > (monitor_width - vborder))
690 new_orientation = PANEL_ORIENTATION_RIGHT;
691 else if (new_x < vborder)
692 new_orientation = PANEL_ORIENTATION_LEFT;
693 }
694 break;
695 case PANEL_ORIENTATION_LEFT:
696 if (new_x > (monitor_width - vborder))
697 new_orientation = PANEL_ORIENTATION_RIGHT;
698
699 else if (new_x > vborder) {
700 if (new_y > (monitor_height - hborder))
701 new_orientation = PANEL_ORIENTATION_BOTTOM;
702 else if (new_y < hborder)
703 new_orientation = PANEL_ORIENTATION_TOP;
704 }
705 break;
706 case PANEL_ORIENTATION_RIGHT:
707 if (new_x < vborder)
708 new_orientation = PANEL_ORIENTATION_LEFT;
709
710 else if (new_x < (monitor_width - vborder)) {
711 if (new_y > (monitor_height - hborder))
712 new_orientation = PANEL_ORIENTATION_BOTTOM;
713 else if (new_y < hborder)
714 new_orientation = PANEL_ORIENTATION_TOP;
715 }
716 break;
717 default:
718 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 718, ((const char*) (__func__)), ((void*)0)); } while (0)
;
719 break;
720 }
721
722 panel_toplevel_set_monitor (toplevel, monitor);
723 panel_toplevel_set_orientation (toplevel, new_orientation);
724}
725
726static void panel_toplevel_move_to(PanelToplevel* toplevel, int new_x, int new_y)
727{
728 PanelOrientation new_orientation;
729 gboolean x_centered, y_centered;
730 GdkPoint display_min, display_max;
731 GdkRectangle monitor_geom;
732 int width, height;
733 int new_monitor;
734 int x, y, x_right, y_bottom;
735 int snap_tolerance;
736
737 panel_multimonitor_get_bounds (&display_min, &display_max);
738
739 width = toplevel->priv->geometry.width;
740 height = toplevel->priv->geometry.height;
741
742 snap_tolerance = toplevel->priv->snap_tolerance;
743
744 new_x = CLAMP (new_x, 0, display_max.x - width)(((new_x) > (display_max.x - width)) ? (display_max.x - width
) : (((new_x) < (0)) ? (0) : (new_x)))
;
745 new_y = CLAMP (new_y, 0, display_max.y - height)(((new_y) > (display_max.y - height)) ? (display_max.y - height
) : (((new_y) < (0)) ? (0) : (new_y)))
;
746
747 new_orientation = toplevel->priv->orientation;
748
749 if (new_x <= (display_min.x + snap_tolerance) &&
750 toplevel->priv->orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT))
751 new_orientation = PANEL_ORIENTATION_LEFT;
752
753 else if ((new_x + width) >= (display_max.x - snap_tolerance) &&
754 toplevel->priv->orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT))
755 new_orientation = PANEL_ORIENTATION_RIGHT;
756
757 if (new_y <= (display_min.y + snap_tolerance) &&
758 toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM))
759 new_orientation = PANEL_ORIENTATION_TOP;
760
761 else if ((new_y + height) >= (display_max.y - snap_tolerance) &&
762 toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM))
763 new_orientation = PANEL_ORIENTATION_BOTTOM;
764
765 new_monitor = panel_multimonitor_get_monitor_at_point (new_x, new_y);
766
767 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
768
769 x_centered = toplevel->priv->x_centered;
770 y_centered = toplevel->priv->y_centered;
771
772 x = new_x - panel_multimonitor_x (new_monitor);
773 y = new_y - panel_multimonitor_y (new_monitor);
774
775 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)) {
776 if (new_y <= display_min.y + snap_tolerance ||
777 new_y + height >= display_max.y - snap_tolerance)
778 x_centered = abs (x - ((monitor_geom.width - width) / 2))
779 <= snap_tolerance;
780 else
781 x_centered = FALSE(0);
782 } else {
783 if (new_x <= display_min.x + snap_tolerance ||
784 new_x + width >= display_max.x - snap_tolerance)
785 y_centered = abs (y - ((monitor_geom.height - height) / 2))
786 <= snap_tolerance;
787 else
788 y_centered = FALSE(0);
789 }
790
791 if (x_centered)
792 x = (monitor_geom.width - width) / 2;
793 if (y_centered)
794 y = (monitor_geom.height - height) / 2;
795
796 if (!x_centered && (x + width / 2) > monitor_geom.width / 2)
797 x_right = monitor_geom.width - (x + width);
798 else
799 x_right = -1;
800
801 if (!y_centered && (y + height / 2) > monitor_geom.height / 2)
802 y_bottom = monitor_geom.height - (y + height);
803 else
804 y_bottom = -1;
805
806 panel_toplevel_set_monitor (toplevel, new_monitor);
807 panel_toplevel_set_orientation (toplevel, new_orientation);
808 panel_toplevel_set_x (toplevel, x, x_right, x_centered);
809 panel_toplevel_set_y (toplevel, y, y_bottom, y_centered);
810}
811
812static void panel_toplevel_move_to_pointer(PanelToplevel* toplevel, int pointer_x, int pointer_y)
813{
814 int new_x, new_y;
815
816 new_x = pointer_x - toplevel->priv->drag_offset_x;
817 new_y = pointer_y - toplevel->priv->drag_offset_y;
818
819 panel_toplevel_move_to (toplevel, new_x, new_y);
820}
821
822static void panel_toplevel_rotate_to_pointer(PanelToplevel* toplevel, int pointer_x, int pointer_y)
823{
824 int x_diff, y_diff;
825 int x, y;
826 int snap_tolerance;
827
828 x = toplevel->priv->geometry.x;
829 y = toplevel->priv->geometry.y;
830 snap_tolerance = toplevel->priv->snap_tolerance;
831
832 x_diff = pointer_x - (x + toplevel->priv->geometry.width / 2);
833 y_diff = pointer_y - (y + toplevel->priv->geometry.height / 2);
834
835 if (((-y_diff > x_diff + snap_tolerance) && x_diff > 0 && y_diff < 0) ||
836 (( y_diff < x_diff + snap_tolerance) && x_diff < 0 && y_diff < 0))
837 panel_toplevel_set_orientation (toplevel, PANEL_ORIENTATION_RIGHT);
838
839 else if (((-x_diff < y_diff - snap_tolerance) && x_diff > 0 && y_diff < 0) ||
840 (( x_diff > y_diff - snap_tolerance) && x_diff > 0 && y_diff > 0))
841 panel_toplevel_set_orientation (toplevel, PANEL_ORIENTATION_BOTTOM);
842
843 else if ((( y_diff > x_diff + snap_tolerance) && x_diff > 0 && y_diff > 0) ||
844 ((-y_diff < x_diff + snap_tolerance) && x_diff < 0 && y_diff > 0))
845 panel_toplevel_set_orientation (toplevel, PANEL_ORIENTATION_LEFT);
846
847 else if (((-x_diff > y_diff - snap_tolerance) && x_diff < 0 && y_diff > 0) ||
848 (( x_diff < y_diff - snap_tolerance) && x_diff < 0 && y_diff < 0))
849 panel_toplevel_set_orientation (toplevel, PANEL_ORIENTATION_TOP);
850}
851
852#ifdef HAVE_X111
853static gboolean panel_toplevel_warp_pointer_increment(PanelToplevel* toplevel, int keyval, int increment)
854{
855 GdkScreen *screen;
856 GdkWindow *root_window;
857 GdkDevice *device;
858 int new_x, new_y;
859
860 screen = gtk_window_get_screen (GTK_WINDOW (toplevel)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_window_get_type ()))))))
);
861 g_return_val_if_fail (GDK_IS_X11_SCREEN (screen), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((screen)); GType __t = ((gdk_x11_screen_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "GDK_IS_X11_SCREEN (screen)"); return ((0)); }
} while (0)
;
862 root_window = gdk_screen_get_root_window (screen);
863 device = gdk_seat_get_pointer (gdk_display_get_default_seat (gtk_widget_get_display (GTK_WIDGET(root_window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((root_window)), ((gtk_widget_get_type ()))))))
)));
864 gdk_window_get_device_position (gtk_widget_get_window (GTK_WIDGET (root_window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((root_window)), ((gtk_widget_get_type ()))))))
), device, &new_x, &new_y, NULL((void*)0));
865
866 switch (keyval) {
867 case GDK_KEY_Up0xff52:
868 case GDK_KEY_KP_Up0xff97:
869 new_y -= increment;
870 break;
871 case GDK_KEY_Left0xff51:
872 case GDK_KEY_KP_Left0xff96:
873 new_x -= increment;
874 break;
875 case GDK_KEY_Down0xff54:
876 case GDK_KEY_KP_Down0xff99:
877 new_y += increment;
878 break;
879 case GDK_KEY_Right0xff53:
880 case GDK_KEY_KP_Right0xff98:
881 new_x += increment;
882 break;
883 default:
884 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 884, ((const char*) (__func__)), ((void*)0)); } while (0)
;
885 return FALSE(0);
886 }
887
888 panel_warp_pointer (root_window, new_x, new_y);
889
890 return TRUE(!(0));
891}
892
893static gboolean panel_toplevel_move_keyboard_floating(PanelToplevel* toplevel, GdkEventKey* event)
894{
895#define SMALL_INCREMENT 1
896#define NORMAL_INCREMENT 10
897
898 int increment = NORMAL_INCREMENT;
899
900 if ((event->state & gtk_accelerator_get_default_mod_mask ()) == GDK_SHIFT_MASK)
901 increment = SMALL_INCREMENT;
902
903 return panel_toplevel_warp_pointer_increment (
904 toplevel, event->keyval, increment);
905
906#undef SMALL_INCREMENT
907#undef NORMAL_INCREMENT
908}
909
910#endif /* HAVE_X11 */
911
912static gboolean panel_toplevel_move_keyboard_expanded(PanelToplevel* toplevel, GdkEventKey* event)
913{
914 PanelOrientation new_orientation;
915
916 switch (event->keyval) {
917 case GDK_KEY_Up0xff52:
918 case GDK_KEY_KP_Up0xff97:
919 new_orientation = PANEL_ORIENTATION_TOP;
920 break;
921 case GDK_KEY_Left0xff51:
922 case GDK_KEY_KP_Left0xff96:
923 new_orientation = PANEL_ORIENTATION_LEFT;
924 break;
925 case GDK_KEY_Down0xff54:
926 case GDK_KEY_KP_Down0xff99:
927 new_orientation = PANEL_ORIENTATION_BOTTOM;
928 break;
929 case GDK_KEY_Right0xff53:
930 case GDK_KEY_KP_Right0xff98:
931 new_orientation = PANEL_ORIENTATION_RIGHT;
932 break;
933 default:
934 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 934, ((const char*) (__func__)), ((void*)0)); } while (0)
;
935 return FALSE(0);
936 }
937
938 panel_toplevel_set_orientation (toplevel, new_orientation);
939
940 return TRUE(!(0));
941}
942
943static gboolean panel_toplevel_initial_resize_keypress(PanelToplevel* toplevel, GdkEventKey* event)
944{
945 PanelGrabOpType grab_op;
946
947 switch (event->keyval) {
948 case GDK_KEY_Up0xff52:
949 case GDK_KEY_KP_Up0xff97:
950 if (!(toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)))
951 return FALSE(0);
952 grab_op = PANEL_GRAB_OP_RESIZE_UP;
953 break;
954 case GDK_KEY_Left0xff51:
955 case GDK_KEY_KP_Left0xff96:
956 if (!(toplevel->priv->orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT)))
957 return FALSE(0);
958 grab_op = PANEL_GRAB_OP_RESIZE_LEFT;
959 break;
960 case GDK_KEY_Down0xff54:
961 case GDK_KEY_KP_Down0xff99:
962 if (!(toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)))
963 return FALSE(0);
964 grab_op = PANEL_GRAB_OP_RESIZE_DOWN;
965 break;
966 case GDK_KEY_Right0xff53:
967 case GDK_KEY_KP_Right0xff98:
968 if (!(toplevel->priv->orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT)))
969 return FALSE(0);
970 grab_op = PANEL_GRAB_OP_RESIZE_RIGHT;
971 break;
972 default:
973 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 973, ((const char*) (__func__)), ((void*)0)); } while (0)
;
974 return FALSE(0);
975 }
976
977 panel_toplevel_end_grab_op (toplevel, event->time);
978 panel_toplevel_begin_grab_op (toplevel, grab_op, TRUE(!(0)), event->time);
979
980 return TRUE(!(0));
981}
982
983static gboolean panel_toplevel_handle_grab_op_key_event(PanelToplevel* toplevel, GdkEventKey* event)
984{
985 gboolean retval = FALSE(0);
986
987 switch (event->keyval) {
988 case GDK_KEY_Up0xff52:
989 case GDK_KEY_KP_Up0xff97:
990 case GDK_KEY_Left0xff51:
991 case GDK_KEY_KP_Left0xff96:
992 case GDK_KEY_Down0xff54:
993 case GDK_KEY_KP_Down0xff99:
994 case GDK_KEY_Right0xff53:
995 case GDK_KEY_KP_Right0xff98:
996 switch (toplevel->priv->grab_op) {
997 case PANEL_GRAB_OP_MOVE:
998 if (toplevel->priv->expand) {
999 retval = panel_toplevel_move_keyboard_expanded (
1000 toplevel, event);
1001 }
1002#ifdef HAVE_X111
1003 else if (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel)))(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gtk_widget_get_display (((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((toplevel)), ((gtk_widget_get_type ()))))
))))); GType __t = ((gdk_x11_display_get_type())); gboolean __r
; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
) {
1004 retval = panel_toplevel_move_keyboard_floating (
1005 toplevel, event);
1006 }
1007#endif /* HAVE_X11 */
1008 break;
1009 case PANEL_GRAB_OP_RESIZE:
1010 retval = panel_toplevel_initial_resize_keypress (toplevel, event);
1011 break;
1012 case PANEL_GRAB_OP_RESIZE_UP:
1013 case PANEL_GRAB_OP_RESIZE_DOWN:
1014 case PANEL_GRAB_OP_RESIZE_LEFT:
1015 case PANEL_GRAB_OP_RESIZE_RIGHT:
1016#ifdef HAVE_X111
1017 if (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel)))(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gtk_widget_get_display (((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((toplevel)), ((gtk_widget_get_type ()))))
))))); GType __t = ((gdk_x11_display_get_type())); gboolean __r
; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
)
1018 retval = panel_toplevel_warp_pointer_increment (toplevel, event->keyval, 1);
1019#endif /* HAVE_X11 */
1020 break;
1021 default:
1022 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 1022, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1023 break;
1024 }
1025 break;
1026 case GDK_KEY_Escape0xff1b:
1027 panel_toplevel_cancel_grab_op (toplevel, event->time);
1028 case GDK_KEY_Return0xff0d: /* drop through*/
1029 case GDK_KEY_KP_Enter0xff8d:
1030 case GDK_KEY_space0x020:
1031 case GDK_KEY_KP_Space0xff80:
1032 panel_toplevel_end_grab_op (toplevel, event->time);
1033 retval = TRUE(!(0));
1034 default: /* drop through*/
1035 break;
1036 }
1037
1038 return retval;
1039}
1040
1041static gboolean panel_toplevel_handle_grab_op_motion_event(PanelToplevel* toplevel, GdkEventMotion* event)
1042{
1043 switch (toplevel->priv->grab_op) {
1044 case PANEL_GRAB_OP_MOVE:
1045 if (toplevel->priv->expand)
1046 panel_toplevel_calc_new_orientation (
1047 toplevel, event->x_root, event->y_root);
1048
1049 else if ((event->state & gtk_accelerator_get_default_mod_mask ()) == GDK_CONTROL_MASK)
1050 panel_toplevel_rotate_to_pointer (
1051 toplevel, event->x_root, event->y_root);
1052
1053 else
1054 panel_toplevel_move_to_pointer (
1055 toplevel, event->x_root, event->y_root);
1056 return TRUE(!(0));
1057 case PANEL_GRAB_OP_RESIZE_UP:
1058 case PANEL_GRAB_OP_RESIZE_DOWN:
1059 case PANEL_GRAB_OP_RESIZE_LEFT:
1060 case PANEL_GRAB_OP_RESIZE_RIGHT:
1061 panel_toplevel_resize_to_pointer (toplevel, event->x_root, event->y_root);
1062 return TRUE(!(0));
1063 default:
1064 break;
1065 }
1066
1067 return FALSE(0);
1068}
1069
1070static void panel_toplevel_calc_floating(PanelToplevel* toplevel)
1071{
1072 GdkRectangle monitor_geom;
1073 GdkPoint position_on_monitor;
1074 int snap_tolerance;
1075
1076 if (toplevel->priv->expand) {
1077 toplevel->priv->floating = FALSE(0);
1078 return;
1079 }
1080
1081 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
1082
1083 if (toplevel->priv->x_right == -1)
1084 position_on_monitor.x = toplevel->priv->x;
1085 else
1086 position_on_monitor.x = monitor_geom.width - (toplevel->priv->x_right + toplevel->priv->geometry.width);
1087 if (toplevel->priv->y_bottom == -1)
1088 position_on_monitor.y = toplevel->priv->y;
1089 else
1090 position_on_monitor.y = monitor_geom.height - (toplevel->priv->y_bottom + toplevel->priv->geometry.height);
1091
1092 snap_tolerance = toplevel->priv->snap_tolerance;
1093
1094 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM))
1095 toplevel->priv->floating =
1096 (position_on_monitor.y > snap_tolerance) &&
1097 (position_on_monitor.y < (monitor_geom.height - toplevel->priv->geometry.height - snap_tolerance));
1098 else
1099 toplevel->priv->floating =
1100 (position_on_monitor.x > snap_tolerance) &&
1101 (position_on_monitor.x < (monitor_geom.width - toplevel->priv->geometry.width - snap_tolerance));
1102}
1103
1104void panel_toplevel_push_autohide_disabler(PanelToplevel* toplevel)
1105{
1106 g_return_if_fail (toplevel != NULL)do { if ((toplevel != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "toplevel != NULL"
); return; } } while (0)
;
1107
1108 if (!toplevel->priv->n_autohide_disablers++)
1109 panel_toplevel_queue_auto_hide (toplevel);
1110}
1111
1112void panel_toplevel_pop_autohide_disabler(PanelToplevel* toplevel)
1113{
1114 g_return_if_fail (toplevel != NULL)do { if ((toplevel != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "toplevel != NULL"
); return; } } while (0)
;
1115 g_return_if_fail (toplevel->priv->n_autohide_disablers > 0)do { if ((toplevel->priv->n_autohide_disablers > 0))
{ } else { g_return_if_fail_warning (((gchar*) 0), ((const char
*) (__func__)), "toplevel->priv->n_autohide_disablers > 0"
); return; } } while (0)
;
1116
1117 if (!--toplevel->priv->n_autohide_disablers)
1118 panel_toplevel_queue_auto_hide (toplevel);
1119}
1120
1121static gboolean panel_toplevel_get_autohide_disabled(PanelToplevel* toplevel)
1122{
1123 return toplevel->priv->n_autohide_disablers > 0 ? TRUE(!(0)) : FALSE(0);
1124}
1125
1126static gboolean panel_toplevel_hide_button_event(PanelToplevel* toplevel, GdkEventButton* event, GtkButton* button)
1127{
1128 if (event->button == 1)
1129 return FALSE(0);
1130
1131 return gtk_widget_event (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
, (GdkEvent *) event);
1132}
1133
1134static void panel_toplevel_hide_button_clicked(PanelToplevel* toplevel, GtkButton* button)
1135{
1136 GtkArrowType arrow_type;
1137 gboolean ltr;
1138
1139 if (toplevel->priv->animating ||
1140 toplevel->priv->state == PANEL_STATE_AUTO_HIDDEN)
1141 return;
1142
1143 ltr = gtk_widget_get_direction (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
) == GTK_TEXT_DIR_LTR;
1144 arrow_type = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button), "arrow-type"))((gint) (glong) (g_object_get_data (((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((button)), (((GType) ((20) << (2)))
))))), "arrow-type")))
;
1145
1146 if (toplevel->priv->state == PANEL_STATE_NORMAL) {
1147 GtkDirectionType direction;
1148
1149 switch (arrow_type) {
1150 case GTK_ARROW_UP:
1151 direction = GTK_DIR_UP;
1152 break;
1153 case GTK_ARROW_DOWN:
1154 direction = GTK_DIR_DOWN;
1155 break;
1156 case GTK_ARROW_LEFT:
1157 direction = ltr ? GTK_DIR_LEFT : GTK_DIR_RIGHT;
1158 break;
1159 case GTK_ARROW_RIGHT:
1160 direction = ltr ? GTK_DIR_RIGHT : GTK_DIR_LEFT;
1161 break;
1162 default:
1163 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 1163, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1164 break;
1165 }
1166
1167 panel_toplevel_hide (toplevel, FALSE(0), (gint) direction);
1168 } else
1169 panel_toplevel_unhide (toplevel);
1170}
1171
1172static void
1173set_arrow_type (GtkImage *image,
1174 GtkArrowType arrow_type)
1175{
1176 switch (arrow_type)
1177 {
1178 case GTK_ARROW_NONE:
1179 case GTK_ARROW_DOWN:
1180 gtk_image_set_from_icon_name (image, "pan-down-symbolic", GTK_ICON_SIZE_BUTTON);
1181 break;
1182 case GTK_ARROW_UP:
1183 gtk_image_set_from_icon_name (image, "pan-up-symbolic", GTK_ICON_SIZE_BUTTON);
1184 break;
1185 case GTK_ARROW_LEFT:
1186 gtk_image_set_from_icon_name (image, "pan-start-symbolic", GTK_ICON_SIZE_BUTTON);
1187 break;
1188 case GTK_ARROW_RIGHT:
1189 gtk_image_set_from_icon_name (image, "pan-end-symbolic", GTK_ICON_SIZE_BUTTON);
1190 break;
1191 }
1192}
1193
1194static GtkWidget *
1195panel_toplevel_add_hide_button (PanelToplevel *toplevel,
1196 GtkArrowType arrow_type,
1197 int left,
1198 int top)
1199{
1200
1201 GtkWidget *button;
1202 AtkObject *obj;
1203 GtkWidget *arrow;
1204
1205 button = gtk_button_new ();
1206 obj = gtk_widget_get_accessible (button);
1207 atk_object_set_name (obj, _("Hide Panel")gettext ("Hide Panel"));
1208 gtk_widget_set_can_default (button, FALSE(0));
1209
1210 arrow = gtk_image_new ();
1211 set_arrow_type (GTK_IMAGE (arrow)((((GtkImage*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((arrow)), ((gtk_image_get_type ()))))))
, arrow_type);
1212 gtk_container_add (GTK_CONTAINER (button)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), ((gtk_container_get_type ()))))))
, arrow);
1213 gtk_widget_show (arrow);
1214
1215 g_object_set_data (G_OBJECT (button)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), (((GType) ((20) << (2))))))))
,
1216 "arrow-type",
1217 GINT_TO_POINTER (arrow_type)((gpointer) (glong) (arrow_type)));
1218
1219 g_signal_connect_swapped (button, "clicked",g_signal_connect_data ((button), ("clicked"), (((GCallback) (
panel_toplevel_hide_button_clicked))), (toplevel), ((void*)0)
, G_CONNECT_SWAPPED)
1220 G_CALLBACK (panel_toplevel_hide_button_clicked), toplevel)g_signal_connect_data ((button), ("clicked"), (((GCallback) (
panel_toplevel_hide_button_clicked))), (toplevel), ((void*)0)
, G_CONNECT_SWAPPED)
;
1221 g_signal_connect_swapped (button, "button-press-event",g_signal_connect_data ((button), ("button-press-event"), (((GCallback
) (panel_toplevel_hide_button_event))), (toplevel), ((void*)0
), G_CONNECT_SWAPPED)
1222 G_CALLBACK (panel_toplevel_hide_button_event), toplevel)g_signal_connect_data ((button), ("button-press-event"), (((GCallback
) (panel_toplevel_hide_button_event))), (toplevel), ((void*)0
), G_CONNECT_SWAPPED)
;
1223 g_signal_connect_swapped (button, "button-release-event",g_signal_connect_data ((button), ("button-release-event"), ((
(GCallback) (panel_toplevel_hide_button_event))), (toplevel),
((void*)0), G_CONNECT_SWAPPED)
1224 G_CALLBACK (panel_toplevel_hide_button_event), toplevel)g_signal_connect_data ((button), ("button-release-event"), ((
(GCallback) (panel_toplevel_hide_button_event))), (toplevel),
((void*)0), G_CONNECT_SWAPPED)
;
1225
1226 gtk_grid_attach (GTK_GRID (toplevel->priv->grid)((((GtkGrid*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->grid)), ((gtk_grid_get_type ()))))
))
, button, left, top, 1, 1);
1227
1228 return button;
1229}
1230
1231static void panel_toplevel_update_buttons_showing(PanelToplevel* toplevel)
1232{
1233 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)) {
1234 gtk_widget_hide (toplevel->priv->hide_button_top);
1235 gtk_widget_hide (toplevel->priv->hide_button_bottom);
1236 gtk_widget_show (toplevel->priv->hide_button_left);
1237 gtk_widget_show (toplevel->priv->hide_button_right);
1238 } else {
1239 gtk_widget_show (toplevel->priv->hide_button_top);
1240 gtk_widget_show (toplevel->priv->hide_button_bottom);
1241 gtk_widget_hide (toplevel->priv->hide_button_left);
1242 gtk_widget_hide (toplevel->priv->hide_button_right);
1243 }
1244
1245 if (toplevel->priv->attached) {
1246 switch (panel_toplevel_get_orientation (toplevel->priv->attach_toplevel)) {
1247 case PANEL_ORIENTATION_TOP:
1248 gtk_widget_hide (toplevel->priv->hide_button_top);
1249 break;
1250 case PANEL_ORIENTATION_BOTTOM:
1251 gtk_widget_hide (toplevel->priv->hide_button_bottom);
1252 break;
1253 case PANEL_ORIENTATION_LEFT:
1254 gtk_widget_hide (toplevel->priv->hide_button_left);
1255 break;
1256 case PANEL_ORIENTATION_RIGHT:
1257 gtk_widget_hide (toplevel->priv->hide_button_right);
1258 break;
1259 default:
1260 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 1260, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1261 break;
1262 }
1263 }
1264}
1265
1266/* force set hide button size on panel size < 30px */
1267static void panel_toplevel_update_hide_buttons_size (GtkWidget *button, int panel_size)
1268{
1269 GtkCssProvider *css_provider;
1270 GtkStyleContext *context;
1271 GtkWidget *arrow;
1272 GtkSettings *settings;
1273 gchar *gtk_theme_name = NULL((void*)0);
1274
1275 context = gtk_widget_get_style_context (button);
1276 gtk_style_context_add_class (context, "panel-button");
1277
1278 /* get defaults from theme */
1279 settings = gtk_settings_get_default ();
1280 g_object_get (settings, "gtk-theme-name", &gtk_theme_name, NULL((void*)0));
1281 css_provider = gtk_css_provider_get_named (gtk_theme_name, NULL((void*)0));
1282 g_free (gtk_theme_name);
1283
1284 /* set custom css by adding our custom code to the default theme css
1285 *
1286 * NOTE that contriary to the documentation:
1287 * https://developer.gnome.org/gtk3/stable/GtkCssProvider.html#gtk-css-provider-load-from-data
1288 * the previously loaded theme is NOT cleared from the css_provider. (reason unknown)
1289 * In other words, this works exactly, how we need it here.
1290 * ALSO NOTE that using gtk_css_provider_to_string () to convert the theme css data into a string
1291 * and then adding the custom css, then adding this updated css to a css_provider
1292 * with the gtk_css_provider_load_from_data () also works,
1293 * however some themes can't be easily converted to strings, beacuse of the binary data
1294 * they contain. This causes a delay of minutes in loading the mate-panel,
1295 * and so this approach is not viable. */
1296 if (panel_size < 30) {
1297 gtk_css_provider_load_from_data (css_provider, ".panel-button {min-height: 13px; min-width: 13px; padding: 0px;}", -1, NULL((void*)0));
1298 }
1299
1300 gtk_style_context_add_provider (context, GTK_STYLE_PROVIDER (css_provider)((((GtkStyleProvider*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((css_provider)), ((gtk_style_provider_get_type
()))))))
, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION600);
1301
1302 /* get arrow image */
1303 arrow = gtk_bin_get_child (GTK_BIN (button)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), ((gtk_bin_get_type ()))))))
);
1304
1305 /* set image size */
1306 if (panel_size < 20) {
1307 gtk_image_set_pixel_size (GTK_IMAGE (arrow)((((GtkImage*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((arrow)), ((gtk_image_get_type ()))))))
, 12);
1308 } else if (panel_size < 40) {
1309 gtk_image_set_pixel_size (GTK_IMAGE (arrow)((((GtkImage*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((arrow)), ((gtk_image_get_type ()))))))
, 16);
1310 } else if (panel_size < 60) {
1311 gtk_image_set_pixel_size (GTK_IMAGE (arrow)((((GtkImage*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((arrow)), ((gtk_image_get_type ()))))))
, 22);
1312 } else {
1313 gtk_image_set_pixel_size (GTK_IMAGE (arrow)((((GtkImage*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((arrow)), ((gtk_image_get_type ()))))))
, 24);
1314 }
1315}
1316
1317static void panel_toplevel_update_hide_buttons(PanelToplevel* toplevel)
1318{
1319
1320 int panel_size = toplevel->priv->size;
1321
1322 if (toplevel->priv->buttons_enabled) {
1323 panel_toplevel_update_buttons_showing (toplevel);
1324
1325 panel_toplevel_update_hide_buttons_size (toplevel->priv->hide_button_top, panel_size);
1326 panel_toplevel_update_hide_buttons_size (toplevel->priv->hide_button_bottom, panel_size);
1327 panel_toplevel_update_hide_buttons_size (toplevel->priv->hide_button_left, panel_size);
1328 panel_toplevel_update_hide_buttons_size (toplevel->priv->hide_button_right, panel_size);
1329
1330 } else {
1331 g_object_set (
1332 G_OBJECT (toplevel->priv->hide_button_top)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->hide_button_top)), (((GType) ((20)
<< (2))))))))
,
1333 "visible", toplevel->priv->state == PANEL_STATE_HIDDEN_DOWN,
1334 NULL((void*)0));
1335 g_object_set (
1336 G_OBJECT (toplevel->priv->hide_button_bottom)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->hide_button_bottom)), (((GType) ((
20) << (2))))))))
,
1337 "visible", toplevel->priv->state == PANEL_STATE_HIDDEN_UP,
1338 NULL((void*)0));
1339 g_object_set (
1340 G_OBJECT (toplevel->priv->hide_button_left)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->hide_button_left)), (((GType) ((20
) << (2))))))))
,
1341 "visible", toplevel->priv->state == PANEL_STATE_HIDDEN_RIGHT,
1342 NULL((void*)0));
1343 g_object_set (
1344 G_OBJECT (toplevel->priv->hide_button_right)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->hide_button_right)), (((GType) ((20
) << (2))))))))
,
1345 "visible", toplevel->priv->state == PANEL_STATE_HIDDEN_LEFT,
1346 NULL((void*)0));
1347 }
1348
1349 if (toplevel->priv->arrows_enabled) {
1350
1351 gtk_widget_show (gtk_bin_get_child (GTK_BIN (toplevel->priv->hide_button_top)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->hide_button_top)), ((gtk_bin_get_type
()))))))
));
1352 gtk_widget_show (gtk_bin_get_child (GTK_BIN (toplevel->priv->hide_button_bottom)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->hide_button_bottom)), ((gtk_bin_get_type
()))))))
));
1353 gtk_widget_show (gtk_bin_get_child (GTK_BIN (toplevel->priv->hide_button_left)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->hide_button_left)), ((gtk_bin_get_type
()))))))
));
1354 gtk_widget_show (gtk_bin_get_child (GTK_BIN (toplevel->priv->hide_button_right)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->hide_button_right)), ((gtk_bin_get_type
()))))))
));
1355
1356 } else {
1357
1358 gtk_widget_hide (gtk_bin_get_child (GTK_BIN (toplevel->priv->hide_button_top)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->hide_button_top)), ((gtk_bin_get_type
()))))))
));
1359 gtk_widget_hide (gtk_bin_get_child (GTK_BIN (toplevel->priv->hide_button_bottom)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->hide_button_bottom)), ((gtk_bin_get_type
()))))))
));
1360 gtk_widget_hide (gtk_bin_get_child (GTK_BIN (toplevel->priv->hide_button_left)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->hide_button_left)), ((gtk_bin_get_type
()))))))
));
1361 gtk_widget_hide (gtk_bin_get_child (GTK_BIN (toplevel->priv->hide_button_right)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->hide_button_right)), ((gtk_bin_get_type
()))))))
));
1362 }
1363
1364 /* set size after setting the arrow */
1365 if (toplevel->priv->buttons_enabled) {
1366 int hb_size;
1367
1368 if (panel_size < 20)
1369 hb_size = 16;
1370 else if (panel_size < 40)
1371 hb_size = 20;
1372 else if (panel_size < 60)
1373 hb_size = 26;
1374 else
1375 hb_size = 30;
1376
1377 gtk_widget_set_size_request (toplevel->priv->hide_button_top, panel_size, hb_size);
1378 gtk_widget_set_size_request (toplevel->priv->hide_button_bottom, panel_size, hb_size);
1379 gtk_widget_set_size_request (toplevel->priv->hide_button_left, hb_size, panel_size);
1380 gtk_widget_set_size_request (toplevel->priv->hide_button_right, hb_size, panel_size);
1381 }
1382}
1383
1384static gboolean panel_toplevel_contains_pointer(PanelToplevel* toplevel)
1385{
1386 GdkDisplay *display;
1387 GdkScreen *screen;
1388 GtkWidget *widget;
1389 GdkSeat *seat;
1390 GdkDevice *pointer;
1391 int x, y;
1392
1393 display = gdk_display_get_default ();
1394 seat = gdk_display_get_default_seat (display);
1395 pointer = gdk_seat_get_pointer (seat);
1396 widget = GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
;
1397
1398 if (!gtk_widget_get_realized (widget))
1399 return FALSE(0);
1400
1401 screen = NULL((void*)0);
1402 x = y = -1;
1403 gdk_device_get_position (pointer, &screen, &x, &y);
1404
1405 if (screen != gtk_window_get_screen (GTK_WINDOW (toplevel)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_window_get_type ()))))))
))
1406 return FALSE(0);
1407
1408 if (x == -1 || y == -1)
1409 return FALSE(0);
1410
1411 if (x < toplevel->priv->geometry.x || x >= (toplevel->priv->geometry.x + toplevel->priv->geometry.width) ||
1412 y < toplevel->priv->geometry.y || y >= (toplevel->priv->geometry.y + toplevel->priv->geometry.height))
1413 return FALSE(0);
1414
1415 return TRUE(!(0));
1416}
1417
1418static inline int panel_toplevel_get_effective_auto_hide_size(PanelToplevel* toplevel)
1419{
1420 int size;
1421
1422 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM))
1423 size = CLAMP (toplevel->priv->auto_hide_size,(((toplevel->priv->auto_hide_size) > (toplevel->priv
->original_height / 2)) ? (toplevel->priv->original_height
/ 2) : (((toplevel->priv->auto_hide_size) < (1)) ? (
1) : (toplevel->priv->auto_hide_size)))
1424 1, toplevel->priv->original_height / 2)(((toplevel->priv->auto_hide_size) > (toplevel->priv
->original_height / 2)) ? (toplevel->priv->original_height
/ 2) : (((toplevel->priv->auto_hide_size) < (1)) ? (
1) : (toplevel->priv->auto_hide_size)))
;
1425 else
1426 size = CLAMP (toplevel->priv->auto_hide_size,(((toplevel->priv->auto_hide_size) > (toplevel->priv
->original_width / 2)) ? (toplevel->priv->original_width
/ 2) : (((toplevel->priv->auto_hide_size) < (1)) ? (
1) : (toplevel->priv->auto_hide_size)))
1427 1, toplevel->priv->original_width / 2)(((toplevel->priv->auto_hide_size) > (toplevel->priv
->original_width / 2)) ? (toplevel->priv->original_width
/ 2) : (((toplevel->priv->auto_hide_size) < (1)) ? (
1) : (toplevel->priv->auto_hide_size)))
;
1428
1429 /* paranoia */
1430 return (size <= 0) ? DEFAULT_AUTO_HIDE_SIZE1 : size;
1431}
1432
1433static gboolean panel_toplevel_update_struts(PanelToplevel* toplevel, gboolean end_of_animation)
1434{
1435 PanelOrientation orientation;
1436 gboolean geometry_changed = FALSE(0);
1437 int strut, strut_start, strut_end;
1438 int x, y, width, height;
1439 GdkRectangle monitor_geom;
1440
1441 if (!toplevel->priv->updated_geometry_initial)
1442 return FALSE(0);
1443
1444#ifdef HAVE_X111
1445 if (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel)))(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gtk_widget_get_display (((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((toplevel)), ((gtk_widget_get_type ()))))
))))); GType __t = ((gdk_x11_display_get_type())); gboolean __r
; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
&& toplevel->priv->attached) {
1446 panel_struts_unregister_strut (toplevel);
1447 panel_struts_set_window_hint (toplevel);
1448 return FALSE(0);
1449 }
1450#endif /* HAVE_X11 */
1451
1452 /* In the case of the initial animation, we really want the struts to
1453 * represent what is at the end of the animation, to avoid desktop
1454 * icons jumping around. */
1455 if (!toplevel->priv->initial_animation_done) {
1456 end_of_animation = TRUE(!(0));
1457
1458 /* We've not started the animation yet, so we have to compute
1459 * where we want to end. Note that we don't want to compute
1460 * this everytime, since the struts conflict resolution will be
1461 * overridden if we do so */
1462 if (!toplevel->priv->animating)
1463 panel_toplevel_calculate_animation_end_geometry (toplevel);
1464 }
1465
1466 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
1467
1468 if (end_of_animation) {
1469 x = toplevel->priv->animation_end_x;
1470 y = toplevel->priv->animation_end_y;
1471 x += panel_multimonitor_x (toplevel->priv->monitor);
1472 y += panel_multimonitor_y (toplevel->priv->monitor);
1473 if (toplevel->priv->animation_end_width != -1)
1474 width = toplevel->priv->animation_end_width;
1475 else
1476 width = toplevel->priv->geometry.width;
1477 if (toplevel->priv->animation_end_height != -1)
1478 height = toplevel->priv->animation_end_height;
1479 else
1480 height = toplevel->priv->geometry.height;
1481 } else {
1482 x = toplevel->priv->geometry.x;
1483 y = toplevel->priv->geometry.y;
1484 width = toplevel->priv->geometry.width;
1485 height = toplevel->priv->geometry.height;
1486 }
1487
1488 orientation = toplevel->priv->orientation;
1489
1490 strut = strut_start = strut_end = 0;
1491
1492 if (orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)) {
1493 if (y <= monitor_geom.y) {
1494 orientation = PANEL_ORIENTATION_TOP;
1495 strut = y + height - monitor_geom.y;
1496 } else if (y >= monitor_geom.y + monitor_geom.height - height) {
1497 orientation = PANEL_ORIENTATION_BOTTOM;
1498 strut = monitor_geom.y + monitor_geom.height - y;
1499 }
1500
1501 if (strut > 0) {
1502 strut_start = MAX (x, monitor_geom.x)(((x) > (monitor_geom.x)) ? (x) : (monitor_geom.x));
1503 strut_end = MIN (x + width, monitor_geom.x + monitor_geom.width)(((x + width) < (monitor_geom.x + monitor_geom.width)) ? (
x + width) : (monitor_geom.x + monitor_geom.width))
- 1;
1504 }
1505 } else {
1506 if (x <= monitor_geom.x) {
1507 orientation = PANEL_ORIENTATION_LEFT;
1508 strut = x + width - monitor_geom.x;
1509 } else if (x >= monitor_geom.x + monitor_geom.width - width) {
1510 orientation = PANEL_ORIENTATION_RIGHT;
1511 strut = monitor_geom.x + monitor_geom.width - x;
1512 }
1513
1514 if (strut > 0) {
1515 strut_start = MAX (y, monitor_geom.y)(((y) > (monitor_geom.y)) ? (y) : (monitor_geom.y));
1516 strut_end = MIN (y + height, monitor_geom.y + monitor_geom.height)(((y + height) < (monitor_geom.y + monitor_geom.height)) ?
(y + height) : (monitor_geom.y + monitor_geom.height))
- 1;
1517 }
1518 }
1519
1520 if (orientation != toplevel->priv->orientation) {
1521 toplevel->priv->orientation = orientation;
1522 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "orientation");
1523 }
1524
1525 if (toplevel->priv->auto_hide && strut > 0)
1526 strut = panel_toplevel_get_effective_auto_hide_size (toplevel);
1527
1528#ifdef HAVE_X111
1529 if (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel)))(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gtk_widget_get_display (((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((toplevel)), ((gtk_widget_get_type ()))))
))))); GType __t = ((gdk_x11_display_get_type())); gboolean __r
; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
) {
1530 if (strut > 0) {
1531 GdkScreen *screen;
1532 screen = gtk_widget_get_screen (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
1533 geometry_changed = panel_struts_register_strut (toplevel,
1534 screen,
1535 toplevel->priv->monitor,
1536 orientation,
1537 strut,
1538 strut_start,
1539 strut_end);
1540 }
1541 else {
1542 panel_struts_unregister_strut (toplevel);
1543 }
1544
1545 if (toplevel->priv->state == PANEL_STATE_NORMAL ||
1546 toplevel->priv->state == PANEL_STATE_AUTO_HIDDEN ||
1547 toplevel->priv->animating)
1548 panel_struts_set_window_hint (toplevel);
1549 else
1550 panel_struts_unset_window_hint (toplevel);
1551 }
1552#endif /* HAVE_X11 */
1553
1554#ifdef HAVE_WAYLAND1
1555 if (GDK_IS_WAYLAND_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel)))(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gtk_widget_get_display (((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((toplevel)), ((gtk_widget_get_type ()))))
))))); GType __t = ((gdk_wayland_display_get_type())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
) {
1556 wayland_panel_toplevel_update_placement (toplevel);
1557 }
1558#endif /* HAVE_WAYLAND */
1559 return geometry_changed;
1560}
1561
1562void panel_toplevel_update_edges(PanelToplevel* toplevel)
1563{
1564 GtkWidget *widget;
1565 PanelFrameEdge edges;
1566 PanelFrameEdge inner_edges;
1567 PanelFrameEdge outer_edges;
1568 GdkRectangle monitor_geom;
1569 int width, height;
1570 gboolean inner_frame = FALSE(0);
1571
1572 widget = GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
;
1573
1574 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
1575
1576 width = toplevel->priv->geometry.width;
1577 height = toplevel->priv->geometry.height;
1578
1579 edges = PANEL_EDGE_NONE;
1580
1581 /* We don't want any bevels with a color/image background */
1582 if (toplevel->priv->geometry.y > 0)
1583 edges |= PANEL_EDGE_TOP;
1584
1585 if (toplevel->priv->geometry.x > 0)
1586 edges |= PANEL_EDGE_LEFT;
1587
1588 if (toplevel->priv->geometry.y < (monitor_geom.height - height))
1589 edges |= PANEL_EDGE_BOTTOM;
1590
1591 if (toplevel->priv->geometry.x < (monitor_geom.width - width))
1592 edges |= PANEL_EDGE_RIGHT;
1593
1594 /* There is a conflict in the position algorithm when a
1595 * non-expanded centered panel is nearly the size of the
1596 * screen. This is similar to the one we have in
1597 * panel_toplevel_update_position(). A simple solution is
1598 * to keep the bevels in this case. */
1599 if (!toplevel->priv->expand &&
1600 toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM) &&
1601 toplevel->priv->x_centered)
1602 edges |= PANEL_EDGE_LEFT | PANEL_EDGE_RIGHT;
1603
1604 if (!toplevel->priv->expand &&
1605 toplevel->priv->orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT) &&
1606 toplevel->priv->y_centered)
1607 edges |= PANEL_EDGE_TOP | PANEL_EDGE_BOTTOM;
1608
1609 if (gtk_widget_get_visible (toplevel->priv->hide_button_left) ||
1610 gtk_widget_get_visible (toplevel->priv->hide_button_right)) {
1611 inner_frame = TRUE(!(0));
1612 edges |= PANEL_EDGE_LEFT | PANEL_EDGE_RIGHT;
1613 }
1614
1615 if (gtk_widget_get_visible (toplevel->priv->hide_button_top) ||
1616 gtk_widget_get_visible (toplevel->priv->hide_button_bottom)) {
1617 inner_frame = TRUE(!(0));
1618 edges |= PANEL_EDGE_TOP | PANEL_EDGE_BOTTOM;
1619 }
1620
1621 if (!inner_frame) {
1622 inner_edges = PANEL_EDGE_NONE;
1623 outer_edges = edges;
1624 } else {
1625 inner_edges = edges;
1626 outer_edges = PANEL_EDGE_NONE;
1627 }
1628
1629 panel_frame_set_edges (toplevel->priv->inner_frame, inner_edges);
1630
1631 if (toplevel->priv->edges != outer_edges) {
1632 toplevel->priv->edges = outer_edges;
1633 gtk_widget_queue_resize (widget);
1634 }
1635}
1636
1637static const char* panel_toplevel_construct_description(PanelToplevel *toplevel)
1638{
1639 if (toplevel->priv->attached)
1640 return _("Drawer")gettext ("Drawer");
1641
1642 switch (toplevel->priv->orientation) {
1643 case PANEL_ORIENTATION_TOP:
1644 /* translators: these string will be shown in MetaCity's switch window
1645 * popup when you pass the focus to a panel */
1646 return _("Top Panel")gettext ("Top Panel");
1647 case PANEL_ORIENTATION_BOTTOM:
1648 return _("Bottom Panel")gettext ("Bottom Panel");
1649 case PANEL_ORIENTATION_LEFT:
1650 return _("Left Panel")gettext ("Left Panel");
1651 case PANEL_ORIENTATION_RIGHT:
1652 return _("Right Panel")gettext ("Right Panel");
1653 }
1654
1655 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 1655, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1656 return _("Top Panel")gettext ("Top Panel");
1657}
1658
1659static void panel_toplevel_update_description(PanelToplevel* toplevel)
1660{
1661 const char *description;
1662
1663 description = panel_toplevel_construct_description (toplevel);
1664
1665 if (toplevel->priv->description &&
1666 !strcmp (toplevel->priv->description, description))
1667 return;
1668
1669 if (toplevel->priv->description)
1670 g_free (toplevel->priv->description);
1671 toplevel->priv->description = g_strdup (description)g_strdup_inline (description);
1672
1673 if (!toplevel->priv->name)
1674 gtk_window_set_title (GTK_WINDOW (toplevel)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_window_get_type ()))))))
,
1675 toplevel->priv->description);
1676
1677 panel_a11y_set_atk_name_desc (
1678 GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
,
1679 toplevel->priv->name ? toplevel->priv->name :
1680 toplevel->priv->description,
1681 toplevel->priv->description);
1682}
1683
1684static void panel_toplevel_update_attached_position(PanelToplevel* toplevel, gboolean hidden, int* x, int* y, int* w, int* h)
1685{
1686 GtkAllocation attach_allocation;
1687 PanelOrientation attach_orientation;
1688 GdkRectangle toplevel_box;
1689 GdkRectangle parent_box;
1690 GdkRectangle attach_box;
1691 int x_origin = 0, y_origin = 0;
1692 GdkRectangle monitor_geom;
1693
1694 if (!gtk_widget_get_realized (GTK_WIDGET (toplevel->priv->attach_toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->attach_toplevel)), ((gtk_widget_get_type
()))))))
) ||
1695 !gtk_widget_get_realized (toplevel->priv->attach_widget))
1696 return;
1697
1698 gtk_widget_get_allocation (GTK_WIDGET (toplevel->priv->attach_widget)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->attach_widget)), ((gtk_widget_get_type
()))))))
, &attach_allocation);
1699
1700 toplevel_box = toplevel->priv->geometry;
1701 parent_box = toplevel->priv->attach_toplevel->priv->geometry;
1702 attach_box = attach_allocation;
1703
1704 if (attach_box.x != -1) {
1705 gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (toplevel->priv->attach_widget)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->attach_widget)), ((gtk_widget_get_type
()))))))
),
1706 &x_origin, &y_origin);
1707
1708 attach_box.x += x_origin;
1709 attach_box.y += y_origin;
1710 } else {
1711 /* attach_widget isn't allocated. Put the toplevel
1712 * off screen.
1713 */
1714 attach_box.x = -toplevel_box.width;
1715 attach_box.y = -toplevel_box.height;
1716 }
1717
1718 attach_orientation = panel_toplevel_get_orientation (
1719 toplevel->priv->attach_toplevel);
1720
1721 if (attach_orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM))
1722 *x = attach_box.x + attach_box.width / 2 - toplevel_box.width / 2;
1723 else
1724 *y = attach_box.y + attach_box.height / 2 - toplevel_box.height / 2;
1725
1726 switch (attach_orientation) {
1727 case PANEL_ORIENTATION_TOP:
1728 *y = parent_box.y;
1729 if (!hidden)
1730 *y += parent_box.height;
1731 else
1732 *h = parent_box.height;
1733 break;
1734 case PANEL_ORIENTATION_BOTTOM:
1735 *y = parent_box.y;
1736 if (!hidden)
1737 *y -= toplevel_box.height;
1738 else
1739 *h = parent_box.height;
1740 break;
1741 case PANEL_ORIENTATION_LEFT:
1742 *x = parent_box.x;
1743 if (!hidden)
1744 *x += parent_box.width;
1745 else
1746 *w = parent_box.width;
1747 break;
1748 case PANEL_ORIENTATION_RIGHT:
1749 *x = parent_box.x;
1750 if (!hidden)
1751 *x -= toplevel_box.width;
1752 else
1753 *w = parent_box.width;
1754 break;
1755 default:
1756 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 1756, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1757 break;
1758 }
1759
1760 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
1761
1762 *x -= monitor_geom.x;
1763 *y -= monitor_geom.y;
1764
1765 if (toplevel->priv->orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT))
1766 *x = CLAMP (*x, 0, monitor_geom.width - toplevel->priv->original_width)(((*x) > (monitor_geom.width - toplevel->priv->original_width
)) ? (monitor_geom.width - toplevel->priv->original_width
) : (((*x) < (0)) ? (0) : (*x)))
;
1767 else
1768 *y = CLAMP (*y, 0, monitor_geom.height - toplevel->priv->original_height)(((*y) > (monitor_geom.height - toplevel->priv->original_height
)) ? (monitor_geom.height - toplevel->priv->original_height
) : (((*y) < (0)) ? (0) : (*y)))
;
1769}
1770
1771static void panel_toplevel_update_normal_position(PanelToplevel* toplevel, int* x, int* y, int* w, int* h)
1772{
1773 GdkRectangle monitor_geom;
1774 int width, height;
1775 int snap_tolerance;
1776
1777 g_assert (x != NULL && y != NULL)do { if (x != ((void*)0) && y != ((void*)0)) ; else g_assertion_message_expr
(((gchar*) 0), "panel-toplevel.c", 1777, ((const char*) (__func__
)), "x != NULL && y != NULL"); } while (0)
;
1778
1779 if (toplevel->priv->attached) {
1780 panel_toplevel_update_attached_position (toplevel, FALSE(0), x, y, w, h);
1781 return;
1782 }
1783
1784 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
1785
1786 width = toplevel->priv->original_width;
1787 height = toplevel->priv->original_height;
1788 snap_tolerance = toplevel->priv->snap_tolerance;
1789
1790 *x = CLAMP (*x, 0, monitor_geom.width - width)(((*x) > (monitor_geom.width - width)) ? (monitor_geom.width
- width) : (((*x) < (0)) ? (0) : (*x)))
;
1791 *y = CLAMP (*y, 0, monitor_geom.height - height)(((*y) > (monitor_geom.height - height)) ? (monitor_geom.height
- height) : (((*y) < (0)) ? (0) : (*y)))
;
1792
1793 if (toplevel->priv->x <= snap_tolerance &&
1794 toplevel->priv->x_right == -1 &&
1795 !toplevel->priv->x_centered)
1796 *x = 0;
1797 else if (toplevel->priv->x_right != -1 &&
1798 toplevel->priv->x_right <= snap_tolerance &&
1799 !toplevel->priv->x_centered)
1800 *x = monitor_geom.width - width;
1801
1802 if (toplevel->priv->y <= snap_tolerance &&
1803 toplevel->priv->y_bottom == -1 &&
1804 !toplevel->priv->y_centered)
1805 *y = 0;
1806 else if (toplevel->priv->y_bottom != -1 &&
1807 toplevel->priv->y_bottom <= snap_tolerance &&
1808 !toplevel->priv->y_centered)
1809 *y = monitor_geom.height - height;
1810}
1811
1812static void
1813panel_toplevel_update_auto_hide_position (PanelToplevel *toplevel,
1814 int *x,
1815 int *y,
1816 int *w,
1817 int *h,
1818 gboolean for_end_position)
1819{
1820 int width, height;
1821 GdkRectangle monitor_geom;
1822 int auto_hide_size;
1823 int snap_tolerance;
1824
1825 g_assert (x != NULL && y != NULL)do { if (x != ((void*)0) && y != ((void*)0)) ; else g_assertion_message_expr
(((gchar*) 0), "panel-toplevel.c", 1825, ((const char*) (__func__
)), "x != NULL && y != NULL"); } while (0)
;
1826
1827 if (toplevel->priv->floating) {
1828 panel_toplevel_update_normal_position (toplevel, x, y, w, h);
1829 return;
1830 }
1831
1832 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
1833
1834 width = toplevel->priv->original_width;
1835 height = toplevel->priv->original_height;
1836 snap_tolerance = toplevel->priv->snap_tolerance;
1837
1838 /* For the initial animation, we animate from outside the screen, and
1839 * so we don't want the toplevel to be visible at all. But when the
1840 * request is for the end position, then we give the real result (it's
1841 * useful for struts) */
1842 if (for_end_position || toplevel->priv->initial_animation_done) {
1843 auto_hide_size = panel_toplevel_get_effective_auto_hide_size (toplevel);
1844 } else {
1845 auto_hide_size = 0;
1846 }
1847
1848 switch (toplevel->priv->orientation) {
1849 case PANEL_ORIENTATION_TOP:
1850 *y = - (height - auto_hide_size);
1851 break;
1852 case PANEL_ORIENTATION_BOTTOM:
1853 *y = monitor_geom.height - auto_hide_size;
1854 break;
1855 case PANEL_ORIENTATION_LEFT:
1856 *x = - (width - auto_hide_size);
1857 break;
1858 case PANEL_ORIENTATION_RIGHT:
1859 *x = monitor_geom.width - auto_hide_size;
1860 break;
1861 default:
1862 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 1862, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1863 break;
1864 }
1865
1866 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)) {
1867 if (toplevel->priv->x <= snap_tolerance &&
1868 toplevel->priv->x_right == -1 &&
1869 !toplevel->priv->x_centered)
1870 *x = 0;
1871 else if (toplevel->priv->x_right != -1 &&
1872 toplevel->priv->x_right <= snap_tolerance &&
1873 !toplevel->priv->x_centered)
1874 *x = monitor_geom.width - width;
1875 } else /* if (toplevel->priv->orientation & PANEL_VERTICAL_MASK) */ {
1876 if (toplevel->priv->y <= snap_tolerance &&
1877 toplevel->priv->y_bottom == -1 &&
1878 !toplevel->priv->y_centered)
1879 *y = 0;
1880 else if (toplevel->priv->y_bottom != -1 &&
1881 toplevel->priv->y_bottom <= snap_tolerance &&
1882 !toplevel->priv->y_centered)
1883 *y = monitor_geom.height - height;
1884 }
1885}
1886
1887/* FIXME: this is wrong for Xinerama. In the Xinerama case
1888 * I think if hiding it requires it to go onto the
1889 * next monitor then it should just move it on to
1890 * the next monitor and set its state back to normal
1891 */
1892static void
1893panel_toplevel_update_hidden_position (PanelToplevel *toplevel,
1894 int *x,
1895 int *y,
1896 int *w,
1897 int *h)
1898{
1899 int width, height;
1900 int min_hide_size;
1901 GdkRectangle monitor_geom;
1902 GtkAllocation hide_allocation;
1903
1904 g_assert (x != NULL && y != NULL)do { if (x != ((void*)0) && y != ((void*)0)) ; else g_assertion_message_expr
(((gchar*) 0), "panel-toplevel.c", 1904, ((const char*) (__func__
)), "x != NULL && y != NULL"); } while (0)
;
1905
1906 g_assert (toplevel->priv->state == PANEL_STATE_HIDDEN_UP ||do { if (toplevel->priv->state == PANEL_STATE_HIDDEN_UP
|| toplevel->priv->state == PANEL_STATE_HIDDEN_DOWN ||
toplevel->priv->state == PANEL_STATE_HIDDEN_LEFT || toplevel
->priv->state == PANEL_STATE_HIDDEN_RIGHT) ; else g_assertion_message_expr
(((gchar*) 0), "panel-toplevel.c", 1909, ((const char*) (__func__
)), "toplevel->priv->state == PANEL_STATE_HIDDEN_UP || toplevel->priv->state == PANEL_STATE_HIDDEN_DOWN || toplevel->priv->state == PANEL_STATE_HIDDEN_LEFT || toplevel->priv->state == PANEL_STATE_HIDDEN_RIGHT"
); } while (0)
1907 toplevel->priv->state == PANEL_STATE_HIDDEN_DOWN ||do { if (toplevel->priv->state == PANEL_STATE_HIDDEN_UP
|| toplevel->priv->state == PANEL_STATE_HIDDEN_DOWN ||
toplevel->priv->state == PANEL_STATE_HIDDEN_LEFT || toplevel
->priv->state == PANEL_STATE_HIDDEN_RIGHT) ; else g_assertion_message_expr
(((gchar*) 0), "panel-toplevel.c", 1909, ((const char*) (__func__
)), "toplevel->priv->state == PANEL_STATE_HIDDEN_UP || toplevel->priv->state == PANEL_STATE_HIDDEN_DOWN || toplevel->priv->state == PANEL_STATE_HIDDEN_LEFT || toplevel->priv->state == PANEL_STATE_HIDDEN_RIGHT"
); } while (0)
1908 toplevel->priv->state == PANEL_STATE_HIDDEN_LEFT ||do { if (toplevel->priv->state == PANEL_STATE_HIDDEN_UP
|| toplevel->priv->state == PANEL_STATE_HIDDEN_DOWN ||
toplevel->priv->state == PANEL_STATE_HIDDEN_LEFT || toplevel
->priv->state == PANEL_STATE_HIDDEN_RIGHT) ; else g_assertion_message_expr
(((gchar*) 0), "panel-toplevel.c", 1909, ((const char*) (__func__
)), "toplevel->priv->state == PANEL_STATE_HIDDEN_UP || toplevel->priv->state == PANEL_STATE_HIDDEN_DOWN || toplevel->priv->state == PANEL_STATE_HIDDEN_LEFT || toplevel->priv->state == PANEL_STATE_HIDDEN_RIGHT"
); } while (0)
1909 toplevel->priv->state == PANEL_STATE_HIDDEN_RIGHT)do { if (toplevel->priv->state == PANEL_STATE_HIDDEN_UP
|| toplevel->priv->state == PANEL_STATE_HIDDEN_DOWN ||
toplevel->priv->state == PANEL_STATE_HIDDEN_LEFT || toplevel
->priv->state == PANEL_STATE_HIDDEN_RIGHT) ; else g_assertion_message_expr
(((gchar*) 0), "panel-toplevel.c", 1909, ((const char*) (__func__
)), "toplevel->priv->state == PANEL_STATE_HIDDEN_UP || toplevel->priv->state == PANEL_STATE_HIDDEN_DOWN || toplevel->priv->state == PANEL_STATE_HIDDEN_LEFT || toplevel->priv->state == PANEL_STATE_HIDDEN_RIGHT"
); } while (0)
;
1910
1911 if (toplevel->priv->attached) {
1912 panel_toplevel_update_attached_position (toplevel, TRUE(!(0)), x, y, w, h);
1913 return;
1914 }
1915
1916 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
1917
1918 width = toplevel->priv->original_width;
1919 height = toplevel->priv->original_height;
1920
1921 /* FIXME should find a better default */
1922 min_hide_size = DEFAULT_AUTO_HIDE_SIZE1;
1923
1924 switch (toplevel->priv->state) {
1925 case PANEL_STATE_HIDDEN_UP:
1926 gtk_widget_get_allocation (toplevel->priv->hide_button_bottom,
1927 &hide_allocation);
1928 *y = - (height - MAX (hide_allocation.height, min_hide_size)(((hide_allocation.height) > (min_hide_size)) ? (hide_allocation
.height) : (min_hide_size))
);
1929 break;
1930 case PANEL_STATE_HIDDEN_DOWN:
1931 gtk_widget_get_allocation (toplevel->priv->hide_button_top,
1932 &hide_allocation);
1933 *y = monitor_geom.height - MAX (hide_allocation.height, min_hide_size)(((hide_allocation.height) > (min_hide_size)) ? (hide_allocation
.height) : (min_hide_size))
;
1934 break;
1935 case PANEL_STATE_HIDDEN_LEFT:
1936 gtk_widget_get_allocation (toplevel->priv->hide_button_right,
1937 &hide_allocation);
1938 *x = - (width - MAX (hide_allocation.width, min_hide_size)(((hide_allocation.width) > (min_hide_size)) ? (hide_allocation
.width) : (min_hide_size))
);
1939 break;
1940 case PANEL_STATE_HIDDEN_RIGHT:
1941 gtk_widget_get_allocation (toplevel->priv->hide_button_left,
1942 &hide_allocation);
1943 *x = monitor_geom.width - MAX (hide_allocation.width, min_hide_size)(((hide_allocation.width) > (min_hide_size)) ? (hide_allocation
.width) : (min_hide_size))
;
1944 break;
1945 default:
1946 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 1946, ((const char*) (__func__)), ((void*)0)); } while (0)
;
1947 break;
1948 }
1949}
1950
1951/*
1952 * This is "almost" like the double sine movement
1953 * from the original panel except that it uses
1954 * a cubic (twice again). I suppose it looks less
1955 * mathematical now :) -- _v_
1956 */
1957static int
1958get_delta (int src,
1959 int dest,
1960 GTimeSpan elapsed_time,
1961 GTimeSpan duration_time)
1962{
1963 double x, percentage;
1964
1965 if (abs (dest - src) <= 1 || elapsed_time >= duration_time)
1966 return dest - src;
1967
1968 /* The cubic is: p(x) = (-2) x^2 (x-1.5) */
1969 /* running p(p(x)) to make it more "pronounced",
1970 * effectively making it a ninth-degree polynomial */
1971
1972 x = (double)elapsed_time/duration_time;
1973 x = -2 * (x*x) * (x-1.5);
1974 /* run it again */
1975 percentage = -2 * (x*x) * (x-1.5);
1976
1977 percentage = CLAMP (percentage, 0.0, 1.0)(((percentage) > (1.0)) ? (1.0) : (((percentage) < (0.0
)) ? (0.0) : (percentage)))
;
1978
1979 return ((dest - src) * percentage);
1980}
1981
1982static void
1983panel_toplevel_update_animating_position (PanelToplevel *toplevel)
1984{
1985 GTimeSpan animation_elapsed_time;
1986 int deltax, deltay, deltaw = 0, deltah = 0;
1987 int monitor_offset_x, monitor_offset_y;
1988
1989 if ((toplevel->priv->animation_start_time <= 0) ||
1990 (toplevel->priv->animation_duration_time <= 0))
1991 return;
1992
1993 animation_elapsed_time = g_get_monotonic_time () - toplevel->priv->animation_start_time;
1994
1995 monitor_offset_x = panel_multimonitor_x (toplevel->priv->monitor);
1996 monitor_offset_y = panel_multimonitor_y (toplevel->priv->monitor);
1997
1998 if (toplevel->priv->animation_end_width != -1)
1999 deltaw = get_delta (toplevel->priv->geometry.width,
2000 toplevel->priv->animation_end_width,
2001 animation_elapsed_time,
2002 toplevel->priv->animation_duration_time);
2003
2004 if (toplevel->priv->animation_end_height != -1)
2005 deltah = get_delta (toplevel->priv->geometry.height,
2006 toplevel->priv->animation_end_height,
2007 animation_elapsed_time,
2008 toplevel->priv->animation_duration_time);
2009
2010 deltax = get_delta (toplevel->priv->geometry.x - monitor_offset_x,
2011 toplevel->priv->animation_end_x,
2012 animation_elapsed_time,
2013 toplevel->priv->animation_duration_time);
2014
2015 deltay = get_delta (toplevel->priv->geometry.y - monitor_offset_y,
2016 toplevel->priv->animation_end_y,
2017 animation_elapsed_time,
2018 toplevel->priv->animation_duration_time);
2019
2020 if (deltaw != 0 && abs (deltaw) > abs (deltax))
2021 deltax = deltaw;
2022 if (deltah != 0 && abs (deltah) > abs (deltay))
2023 deltay = deltah;
2024
2025 toplevel->priv->geometry.x += deltax;
2026 toplevel->priv->geometry.y += deltay;
2027
2028 toplevel->priv->geometry.width += deltaw;
2029 toplevel->priv->geometry.height += deltah;
2030
2031 if (toplevel->priv->geometry.x - monitor_offset_x == toplevel->priv->animation_end_x &&
2032 toplevel->priv->geometry.y - monitor_offset_y == toplevel->priv->animation_end_y) {
2033 toplevel->priv->animating = FALSE(0);
2034 /* Note: it's important to set initial_animation_done to TRUE
2035 * as soon as possible (hence, here) since we don't want to
2036 * have a wrong value in a size request event */
2037 toplevel->priv->initial_animation_done = TRUE(!(0));
2038
2039 if (toplevel->priv->attached && panel_toplevel_get_is_hidden (toplevel))
2040 gtk_widget_unmap (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
2041 else
2042 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
2043
2044 if (toplevel->priv->state == PANEL_STATE_NORMAL)
2045 g_signal_emit (toplevel, toplevel_signals [UNHIDE_SIGNAL], 0);
2046 }
2047}
2048
2049static void
2050panel_toplevel_update_expanded_position (PanelToplevel *toplevel)
2051{
2052 GdkRectangle monitor_geom;
2053 int x, y;
2054 int x_right, y_bottom;
2055 int monitor;
2056
2057 if (!toplevel->priv->expand)
2058 return;
2059
2060 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
2061
2062 x = -1;
2063 y = -1;
Value stored to 'y' is never read
2064 x_right = -1;
2065 y_bottom = -1;
2066
2067 switch (toplevel->priv->orientation) {
2068 case PANEL_ORIENTATION_TOP:
2069 x = monitor_geom.x;
2070 y = monitor_geom.y;
2071 break;
2072 case PANEL_ORIENTATION_LEFT:
2073 x = monitor_geom.x;
2074 y = monitor_geom.y;
2075 break;
2076 case PANEL_ORIENTATION_BOTTOM:
2077 x = monitor_geom.x;
2078 y = monitor_geom.y + monitor_geom.height - toplevel->priv->geometry.height;
2079 y_bottom = 0;
2080 break;
2081 case PANEL_ORIENTATION_RIGHT:
2082 x = monitor_geom.x + monitor_geom.width - toplevel->priv->geometry.width;
2083 y = monitor_geom.y;
2084 x_right = 0;
2085 break;
2086 default:
2087 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 2087, ((const char*) (__func__)), ((void*)0)); } while (0)
;
2088 break;
2089 }
2090
2091 monitor = panel_multimonitor_get_monitor_at_point (x, y);
2092
2093 panel_toplevel_set_monitor_internal (toplevel, monitor, TRUE(!(0)));
2094
2095 x -= panel_multimonitor_x (monitor);
2096 y -= panel_multimonitor_y (monitor);
2097
2098 g_object_freeze_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
);
2099
2100 if (toplevel->priv->x != x) {
2101 toplevel->priv->x = x;
2102 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "x");
2103 }
2104
2105 if (toplevel->priv->y != y) {
2106 toplevel->priv->y = y;
2107 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "y");
2108 }
2109
2110 if (toplevel->priv->x_right != x_right) {
2111 toplevel->priv->x_right = x_right;
2112 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "x_right");
2113 }
2114
2115 if (toplevel->priv->y_bottom != y_bottom) {
2116 toplevel->priv->y_bottom = y_bottom;
2117 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "y_bottom");
2118 }
2119
2120 g_object_thaw_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
);
2121}
2122
2123static void
2124panel_toplevel_update_position (PanelToplevel *toplevel)
2125{
2126 PanelBackground *background;
2127 int x, y;
2128 int w, h;
2129 GdkRectangle monitor_geom;
2130
2131 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
2132
2133 if (toplevel->priv->animating) {
2134 panel_toplevel_update_animating_position (toplevel);
2135 return;
2136 }
2137
2138 if (toplevel->priv->position_centered) {
2139 toplevel->priv->position_centered = FALSE(0);
2140
2141 g_object_freeze_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
);
2142
2143 if (!toplevel->priv->x_centered) {
2144 int x_right;
2145
2146 toplevel->priv->x -= toplevel->priv->geometry.width / 2;
2147 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "x");
2148
2149 if ((toplevel->priv->x + toplevel->priv->geometry.width / 2) > monitor_geom.width / 2)
2150 x_right = monitor_geom.width - (toplevel->priv->x + toplevel->priv->geometry.width);
2151 else
2152 x_right = -1;
2153 if (toplevel->priv->x_right != x_right) {
2154 toplevel->priv->x_right = x_right;
2155 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
,
2156 "x-right");
2157 }
2158 }
2159
2160 if (!toplevel->priv->y_centered) {
2161 int y_bottom;
2162
2163 toplevel->priv->y -= toplevel->priv->geometry.height / 2;
2164 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "y");
2165
2166 if ((toplevel->priv->y + toplevel->priv->geometry.height / 2) > monitor_geom.height / 2)
2167 y_bottom = monitor_geom.height - (toplevel->priv->y + toplevel->priv->geometry.height);
2168 else
2169 y_bottom = -1;
2170 if (toplevel->priv->y_bottom != y_bottom) {
2171 toplevel->priv->y_bottom = y_bottom;
2172 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
,
2173 "y-bottom");
2174 }
2175 }
2176
2177 g_object_thaw_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
);
2178 }
2179
2180 panel_toplevel_update_expanded_position (toplevel);
2181 panel_toplevel_calc_floating (toplevel); /* FIXME should probably be done after panel_toplevel_update_normal_position() too */
2182
2183 if (toplevel->priv->x_right == -1)
2184 x = toplevel->priv->x;
2185 else
2186 x = monitor_geom.width - (toplevel->priv->x_right + toplevel->priv->geometry.width);
2187 if (toplevel->priv->y_bottom == -1)
2188 y = toplevel->priv->y;
2189 else
2190 y = monitor_geom.height - (toplevel->priv->y_bottom + toplevel->priv->geometry.height);
2191
2192 if (!toplevel->priv->expand) {
2193 if (toplevel->priv->x_centered)
2194 x = (monitor_geom.width - toplevel->priv->geometry.width) / 2;
2195 if (toplevel->priv->y_centered)
2196 y = (monitor_geom.height - toplevel->priv->geometry.height) / 2;
2197 }
2198
2199 w = h = -1;
2200
2201 if (toplevel->priv->state == PANEL_STATE_NORMAL)
2202 panel_toplevel_update_normal_position (toplevel, &x, &y, &w, &h);
2203
2204 else if (toplevel->priv->state == PANEL_STATE_AUTO_HIDDEN)
2205 panel_toplevel_update_auto_hide_position (toplevel, &x, &y, &w, &h, FALSE(0));
2206
2207 else
2208 panel_toplevel_update_hidden_position (toplevel, &x, &y, &w, &h);
2209
2210 if (w != -1)
2211 toplevel->priv->geometry.width = w;
2212 if (h != -1)
2213 toplevel->priv->geometry.height = h;
2214
2215 /* This is some kind of snap: there's a possibility of an infinite loop
2216 * because of the bevels of the frame that are set in
2217 * panel_toplevel_update_edges(). The bevels change the width/height of
2218 * the toplevel. The typical loop is:
2219 * x = 1 => outer bevel => x = 0 => no outer bevel = > x = 1 => ...
2220 * FIXME: maybe the real bug is that we enter into this loop (see bug
2221 * #160748 to learn how to reproduce.) */
2222 background = &toplevel->background;
2223
2224 /* There's no bevels with a color/image background */
2225 if (panel_background_effective_type (background) == PANEL_BACK_NONE) {
2226 GtkStyleContext *context;
2227 GtkStateFlags state;
2228 GdkRectangle *geometry;
2229 GtkBorder padding;
2230 int max_size;
2231
2232 state = gtk_widget_get_state_flags (GTK_WIDGET (toplevel->priv->inner_frame)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->inner_frame)), ((gtk_widget_get_type
()))))))
);
2233 context = gtk_widget_get_style_context (GTK_WIDGET (toplevel->priv->inner_frame)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->inner_frame)), ((gtk_widget_get_type
()))))))
);
2234 gtk_style_context_get_padding (context, state, &padding);
2235 geometry = &toplevel->priv->geometry;
2236
2237 if (x <= padding.left && x > 0 &&
2238 !toplevel->priv->x_centered)
2239 x = 0;
2240
2241 if (y <= padding.top && y > 0 &&
2242 !toplevel->priv->y_centered)
2243 y = 0;
2244
2245 max_size = monitor_geom.width - geometry->width - padding.right;
2246 if (x + padding.left >= max_size && x < max_size &&
2247 !toplevel->priv->x_centered)
2248 x = max_size;
2249
2250 max_size = monitor_geom.height - geometry->height - padding.bottom;
2251 if (y + padding.top >= max_size && y < max_size &&
2252 !toplevel->priv->y_centered)
2253 y = max_size;
2254 }
2255
2256 x += panel_multimonitor_x (toplevel->priv->monitor);
2257 y += panel_multimonitor_y (toplevel->priv->monitor);
2258
2259 toplevel->priv->geometry.x = x;
2260 toplevel->priv->geometry.y = y;
2261}
2262
2263static int
2264calculate_minimum_height (GtkWidget *widget,
2265 PanelOrientation orientation)
2266{
2267 GtkStateFlags state;
2268 GtkStyleContext *style_context;
2269 PangoFontDescription *font_desc;
2270 GtkBorder padding;
2271 PangoContext *pango_context;
2272 PangoFontMetrics *metrics;
2273 int ascent;
2274 int descent;
2275 int thickness;
2276
2277 state = gtk_widget_get_state_flags (widget);
2278 style_context = gtk_widget_get_style_context (widget);
2279 gtk_style_context_get(style_context, state, GTK_STYLE_PROPERTY_FONT"font", &font_desc, NULL((void*)0));
2280
2281 pango_context = gtk_widget_get_pango_context (widget);
2282 metrics = pango_context_get_metrics (pango_context,
2283 font_desc,
2284 pango_context_get_language (pango_context));
2285 gtk_style_context_get_padding (style_context, state, &padding);
2286
2287 ascent = pango_font_metrics_get_ascent (metrics);
2288 descent = pango_font_metrics_get_descent (metrics);
2289
2290 pango_font_description_free (font_desc);
2291 pango_font_metrics_unref (metrics);
2292
2293 thickness = (orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)) ?
2294 padding.top + padding.bottom :
2295 padding.left + padding.right;
2296
2297 return PANGO_PIXELS (ascent + descent)(((int)(ascent + descent) + 512) >> 10) + thickness;
2298}
2299
2300static int
2301panel_toplevel_update_size_from_hints (PanelToplevel *toplevel,
2302 int requisition_size,
2303 int monitor_size,
2304 int non_panel_widget_size)
2305{
2306 int nb_size_hints;
2307 AppletSizeHints *applets_hints;
2308 AppletSizeHintsAlloc *using_hint;
2309
2310 int i;
2311 int total_size;
2312 int full_hints;
2313
2314 /* Scale down the size so that the panel only takes what it needs for the applets it has. */
2315 total_size = non_panel_widget_size + (requisition_size / toplevel->priv->scale);
2316
2317 nb_size_hints = toplevel->priv->panel_widget->nb_applets_size_hints;
2318 if (nb_size_hints <= 0)
2319 return total_size;
2320
2321 applets_hints = toplevel->priv->panel_widget->applets_hints;
2322 using_hint = toplevel->priv->panel_widget->applets_using_hint;
2323
2324 for (i = 0; i < nb_size_hints; i++) {
2325 using_hint[i].index = applets_hints[i].len - 2;
2326 using_hint[i].size = applets_hints[i].hints[applets_hints[i].len - 1];
2327 total_size += using_hint[i].size;
2328 }
2329
2330 if (total_size > monitor_size)
2331 return monitor_size;
2332
2333 full_hints = 0;
2334 while (full_hints != nb_size_hints && total_size < monitor_size) {
2335 int bonus;
2336 int extra_bonus;
2337
2338 bonus = (monitor_size - total_size)
2339 / (nb_size_hints - full_hints);
2340 extra_bonus = (monitor_size - total_size)
2341 % (nb_size_hints - full_hints);
2342 full_hints = 0;
2343
2344 for (i = 0; i < nb_size_hints; i++) {
2345 int new_size;
2346 int current_bonus;
2347
2348 current_bonus = bonus;
2349
2350 while (using_hint[i].index > 0 && applets_hints[i].hints[using_hint[i].index - 1] < using_hint[i].size + current_bonus) {
2351 new_size = applets_hints[i].hints[using_hint[i].index - 1];
2352 current_bonus = using_hint[i].size
2353 + current_bonus - new_size;
2354 total_size = total_size - using_hint[i].size
2355 + new_size;
2356
2357 using_hint[i].index -= 2;
2358 using_hint[i].size = new_size;
2359 }
2360
2361 new_size = MIN (applets_hints[i].hints[using_hint[i].index],(((applets_hints[i].hints[using_hint[i].index]) < (using_hint
[i].size + current_bonus)) ? (applets_hints[i].hints[using_hint
[i].index]) : (using_hint[i].size + current_bonus))
2362 using_hint[i].size + current_bonus)(((applets_hints[i].hints[using_hint[i].index]) < (using_hint
[i].size + current_bonus)) ? (applets_hints[i].hints[using_hint
[i].index]) : (using_hint[i].size + current_bonus))
;
2363 if (new_size > using_hint[i].size) {
2364 total_size += (new_size - using_hint[i].size);
2365 using_hint[i].size = new_size;
2366 }
2367
2368 if (extra_bonus > 0) {
2369 new_size = MIN (applets_hints[i].hints[using_hint[i].index],(((applets_hints[i].hints[using_hint[i].index]) < (using_hint
[i].size + extra_bonus)) ? (applets_hints[i].hints[using_hint
[i].index]) : (using_hint[i].size + extra_bonus))
2370 using_hint[i].size + extra_bonus)(((applets_hints[i].hints[using_hint[i].index]) < (using_hint
[i].size + extra_bonus)) ? (applets_hints[i].hints[using_hint
[i].index]) : (using_hint[i].size + extra_bonus))
;
2371 if (new_size > using_hint[i].size) {
2372 total_size += (new_size
2373 - using_hint[i].size);
2374 extra_bonus -= (new_size
2375 - using_hint[i].size);
2376 using_hint[i].size = new_size;
2377 }
2378 }
2379
2380 if (using_hint[i].size == applets_hints[i].hints[using_hint[i].index])
2381 full_hints++;
2382 }
2383 }
2384
2385 return total_size;
2386}
2387
2388static void
2389panel_toplevel_update_size (PanelToplevel *toplevel,
2390 GtkRequisition *requisition)
2391{
2392 GtkWidget *widget;
2393 GtkStyleContext *context;
2394 GtkStateFlags state;
2395 GtkBorder padding;
2396 GdkRectangle monitor_geom;
2397 int width, height;
2398 int minimum_height;
2399 int non_panel_widget_size;
2400
2401 if (toplevel->priv->animating)
2402 return;
2403
2404 widget = GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
;
2405 context = gtk_widget_get_style_context (widget);
2406 state = gtk_widget_get_state_flags (widget);
2407 gtk_style_context_get_padding (context, state, &padding);
2408
2409 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
2410
2411 width = requisition->width;
2412 height = requisition->height;
2413
2414 if (!toplevel->priv->expand &&
2415 !toplevel->priv->buttons_enabled && !toplevel->priv->attached)
2416 non_panel_widget_size = 2 * HANDLE_SIZE10;
2417 else
2418 non_panel_widget_size = 0;
2419
2420 minimum_height = calculate_minimum_height (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
,
2421 toplevel->priv->orientation);
2422
2423 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)) {
2424
2425 height = MAX (MIN (MAX (height, toplevel->priv->size),(((((((((height) > (toplevel->priv->size)) ? (height
) : (toplevel->priv->size))) < (panel_toplevel_get_maximum_size
(toplevel))) ? ((((height) > (toplevel->priv->size)
) ? (height) : (toplevel->priv->size))) : (panel_toplevel_get_maximum_size
(toplevel)))) > (minimum_height)) ? (((((((height) > (
toplevel->priv->size)) ? (height) : (toplevel->priv->
size))) < (panel_toplevel_get_maximum_size (toplevel))) ? (
(((height) > (toplevel->priv->size)) ? (height) : (toplevel
->priv->size))) : (panel_toplevel_get_maximum_size (toplevel
)))) : (minimum_height))
2426 panel_toplevel_get_maximum_size (toplevel)),(((((((((height) > (toplevel->priv->size)) ? (height
) : (toplevel->priv->size))) < (panel_toplevel_get_maximum_size
(toplevel))) ? ((((height) > (toplevel->priv->size)
) ? (height) : (toplevel->priv->size))) : (panel_toplevel_get_maximum_size
(toplevel)))) > (minimum_height)) ? (((((((height) > (
toplevel->priv->size)) ? (height) : (toplevel->priv->
size))) < (panel_toplevel_get_maximum_size (toplevel))) ? (
(((height) > (toplevel->priv->size)) ? (height) : (toplevel
->priv->size))) : (panel_toplevel_get_maximum_size (toplevel
)))) : (minimum_height))
2427 minimum_height)(((((((((height) > (toplevel->priv->size)) ? (height
) : (toplevel->priv->size))) < (panel_toplevel_get_maximum_size
(toplevel))) ? ((((height) > (toplevel->priv->size)
) ? (height) : (toplevel->priv->size))) : (panel_toplevel_get_maximum_size
(toplevel)))) > (minimum_height)) ? (((((((height) > (
toplevel->priv->size)) ? (height) : (toplevel->priv->
size))) < (panel_toplevel_get_maximum_size (toplevel))) ? (
(((height) > (toplevel->priv->size)) ? (height) : (toplevel
->priv->size))) : (panel_toplevel_get_maximum_size (toplevel
)))) : (minimum_height))
;
2428
2429 if (toplevel->priv->expand)
2430 width = monitor_geom.width;
2431 else {
2432 int max_width;
2433
2434 if (!toplevel->priv->attached)
2435 max_width = monitor_geom.width;
2436 else {
2437 if (panel_toplevel_get_orientation (toplevel->priv->attach_toplevel) == PANEL_ORIENTATION_LEFT)
2438 max_width = monitor_geom.width
2439 - toplevel->priv->geometry.x;
2440 else
2441 max_width = toplevel->priv->geometry.x +
2442 toplevel->priv->geometry.width;
2443 }
2444
2445 width = panel_toplevel_update_size_from_hints (
2446 toplevel,
2447 requisition->width,
2448 max_width,
2449 non_panel_widget_size);
2450 }
2451
2452 width = MAX (MINIMUM_WIDTH, width)(((100) > (width)) ? (100) : (width));
2453 } else {
2454 width = MAX (MIN (MAX (width, toplevel->priv->size),(((((((((width) > (toplevel->priv->size)) ? (width) :
(toplevel->priv->size))) < (panel_toplevel_get_maximum_size
(toplevel))) ? ((((width) > (toplevel->priv->size))
? (width) : (toplevel->priv->size))) : (panel_toplevel_get_maximum_size
(toplevel)))) > (minimum_height)) ? (((((((width) > (toplevel
->priv->size)) ? (width) : (toplevel->priv->size)
)) < (panel_toplevel_get_maximum_size (toplevel))) ? ((((width
) > (toplevel->priv->size)) ? (width) : (toplevel->
priv->size))) : (panel_toplevel_get_maximum_size (toplevel
)))) : (minimum_height))
2455 panel_toplevel_get_maximum_size (toplevel)),(((((((((width) > (toplevel->priv->size)) ? (width) :
(toplevel->priv->size))) < (panel_toplevel_get_maximum_size
(toplevel))) ? ((((width) > (toplevel->priv->size))
? (width) : (toplevel->priv->size))) : (panel_toplevel_get_maximum_size
(toplevel)))) > (minimum_height)) ? (((((((width) > (toplevel
->priv->size)) ? (width) : (toplevel->priv->size)
)) < (panel_toplevel_get_maximum_size (toplevel))) ? ((((width
) > (toplevel->priv->size)) ? (width) : (toplevel->
priv->size))) : (panel_toplevel_get_maximum_size (toplevel
)))) : (minimum_height))
2456 minimum_height)(((((((((width) > (toplevel->priv->size)) ? (width) :
(toplevel->priv->size))) < (panel_toplevel_get_maximum_size
(toplevel))) ? ((((width) > (toplevel->priv->size))
? (width) : (toplevel->priv->size))) : (panel_toplevel_get_maximum_size
(toplevel)))) > (minimum_height)) ? (((((((width) > (toplevel
->priv->size)) ? (width) : (toplevel->priv->size)
)) < (panel_toplevel_get_maximum_size (toplevel))) ? ((((width
) > (toplevel->priv->size)) ? (width) : (toplevel->
priv->size))) : (panel_toplevel_get_maximum_size (toplevel
)))) : (minimum_height))
;
2457
2458 if (toplevel->priv->expand)
2459 height = monitor_geom.height;
2460 else {
2461 int max_height;
2462
2463 if (!toplevel->priv->attached)
2464 max_height = monitor_geom.height;
2465 else {
2466 if (panel_toplevel_get_orientation (toplevel->priv->attach_toplevel) == PANEL_ORIENTATION_TOP)
2467 max_height = monitor_geom.height
2468 - toplevel->priv->geometry.y;
2469 else
2470 max_height = toplevel->priv->geometry.y +
2471 toplevel->priv->geometry.height;
2472 }
2473
2474 height = panel_toplevel_update_size_from_hints (
2475 toplevel,
2476 requisition->height,
2477 max_height,
2478 non_panel_widget_size);
2479 }
2480
2481 height = MAX (MINIMUM_WIDTH, height)(((100) > (height)) ? (100) : (height));
2482 }
2483
2484 if (toplevel->priv->edges & PANEL_EDGE_TOP)
2485 height += padding.top;
2486 if (toplevel->priv->edges & PANEL_EDGE_BOTTOM)
2487 height += padding.bottom;
2488 if (toplevel->priv->edges & PANEL_EDGE_LEFT)
2489 width += padding.left;
2490 if (toplevel->priv->edges & PANEL_EDGE_RIGHT)
2491 width += padding.right;
2492
2493 toplevel->priv->geometry.width = CLAMP (width, 0, monitor_geom.width)(((width) > (monitor_geom.width)) ? (monitor_geom.width) :
(((width) < (0)) ? (0) : (width)))
;
2494 toplevel->priv->geometry.height = CLAMP (height, 0, monitor_geom.height)(((height) > (monitor_geom.height)) ? (monitor_geom.height
) : (((height) < (0)) ? (0) : (height)))
;
2495 toplevel->priv->original_width = toplevel->priv->geometry.width;
2496 toplevel->priv->original_height = toplevel->priv->geometry.height;
2497}
2498
2499static void
2500panel_toplevel_update_geometry (PanelToplevel *toplevel,
2501 GtkRequisition *requisition)
2502{
2503 toplevel->priv->updated_geometry_initial = TRUE(!(0));
2504 panel_toplevel_update_size (toplevel, requisition);
2505 panel_toplevel_update_position (toplevel);
2506
2507 panel_toplevel_update_struts (toplevel, FALSE(0));
2508
2509#ifdef HAVE_X111
2510 if (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel)))(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gtk_widget_get_display (((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((toplevel)), ((gtk_widget_get_type ()))))
))))); GType __t = ((gdk_x11_display_get_type())); gboolean __r
; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
) {
2511 if (toplevel->priv->state == PANEL_STATE_NORMAL ||
2512 toplevel->priv->state != PANEL_STATE_AUTO_HIDDEN) {
2513 panel_struts_update_toplevel_geometry (toplevel,
2514 &toplevel->priv->geometry.x,
2515 &toplevel->priv->geometry.y,
2516 &toplevel->priv->geometry.width,
2517 &toplevel->priv->geometry.height);
2518 } else {
2519 panel_struts_update_toplevel_geometry (toplevel,
2520 &toplevel->priv->geometry.x,
2521 &toplevel->priv->geometry.y,
2522 NULL((void*)0), NULL((void*)0));
2523 }
2524 }
2525#endif /* HAVE_X11 */
2526
2527 panel_toplevel_update_edges (toplevel);
2528 panel_toplevel_update_description (toplevel);
2529}
2530
2531static void
2532panel_toplevel_attach_widget_destroyed (PanelToplevel *toplevel)
2533{
2534 panel_toplevel_detach (toplevel);
2535}
2536
2537static gboolean
2538panel_toplevel_attach_widget_configure (PanelToplevel *toplevel)
2539{
2540 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
2541
2542 return FALSE(0);
2543}
2544
2545static void
2546panel_toplevel_update_attach_orientation (PanelToplevel *toplevel)
2547{
2548 PanelOrientation attach_orientation;
2549 PanelOrientation orientation;
2550
2551 attach_orientation =
2552 panel_toplevel_get_orientation (toplevel->priv->attach_toplevel);
2553
2554 orientation = toplevel->priv->orientation;
2555
2556 switch (attach_orientation) {
2557 case PANEL_ORIENTATION_TOP:
2558 orientation = PANEL_ORIENTATION_LEFT;
2559 break;
2560 case PANEL_ORIENTATION_BOTTOM:
2561 orientation = PANEL_ORIENTATION_RIGHT;
2562 break;
2563 case PANEL_ORIENTATION_LEFT:
2564 orientation = PANEL_ORIENTATION_TOP;
2565 break;
2566 case PANEL_ORIENTATION_RIGHT:
2567 orientation = PANEL_ORIENTATION_BOTTOM;
2568 break;
2569 default:
2570 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 2570, ((const char*) (__func__)), ((void*)0)); } while (0)
;
2571 break;
2572 }
2573
2574 panel_toplevel_set_orientation (toplevel, orientation);
2575}
2576
2577static void
2578panel_toplevel_attach_widget_parent_set (PanelToplevel *toplevel,
2579 GtkWidget *previous_parent,
2580 GtkWidget *attach_widget)
2581{
2582 GtkWidget *panel_widget;
2583
2584 panel_widget = gtk_widget_get_parent (GTK_WIDGET (attach_widget)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((attach_widget)), ((gtk_widget_get_type ()))))))
);
2585 if (!panel_widget)
2586 return;
2587
2588 g_assert (PANEL_IS_WIDGET (panel_widget))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((panel_widget)); GType __t = ((panel_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_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 2588, ((const char*) (__func__)), "PANEL_IS_WIDGET (panel_widget)"
); } while (0)
;
2589
2590 toplevel->priv->attach_toplevel = PANEL_WIDGET (panel_widget)((((PanelWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((panel_widget)), ((panel_widget_get_type()))))))
->toplevel;
2591 panel_toplevel_update_attach_orientation (toplevel);
2592 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
2593}
2594
2595static void
2596panel_toplevel_attach_toplevel_hiding (PanelToplevel *toplevel)
2597{
2598 if (!panel_toplevel_get_is_hidden (toplevel)) {
2599 panel_toplevel_hide (toplevel, FALSE(0), -1);
2600
2601 toplevel->priv->attach_hidden = TRUE(!(0));
2602 }
2603}
2604
2605static void
2606panel_toplevel_attach_toplevel_unhiding (PanelToplevel *toplevel)
2607{
2608 if (!toplevel->priv->attach_hidden)
2609 return;
2610
2611 toplevel->priv->attach_hidden = FALSE(0);
2612
2613 panel_toplevel_unhide (toplevel);
2614}
2615
2616static void
2617panel_toplevel_reverse_arrow (PanelToplevel *toplevel,
2618 GtkWidget *button)
2619{
2620 GtkArrowType arrow_type;
2621
2622 arrow_type = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button), "arrow-type"))((gint) (glong) (g_object_get_data (((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((button)), (((GType) ((20) << (2)))
))))), "arrow-type")))
;
2623
2624 switch (arrow_type) {
2625 case GTK_ARROW_UP:
2626 arrow_type = GTK_ARROW_DOWN;
2627 break;
2628 case GTK_ARROW_DOWN:
2629 arrow_type = GTK_ARROW_UP;
2630 break;
2631 case GTK_ARROW_LEFT:
2632 arrow_type = GTK_ARROW_RIGHT;
2633 break;
2634 case GTK_ARROW_RIGHT:
2635 arrow_type = GTK_ARROW_LEFT;
2636 break;
2637 default:
2638 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 2638, ((const char*) (__func__)), ((void*)0)); } while (0)
;
2639 break;
2640 }
2641
2642 g_object_set_data (G_OBJECT (button)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), (((GType) ((20) << (2))))))))
, "arrow-type", GINT_TO_POINTER (arrow_type)((gpointer) (glong) (arrow_type)));
2643
2644 set_arrow_type (GTK_IMAGE (gtk_bin_get_child (GTK_BIN (button)))((((GtkImage*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_bin_get_child (((((GtkBin*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((button)), ((gtk_bin_get_type ())))))))))
, ((gtk_image_get_type ()))))))
, arrow_type);
2645}
2646
2647static void
2648panel_toplevel_reverse_arrows (PanelToplevel *toplevel)
2649{
2650 panel_toplevel_reverse_arrow (toplevel, toplevel->priv->hide_button_top);
2651 panel_toplevel_reverse_arrow (toplevel, toplevel->priv->hide_button_bottom);
2652 panel_toplevel_reverse_arrow (toplevel, toplevel->priv->hide_button_left);
2653 panel_toplevel_reverse_arrow (toplevel, toplevel->priv->hide_button_right);
2654}
2655
2656static void
2657panel_toplevel_disconnect_attached (PanelToplevel *toplevel)
2658{
2659 guint i;
2660
2661#if GLIB_CHECK_VERSION(2,62,0)(2 > (2) || (2 == (2) && 80 > (62)) || (2 == (2
) && 80 == (62) && 2 >= (0)))
2662 for (i = 0; i < N_ATTACH_TOPLEVEL_SIGNALS5; i++) {
2663 g_clear_signal_handler (&toplevel->priv->attach_toplevel_signals [i],do { gpointer const _instance = (toplevel->priv->attach_toplevel
); gulong *const _handler_id_ptr = (&toplevel->priv->
attach_toplevel_signals [i]); const gulong _handler_id = *_handler_id_ptr
; if (_handler_id > 0) { *_handler_id_ptr = 0; g_signal_handler_disconnect
(_instance, _handler_id); } } while (0)
2664 toplevel->priv->attach_toplevel)do { gpointer const _instance = (toplevel->priv->attach_toplevel
); gulong *const _handler_id_ptr = (&toplevel->priv->
attach_toplevel_signals [i]); const gulong _handler_id = *_handler_id_ptr
; if (_handler_id > 0) { *_handler_id_ptr = 0; g_signal_handler_disconnect
(_instance, _handler_id); } } while (0)
;
2665 }
2666
2667 for (i = 0; i < N_ATTACH_WIDGET_SIGNALS5; i++) {
2668 g_clear_signal_handler (&toplevel->priv->attach_widget_signals [i],do { gpointer const _instance = (toplevel->priv->attach_widget
); gulong *const _handler_id_ptr = (&toplevel->priv->
attach_widget_signals [i]); const gulong _handler_id = *_handler_id_ptr
; if (_handler_id > 0) { *_handler_id_ptr = 0; g_signal_handler_disconnect
(_instance, _handler_id); } } while (0)
2669 toplevel->priv->attach_widget)do { gpointer const _instance = (toplevel->priv->attach_widget
); gulong *const _handler_id_ptr = (&toplevel->priv->
attach_widget_signals [i]); const gulong _handler_id = *_handler_id_ptr
; if (_handler_id > 0) { *_handler_id_ptr = 0; g_signal_handler_disconnect
(_instance, _handler_id); } } while (0)
;
2670 }
2671#else
2672 for (i = 0; i < N_ATTACH_TOPLEVEL_SIGNALS5; i++) {
2673 if (toplevel->priv->attach_toplevel_signals [i] != 0) {
2674 g_signal_handler_disconnect (toplevel->priv->attach_toplevel,
2675 toplevel->priv->attach_toplevel_signals [i]);
2676 toplevel->priv->attach_toplevel_signals [i] = 0;
2677 }
2678 }
2679
2680 for (i = 0; i < N_ATTACH_WIDGET_SIGNALS5; i++) {
2681 if (toplevel->priv->attach_widget_signals [i] != 0) {
2682 g_signal_handler_disconnect (toplevel->priv->attach_widget,
2683 toplevel->priv->attach_widget_signals [i]);
2684 toplevel->priv->attach_widget_signals [i] = 0;
2685 }
2686 }
2687#endif
2688}
2689
2690static void
2691panel_toplevel_connect_attached (PanelToplevel *toplevel)
2692{
2693 gulong *signals;
2694 int i = 0;
2695
2696 signals = toplevel->priv->attach_toplevel_signals;
2697
2698 signals [i++] = g_signal_connect_swapped (g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("destroy"), (((GCallback) (panel_toplevel_attach_widget_destroyed
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2699 toplevel->priv->attach_toplevel, "destroy",g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("destroy"), (((GCallback) (panel_toplevel_attach_widget_destroyed
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2700 G_CALLBACK (panel_toplevel_attach_widget_destroyed), toplevel)g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("destroy"), (((GCallback) (panel_toplevel_attach_widget_destroyed
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
;
2701 signals [i++] = g_signal_connect_swapped (g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("notify::orientation"), (((GCallback) (panel_toplevel_update_attach_orientation
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2702 toplevel->priv->attach_toplevel, "notify::orientation",g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("notify::orientation"), (((GCallback) (panel_toplevel_update_attach_orientation
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2703 G_CALLBACK (panel_toplevel_update_attach_orientation), toplevel)g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("notify::orientation"), (((GCallback) (panel_toplevel_update_attach_orientation
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
;
2704 signals [i++] = g_signal_connect_swapped (g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("configure-event"), (((GCallback) (panel_toplevel_attach_widget_configure
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2705 toplevel->priv->attach_toplevel, "configure-event",g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("configure-event"), (((GCallback) (panel_toplevel_attach_widget_configure
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2706 G_CALLBACK (panel_toplevel_attach_widget_configure), toplevel)g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("configure-event"), (((GCallback) (panel_toplevel_attach_widget_configure
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
;
2707 signals [i++] = g_signal_connect_swapped (g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("hiding"), (((GCallback) (panel_toplevel_attach_toplevel_hiding
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2708 toplevel->priv->attach_toplevel, "hiding",g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("hiding"), (((GCallback) (panel_toplevel_attach_toplevel_hiding
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2709 G_CALLBACK (panel_toplevel_attach_toplevel_hiding), toplevel)g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("hiding"), (((GCallback) (panel_toplevel_attach_toplevel_hiding
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
;
2710 signals [i++] = g_signal_connect_swapped (g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("unhiding"), (((GCallback) (panel_toplevel_attach_toplevel_unhiding
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2711 toplevel->priv->attach_toplevel, "unhiding",g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("unhiding"), (((GCallback) (panel_toplevel_attach_toplevel_unhiding
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2712 G_CALLBACK (panel_toplevel_attach_toplevel_unhiding), toplevel)g_signal_connect_data ((toplevel->priv->attach_toplevel
), ("unhiding"), (((GCallback) (panel_toplevel_attach_toplevel_unhiding
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
;
2713
2714 g_assert (i == N_ATTACH_TOPLEVEL_SIGNALS)do { if (i == 5) ; else g_assertion_message_expr (((gchar*) 0
), "panel-toplevel.c", 2714, ((const char*) (__func__)), "i == N_ATTACH_TOPLEVEL_SIGNALS"
); } while (0)
;
2715
2716 signals = toplevel->priv->attach_widget_signals;
2717 i = 0;
2718
2719 signals [i++] = g_signal_connect_swapped (g_signal_connect_data ((toplevel->priv->attach_widget),
("destroy"), (((GCallback) (panel_toplevel_attach_widget_destroyed
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2720 toplevel->priv->attach_widget, "destroy",g_signal_connect_data ((toplevel->priv->attach_widget),
("destroy"), (((GCallback) (panel_toplevel_attach_widget_destroyed
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2721 G_CALLBACK (panel_toplevel_attach_widget_destroyed), toplevel)g_signal_connect_data ((toplevel->priv->attach_widget),
("destroy"), (((GCallback) (panel_toplevel_attach_widget_destroyed
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
;
2722 signals [i++] = g_signal_connect_swapped (g_signal_connect_data ((toplevel->priv->attach_widget),
("configure-event"), (((GCallback) (panel_toplevel_attach_widget_configure
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2723 toplevel->priv->attach_widget, "configure-event",g_signal_connect_data ((toplevel->priv->attach_widget),
("configure-event"), (((GCallback) (panel_toplevel_attach_widget_configure
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2724 G_CALLBACK (panel_toplevel_attach_widget_configure), toplevel)g_signal_connect_data ((toplevel->priv->attach_widget),
("configure-event"), (((GCallback) (panel_toplevel_attach_widget_configure
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
;
2725 signals [i++] = g_signal_connect_swapped (g_signal_connect_data ((toplevel->priv->attach_widget),
("parent-set"), (((GCallback) (panel_toplevel_attach_widget_parent_set
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2726 toplevel->priv->attach_widget, "parent-set",g_signal_connect_data ((toplevel->priv->attach_widget),
("parent-set"), (((GCallback) (panel_toplevel_attach_widget_parent_set
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
2727 G_CALLBACK (panel_toplevel_attach_widget_parent_set), toplevel)g_signal_connect_data ((toplevel->priv->attach_widget),
("parent-set"), (((GCallback) (panel_toplevel_attach_widget_parent_set
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
;
2728 signals [i++] = g_signal_connect_swapped (g_signal_connect_data ((toplevel->priv->attach_widget),
("show"), (((GCallback) (gtk_widget_show))), (toplevel), ((void
*)0), G_CONNECT_SWAPPED)
2729 toplevel->priv->attach_widget, "show",g_signal_connect_data ((toplevel->priv->attach_widget),
("show"), (((GCallback) (gtk_widget_show))), (toplevel), ((void
*)0), G_CONNECT_SWAPPED)
2730 G_CALLBACK (gtk_widget_show), toplevel)g_signal_connect_data ((toplevel->priv->attach_widget),
("show"), (((GCallback) (gtk_widget_show))), (toplevel), ((void
*)0), G_CONNECT_SWAPPED)
;
2731 signals [i++] = g_signal_connect_swapped (g_signal_connect_data ((toplevel->priv->attach_widget),
("hide"), (((GCallback) (gtk_widget_hide))), (toplevel), ((void
*)0), G_CONNECT_SWAPPED)
2732 toplevel->priv->attach_widget, "hide",g_signal_connect_data ((toplevel->priv->attach_widget),
("hide"), (((GCallback) (gtk_widget_hide))), (toplevel), ((void
*)0), G_CONNECT_SWAPPED)
2733 G_CALLBACK (gtk_widget_hide), toplevel)g_signal_connect_data ((toplevel->priv->attach_widget),
("hide"), (((GCallback) (gtk_widget_hide))), (toplevel), ((void
*)0), G_CONNECT_SWAPPED)
;
2734
2735 g_assert (i == N_ATTACH_WIDGET_SIGNALS)do { if (i == 5) ; else g_assertion_message_expr (((gchar*) 0
), "panel-toplevel.c", 2735, ((const char*) (__func__)), "i == N_ATTACH_WIDGET_SIGNALS"
); } while (0)
;
2736}
2737
2738void
2739panel_toplevel_attach_to_widget (PanelToplevel *toplevel,
2740 PanelToplevel *attach_toplevel,
2741 GtkWidget *attach_widget)
2742{
2743 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
2744 g_return_if_fail (PANEL_IS_TOPLEVEL (attach_toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((attach_toplevel)); GType __t = ((panel_toplevel_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0
), ((const char*) (__func__)), "PANEL_IS_TOPLEVEL (attach_toplevel)"
); return; } } while (0)
;
2745 g_return_if_fail (GTK_IS_WIDGET (attach_widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((attach_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 (((gchar*) 0), ((const
char*) (__func__)), "GTK_IS_WIDGET (attach_widget)"); return
; } } while (0)
;
2746
2747 if (toplevel->priv->attached)
2748 panel_toplevel_disconnect_attached (toplevel);
2749
2750 toplevel->priv->attached = TRUE(!(0));
2751
2752 /* Cancelling the initial animation for drawers in
2753 * panel_toplevel_initially_hide() is not enough, since this will
2754 * happen only when the toplevel is realized, which might be too late
2755 * for drawers (since it's realized when the drawer is clicked) */
2756 toplevel->priv->initial_animation_done = TRUE(!(0));
2757
2758 toplevel->priv->attach_toplevel = attach_toplevel;
2759 toplevel->priv->attach_widget = attach_widget;
2760
2761 panel_toplevel_connect_attached (toplevel);
2762
2763 panel_toplevel_reverse_arrows (toplevel);
2764 panel_toplevel_set_expand (toplevel, FALSE(0));
2765 panel_toplevel_update_attach_orientation (toplevel);
2766 panel_toplevel_update_hide_buttons (toplevel);
2767
2768 gtk_window_set_screen (GTK_WINDOW (toplevel)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_window_get_type ()))))))
,
2769 gtk_widget_get_screen (GTK_WIDGET (attach_toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((attach_toplevel)), ((gtk_widget_get_type ()))))))
));
2770 panel_toplevel_set_monitor (toplevel,
2771 panel_toplevel_get_monitor (attach_toplevel));
2772 if (toplevel->priv->state == PANEL_STATE_NORMAL)
2773 panel_toplevel_push_autohide_disabler (toplevel->priv->attach_toplevel);
2774
2775 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
2776}
2777
2778void
2779panel_toplevel_detach (PanelToplevel *toplevel)
2780{
2781 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
2782
2783 if (!toplevel->priv->attached)
2784 return;
2785
2786 if (toplevel->priv->state == PANEL_STATE_NORMAL)
2787 panel_toplevel_pop_autohide_disabler (toplevel->priv->attach_toplevel);
2788
2789 panel_toplevel_disconnect_attached (toplevel);
2790
2791 panel_toplevel_reverse_arrows (toplevel);
2792
2793 toplevel->priv->attached = FALSE(0);
2794
2795 toplevel->priv->attach_toplevel = NULL((void*)0);
2796 toplevel->priv->attach_widget = NULL((void*)0);
2797
2798 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
2799}
2800
2801gboolean
2802panel_toplevel_get_is_attached (PanelToplevel *toplevel)
2803{
2804 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return ((0));
} } while (0)
;
2805
2806 return toplevel->priv->attached;
2807}
2808
2809PanelToplevel *
2810panel_toplevel_get_attach_toplevel (PanelToplevel *toplevel)
2811{
2812 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return (((void
*)0)); } } while (0)
;
2813
2814 return toplevel->priv->attach_toplevel;
2815}
2816
2817GtkWidget *
2818panel_toplevel_get_attach_widget (PanelToplevel *toplevel)
2819{
2820 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return (((void
*)0)); } } while (0)
;
2821
2822 return toplevel->priv->attach_widget;
2823}
2824
2825static gboolean
2826panel_toplevel_popup_panel_menu (PanelToplevel *toplevel)
2827{
2828 gboolean retval = FALSE(0);
2829
2830 g_signal_emit_by_name (toplevel, "popup-menu", &retval);
2831
2832 return retval;
2833}
2834
2835static gboolean
2836panel_toplevel_toggle_expand (PanelToplevel *toplevel)
2837{
2838 panel_toplevel_set_expand (toplevel, !toplevel->priv->expand);
2839
2840 return TRUE(!(0));
2841}
2842
2843static gboolean
2844panel_toplevel_expand (PanelToplevel *toplevel)
2845{
2846 panel_toplevel_set_expand (toplevel, TRUE(!(0)));
2847
2848 return TRUE(!(0));
2849}
2850
2851static gboolean
2852panel_toplevel_unexpand (PanelToplevel *toplevel)
2853{
2854 panel_toplevel_set_expand (toplevel, FALSE(0));
2855
2856 return TRUE(!(0));
2857}
2858
2859static gboolean
2860panel_toplevel_toggle_hidden (PanelToplevel *toplevel)
2861{
2862 if (toplevel->priv->state == PANEL_STATE_NORMAL)
2863 panel_toplevel_hide (toplevel, toplevel->priv->auto_hide, -1);
2864 else
2865 panel_toplevel_unhide (toplevel);
2866
2867 return FALSE(0);
2868}
2869
2870static gboolean
2871panel_toplevel_begin_move (PanelToplevel *toplevel)
2872{
2873 if (toplevel->priv->grab_op != PANEL_GRAB_OP_NONE)
2874 return FALSE(0);
2875
2876 panel_toplevel_begin_grab_op (
2877 toplevel, PANEL_GRAB_OP_MOVE, TRUE(!(0)), GDK_CURRENT_TIME0L);
2878
2879 return TRUE(!(0));
2880}
2881
2882static gboolean
2883panel_toplevel_begin_resize (PanelToplevel *toplevel)
2884{
2885 if (toplevel->priv->grab_op != PANEL_GRAB_OP_NONE)
2886 return FALSE(0);
2887
2888 panel_toplevel_begin_grab_op (
2889 toplevel, PANEL_GRAB_OP_RESIZE, TRUE(!(0)), GDK_CURRENT_TIME0L);
2890
2891 return TRUE(!(0));
2892}
2893
2894static void
2895panel_toplevel_move_resize_window (PanelToplevel *toplevel,
2896 gboolean move,
2897 gboolean resize)
2898{
2899 GtkWidget *widget;
2900
2901 GList *list;
2902 gboolean stick;
2903
2904 widget = GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
;
2905
2906 g_assert (gtk_widget_get_realized (widget))do { if (gtk_widget_get_realized (widget)) ; else g_assertion_message_expr
(((gchar*) 0), "panel-toplevel.c", 2906, ((const char*) (__func__
)), "gtk_widget_get_realized (widget)"); } while (0)
;
2907
2908 if (move && resize)
2909 gdk_window_move_resize (gtk_widget_get_window (widget),
2910 toplevel->priv->geometry.x,
2911 toplevel->priv->geometry.y,
2912 toplevel->priv->geometry.width,
2913 toplevel->priv->geometry.height);
2914 else if (move)
2915 gdk_window_move (gtk_widget_get_window (widget),
2916 toplevel->priv->geometry.x,
2917 toplevel->priv->geometry.y);
2918 else if (resize)
2919 gdk_window_resize (gtk_widget_get_window (widget),
2920 toplevel->priv->geometry.width,
2921 toplevel->priv->geometry.height);
2922
2923 if (resize || move) {
2924 for (list = toplevel->priv->panel_widget->applet_list; list != NULL((void*)0); list = g_list_next (list)((list) ? (((GList *)(list))->next) : ((void*)0))) {
2925 AppletData *ad = list->data;
2926 const char *id = mate_panel_applet_get_id_by_widget (ad->applet);
2927
2928 if (!id)
2929 return;
2930
2931 AppletInfo *info;
2932 info = mate_panel_applet_get_by_id (id);
2933
2934 stick = g_settings_get_boolean (info->settings, PANEL_OBJECT_PANEL_RIGHT_STICK_KEY"panel-right-stick");
2935
2936 if (stick) {
2937 int position = g_settings_get_int (info->settings, PANEL_OBJECT_POSITION_KEY"position");
2938 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)) {
2939 ad->pos = toplevel->priv->geometry.width - position;
2940 } else {
2941 ad->pos = toplevel->priv->geometry.height - position;
2942 }
2943 }
2944 }
2945 }
2946}
2947
2948static void
2949panel_toplevel_initially_hide (PanelToplevel *toplevel)
2950{
2951 if (!toplevel->priv->attached) {
2952 toplevel->priv->initial_animation_done = FALSE(0);
2953
2954 /* We start the panel off hidden until all the applets are
2955 * loaded, and then finally slide it down when it's ready to be
2956 * used */
2957 toplevel->priv->state = PANEL_STATE_AUTO_HIDDEN;
2958 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
2959 } else
2960 toplevel->priv->initial_animation_done = TRUE(!(0));
2961}
2962
2963static void
2964set_background_default_style (GtkWidget *widget)
2965{
2966 PanelToplevel *toplevel;
2967 GtkStyleContext *context;
2968 GtkStateFlags state;
2969 GdkRGBA *bg_color;
2970 cairo_pattern_t *bg_image;
2971
2972 if (!gtk_widget_get_realized (widget))
2973 return;
2974
2975 toplevel = PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
;
2976
2977 context = gtk_widget_get_style_context (widget);
2978 state = gtk_style_context_get_state (context);
2979
2980 gtk_style_context_get (context, state,
2981 "background-color", &bg_color,
2982 "background-image", &bg_image,
2983 NULL((void*)0));
2984
2985 panel_background_set_default_style (&toplevel->background,
2986 bg_color, bg_image);
2987
2988 if (bg_color)
2989 gdk_rgba_free (bg_color);
2990
2991 if (bg_image)
2992 cairo_pattern_destroy (bg_image);
2993}
2994
2995static void
2996panel_toplevel_realize (GtkWidget *widget)
2997{
2998 PanelToplevel *toplevel;
2999 GdkScreen *screen;
3000 GdkVisual *visual;
3001 GdkWindow *window;
3002
3003 toplevel = PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
;
3004
3005 screen = gtk_widget_get_screen (widget);
3006 visual = gdk_screen_get_rgba_visual (screen);
3007
3008 if (visual == NULL((void*)0))
3009 visual = gdk_screen_get_system_visual (screen);
3010
3011 gtk_widget_set_visual (widget, visual);
3012 gtk_window_stick (GTK_WINDOW (widget)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_window_get_type ()))))))
);
3013 gtk_window_set_decorated (GTK_WINDOW (widget)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_window_get_type ()))))))
, FALSE(0));
3014 gtk_window_stick (GTK_WINDOW (widget)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_window_get_type ()))))))
);
3015 gtk_window_set_type_hint (GTK_WINDOW (widget)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_window_get_type ()))))))
, GDK_WINDOW_TYPE_HINT_DOCK);
3016
3017 GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->realize (widget);
3018
3019 window = gtk_widget_get_window (widget);
3020 set_background_default_style (widget);
3021 panel_background_realized (&toplevel->background, window);
3022
3023#ifdef HAVE_X111
3024 if (GDK_IS_X11_WINDOW (window)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(window)); GType __t = ((gdk_x11_window_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
) {
3025 panel_struts_set_window_hint (toplevel);
3026 gdk_window_set_geometry_hints (window, NULL((void*)0), 0);
3027 }
3028#endif /* HAVE_X11 */
3029
3030 gdk_window_set_group (window, window);
3031 panel_toplevel_initially_hide (toplevel);
3032
3033 panel_toplevel_move_resize_window (toplevel, TRUE(!(0)), TRUE(!(0)));
3034}
3035
3036static void
3037panel_toplevel_disconnect_timeouts (PanelToplevel *toplevel)
3038{
3039 if (toplevel->priv->hide_timeout)
3040 g_source_remove (toplevel->priv->hide_timeout);
3041 toplevel->priv->hide_timeout = 0;
3042
3043 if (toplevel->priv->unhide_timeout)
3044 g_source_remove (toplevel->priv->unhide_timeout);
3045 toplevel->priv->unhide_timeout = 0;
3046
3047 if (toplevel->priv->animation_timeout)
3048 g_source_remove (toplevel->priv->animation_timeout);
3049 toplevel->priv->animation_timeout = 0;
3050}
3051
3052static void
3053panel_toplevel_unrealize (GtkWidget *widget)
3054{
3055 PanelToplevel *toplevel;
3056 toplevel = PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
;
3057 panel_toplevel_disconnect_timeouts (toplevel);
3058 panel_background_unrealized (&toplevel->background);
3059 GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->unrealize (widget);
3060}
3061
3062static void
3063panel_toplevel_dispose (GObject *widget)
3064{
3065 PanelToplevel *toplevel = (PanelToplevel *) widget;
3066
3067 g_clear_pointer (&toplevel->priv->settings_path, g_free)do { _Static_assert (sizeof *(&toplevel->priv->settings_path
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
((&toplevel->priv->settings_path)) _pp = (&toplevel
->priv->settings_path); __typeof__ (*(&toplevel->
priv->settings_path)) _ptr = *_pp; *_pp = ((void*)0); if (
_ptr) (g_free) (_ptr); } while (0)
;
3068
3069 if (toplevel->settings) {
3070 g_signal_handlers_disconnect_by_data (toplevel->settings, toplevel)g_signal_handlers_disconnect_matched ((toplevel->settings)
, G_SIGNAL_MATCH_DATA, 0, 0, ((void*)0), ((void*)0), (toplevel
))
;
3071 g_clear_object (&toplevel->settings)do { _Static_assert (sizeof *((&toplevel->settings)) ==
sizeof (gpointer), "Expression evaluates to false"); __typeof__
(((&toplevel->settings))) _pp = ((&toplevel->settings
)); __typeof__ (*((&toplevel->settings))) _ptr = *_pp;
*_pp = ((void*)0); if (_ptr) (g_object_unref) (_ptr); } while
(0)
;
3072 }
3073
3074 g_clear_object (&toplevel->queued_settings)do { _Static_assert (sizeof *((&toplevel->queued_settings
)) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(((&toplevel->queued_settings))) _pp = ((&toplevel
->queued_settings)); __typeof__ (*((&toplevel->queued_settings
))) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (g_object_unref
) (_ptr); } while (0)
;
3075
3076 if (toplevel->background_settings) {
3077 g_signal_handlers_disconnect_by_data (toplevel->background_settings, toplevel)g_signal_handlers_disconnect_matched ((toplevel->background_settings
), G_SIGNAL_MATCH_DATA, 0, 0, ((void*)0), ((void*)0), (toplevel
))
;
3078 g_clear_object (&toplevel->background_settings)do { _Static_assert (sizeof *((&toplevel->background_settings
)) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(((&toplevel->background_settings))) _pp = ((&toplevel
->background_settings)); __typeof__ (*((&toplevel->
background_settings))) _ptr = *_pp; *_pp = ((void*)0); if (_ptr
) (g_object_unref) (_ptr); } while (0)
;
3079 }
3080
3081 if (toplevel->priv->gtk_settings) {
3082 g_signal_handlers_disconnect_by_func (toplevel->priv->gtk_settings,g_signal_handlers_disconnect_matched ((toplevel->priv->
gtk_settings), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (panel_toplevel_drag_threshold_changed
))), (toplevel))
3083 G_CALLBACK (panel_toplevel_drag_threshold_changed),g_signal_handlers_disconnect_matched ((toplevel->priv->
gtk_settings), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (panel_toplevel_drag_threshold_changed
))), (toplevel))
3084 toplevel)g_signal_handlers_disconnect_matched ((toplevel->priv->
gtk_settings), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (panel_toplevel_drag_threshold_changed
))), (toplevel))
;
3085 toplevel->priv->gtk_settings = NULL((void*)0);
3086
3087 panel_background_free (&toplevel->background);
3088 }
3089
3090 if (toplevel->priv->attached) {
3091 panel_toplevel_disconnect_attached (toplevel);
3092 toplevel->priv->attached = FALSE(0);
3093
3094 toplevel->priv->attach_toplevel = NULL((void*)0);
3095 toplevel->priv->attach_widget = NULL((void*)0);
3096 }
3097
3098 g_clear_pointer (&toplevel->priv->description, g_free)do { _Static_assert (sizeof *(&toplevel->priv->description
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
((&toplevel->priv->description)) _pp = (&toplevel
->priv->description); __typeof__ (*(&toplevel->priv
->description)) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (
g_free) (_ptr); } while (0)
;
3099 g_clear_pointer (&toplevel->priv->name, g_free)do { _Static_assert (sizeof *(&toplevel->priv->name
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
((&toplevel->priv->name)) _pp = (&toplevel->
priv->name); __typeof__ (*(&toplevel->priv->name
)) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (g_free) (_ptr);
} while (0)
;
3100
3101 panel_toplevel_disconnect_timeouts (toplevel);
3102
3103 G_OBJECT_CLASS (panel_toplevel_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), (((GType) ((20) << (
2))))))))
->dispose (widget);
3104}
3105
3106static void
3107panel_toplevel_check_resize (GtkContainer *container)
3108{
3109 GtkAllocation allocation;
3110 GtkRequisition requisition;
3111 GtkWidget *widget;
3112
3113 widget = GTK_WIDGET (container)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((container)), ((gtk_widget_get_type ()))))))
;
3114
3115 if (!gtk_widget_get_visible (widget))
3116 return;
3117
3118 requisition.width = -1;
3119 requisition.height = -1;
3120
3121 gtk_widget_get_preferred_size (widget, &requisition, NULL((void*)0));
3122 gtk_widget_get_allocation (widget, &allocation);
3123
3124 allocation.width = requisition.width;
3125 allocation.height = requisition.height;
3126
3127 gtk_widget_size_allocate (widget, &allocation);
3128}
3129
3130static void
3131panel_toplevel_size_request (GtkWidget *widget,
3132 GtkRequisition *requisition)
3133{
3134 PanelToplevel *toplevel;
3135 GtkBin *bin;
3136 GtkWidget *child;
3137 GdkRectangle old_geometry;
3138 int position_changed = FALSE(0);
3139 int size_changed = FALSE(0);
3140
3141 toplevel = PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
;
3142 bin = GTK_BIN (widget)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_bin_get_type ()))))))
;
3143
3144 /* we get a size request when there are new monitors, so first try to
3145 * see if we need to move to a new monitor */
3146 panel_toplevel_update_monitor (toplevel);
3147
3148 child = gtk_bin_get_child (bin);
3149 if (child && gtk_widget_get_visible (child))
3150 gtk_widget_get_preferred_size (child, requisition, NULL((void*)0));
3151
3152 old_geometry = toplevel->priv->geometry;
3153
3154 panel_toplevel_update_geometry (toplevel, requisition);
3155
3156 requisition->width = toplevel->priv->geometry.width;
3157 requisition->height = toplevel->priv->geometry.height;
3158
3159 if (!gtk_widget_get_realized (widget))
3160 return;
3161
3162 if (old_geometry.width != toplevel->priv->geometry.width ||
3163 old_geometry.height != toplevel->priv->geometry.height)
3164 size_changed = TRUE(!(0));
3165
3166 if (old_geometry.x != toplevel->priv->geometry.x ||
3167 old_geometry.y != toplevel->priv->geometry.y)
3168 position_changed = TRUE(!(0));
3169
3170 panel_toplevel_move_resize_window (toplevel, position_changed, size_changed);
3171}
3172
3173static void
3174panel_toplevel_get_preferred_width (GtkWidget *widget,
3175 gint *minimum_width,
3176 gint *natural_width)
3177{
3178 GtkRequisition req;
3179 panel_toplevel_size_request (widget, &req);
3180 *minimum_width = *natural_width = req.width;
3181}
3182
3183static void
3184panel_toplevel_get_preferred_height (GtkWidget *widget,
3185 gint *minimum_height,
3186 gint *natural_height)
3187{
3188 GtkRequisition req;
3189 panel_toplevel_size_request (widget, &req);
3190 *minimum_height = *natural_height = req.height;
3191}
3192
3193static void
3194set_background_region (PanelToplevel *toplevel)
3195{
3196 GtkWidget *widget;
3197 GdkWindow *window;
3198 gint origin_x;
3199 gint origin_y;
3200 GtkAllocation allocation;
3201 GtkOrientation orientation;
3202
3203 widget = GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
;
3204
3205 if (!gtk_widget_get_realized (widget))
3206 return;
3207
3208 window = gtk_widget_get_window (widget);
3209 origin_x = -1;
3210 origin_y = -1;
3211
3212 gdk_window_get_origin (window, &origin_x, &origin_y);
3213 gtk_widget_get_allocation (widget, &allocation);
3214
3215 orientation = GTK_ORIENTATION_HORIZONTAL;
3216 if (toplevel->priv->orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT))
3217 orientation = GTK_ORIENTATION_VERTICAL;
3218
3219 panel_background_change_region (&toplevel->background, orientation,
3220 origin_x, origin_y,
3221 allocation.width, allocation.height);
3222}
3223
3224static void
3225panel_toplevel_size_allocate (GtkWidget *widget,
3226 GtkAllocation *allocation)
3227{
3228 PanelToplevel *toplevel = (PanelToplevel *) widget;
3229 GtkBin *bin = (GtkBin *) widget;
3230 GtkStyleContext *context;
3231 GtkStateFlags state;
3232 GtkBorder padding;
3233 GtkWidget *child;
3234 GtkAllocation challoc;
3235 GtkAllocation child_allocation;
3236
3237 gtk_widget_set_allocation (widget, allocation);
3238
3239 if (toplevel->priv->expand ||
3240 toplevel->priv->buttons_enabled ||
3241 toplevel->priv->attached)
3242 challoc = *allocation;
3243 else {
3244 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)) {
3245 challoc.x = HANDLE_SIZE10;
3246 challoc.y = 0;
3247 challoc.width = allocation->width - 2 * HANDLE_SIZE10;
3248 challoc.height = allocation->height;
3249 } else {
3250 challoc.x = 0;
3251 challoc.y = HANDLE_SIZE10;
3252 challoc.width = allocation->width;
3253 challoc.height = allocation->height - 2 * HANDLE_SIZE10;
3254 }
3255 }
3256
3257 state = gtk_widget_get_state_flags (widget);
3258 context = gtk_widget_get_style_context (widget);
3259 gtk_style_context_get_padding (context, state, &padding);
3260
3261 if (toplevel->priv->edges & PANEL_EDGE_TOP) {
3262 challoc.y += padding.top;
3263 challoc.height -= padding.top;
3264 }
3265
3266 if (toplevel->priv->edges & PANEL_EDGE_LEFT) {
3267 challoc.x += padding.left;
3268 challoc.width -= padding.left;
3269 }
3270
3271 if (toplevel->priv->edges & PANEL_EDGE_BOTTOM)
3272 challoc.height -= padding.bottom;
3273
3274 if (toplevel->priv->edges & PANEL_EDGE_RIGHT)
3275 challoc.width -= padding.right;
3276
3277 challoc.width = MAX (1, challoc.width)(((1) > (challoc.width)) ? (1) : (challoc.width));
3278 challoc.height = MAX (1, challoc.height)(((1) > (challoc.height)) ? (1) : (challoc.height));
3279
3280 child = gtk_bin_get_child (bin);
3281 gtk_widget_get_allocation (child, &child_allocation);
3282
3283 if (gtk_widget_get_mapped (widget) &&
3284 (challoc.x != child_allocation.x ||
3285 challoc.y != child_allocation.y ||
3286 challoc.width != child_allocation.width ||
3287 challoc.height != child_allocation.height)) {
3288 GtkAllocation allocation_to_invalidate;
3289
3290 gtk_widget_get_allocation (widget, &allocation_to_invalidate);
3291 gdk_window_invalidate_rect (gtk_widget_get_window (widget),
3292 &allocation_to_invalidate, FALSE(0));
3293 }
3294
3295 if (child && gtk_widget_get_visible (child))
3296 gtk_widget_size_allocate (child, &challoc);
3297
3298 set_background_region (toplevel);
3299}
3300
3301static gboolean panel_toplevel_draw(GtkWidget* widget, cairo_t* cr)
3302{
3303 PanelToplevel* toplevel = (PanelToplevel*) widget;
3304 PanelFrameEdge edges;
3305 gboolean retval = FALSE(0);
3306 int awidth;
3307 int aheight;
3308 GtkStyleContext *context;
3309 GtkStateFlags state;
3310 GtkBorder padding;
3311
3312 if (!gtk_widget_is_drawable (widget))
3313 return retval;
3314
3315 if (GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->draw)
3316 retval = GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->draw (widget, cr);
3317
3318 edges = toplevel->priv->edges;
3319 panel_frame_draw (widget, cr, edges);
3320
3321 if (toplevel->priv->expand ||
3322 toplevel->priv->buttons_enabled ||
3323 toplevel->priv->attached)
3324 return retval;
3325
3326 state = gtk_widget_get_state_flags (widget);
3327 awidth = gtk_widget_get_allocated_width (widget);
3328 aheight = gtk_widget_get_allocated_height (widget);
3329
3330 context = gtk_widget_get_style_context (widget);
3331 gtk_style_context_get_padding (context, state, &padding);
3332
3333 gtk_style_context_save (context);
3334 gtk_style_context_set_state (context, state);
3335
3336 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)) {
3337 int x, y, width, height;
3338
3339 x = 0;
3340 y = 0;
3341 height = aheight;
3342 width = HANDLE_SIZE10;
3343
3344 if (edges & PANEL_EDGE_TOP) {
3345 y += padding.top;
3346 height -= padding.top;
3347 }
3348 if (edges & PANEL_EDGE_BOTTOM)
3349 height -= padding.bottom;
3350 if (edges & PANEL_EDGE_LEFT)
3351 x += padding.left;
3352
3353 cairo_save (cr);
3354 gtk_render_handle (context, cr, x, y, width, height);
3355 cairo_restore (cr);
3356
3357 x = awidth - HANDLE_SIZE10;
3358 if (edges & PANEL_EDGE_RIGHT)
3359 x -= padding.right;
3360
3361 cairo_save (cr);
3362 gtk_render_handle (context, cr, x, y, width, height);
3363 cairo_restore (cr);
3364 } else {
3365 int x, y, width, height;
3366
3367 x = 0;
3368 y = 0;
3369 width = awidth;
3370 height = HANDLE_SIZE10;
3371
3372 if (edges & PANEL_EDGE_LEFT) {
3373 x += padding.left;
3374 width -= padding.left;
3375 }
3376 if (edges & PANEL_EDGE_RIGHT)
3377 width -= padding.right;
3378 if (edges & PANEL_EDGE_TOP)
3379 y += padding.top;
3380
3381 cairo_save (cr);
3382 gtk_render_handle (context, cr, x, y, width, height);
3383 cairo_restore (cr);
3384
3385 y = aheight - HANDLE_SIZE10;
3386 if (edges & PANEL_EDGE_BOTTOM)
3387 y -= padding.bottom;
3388
3389 cairo_save (cr);
3390 gtk_render_handle (context, cr, x, y, width, height);
3391 cairo_restore (cr);
3392 }
3393
3394 gtk_style_context_restore (context);
3395
3396 return retval;
3397}
3398
3399static gboolean
3400panel_toplevel_button_press_event (GtkWidget *widget,
3401 GdkEventButton *event)
3402{
3403 PanelToplevel *toplevel;
3404 GtkWidget *event_widget;
3405
3406 g_return_val_if_fail (PANEL_IS_TOPLEVEL (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (widget)"); return ((0)); }
} while (0)
;
3407
3408 toplevel = PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
;
3409
3410 if (event->button != 1 && event->button != 2)
3411 return FALSE(0);
3412
3413 if (toplevel->priv->animating)
3414 return FALSE(0);
3415
3416 /* Get the mouse-button modifier from marco so that only intentional
3417 * moves are considered. We don't this for non-expanded panels since we
3418 * only have the handles that the user can grab. */
3419 if ((toplevel->priv->expand || toplevel->priv->attached) &&
3420 (event->state & GDK_MODIFIER_MASK) != panel_bindings_get_mouse_button_modifier_keymask ())
3421 return FALSE(0);
3422
3423 gdk_window_get_user_data (event->window, (gpointer)&event_widget);
3424 g_assert (GTK_IS_WIDGET (event_widget))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((event_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_assertion_message_expr (((gchar*) 0), "panel-toplevel.c", 3424
, ((const char*) (__func__)), "GTK_IS_WIDGET (event_widget)")
; } while (0)
;
3425 gtk_widget_translate_coordinates (event_widget,
3426 widget,
3427 event->x,
3428 event->y,
3429 &toplevel->priv->drag_offset_x,
3430 &toplevel->priv->drag_offset_y);
3431
3432 panel_toplevel_begin_grab_op (toplevel, PANEL_GRAB_OP_MOVE, FALSE(0), event->time);
3433
3434 return TRUE(!(0));
3435}
3436
3437static gboolean
3438panel_toplevel_button_release_event (GtkWidget *widget,
3439 GdkEventButton *event)
3440{
3441 PanelToplevel *toplevel;
3442
3443 if (event->button != 1 && event->button != 2)
3444 return FALSE(0);
3445
3446 toplevel = PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
;
3447
3448 if (toplevel->priv->grab_op == PANEL_GRAB_OP_NONE)
3449 return FALSE(0);
3450
3451 if (toplevel->priv->grab_is_keyboard)
3452 return FALSE(0);
3453
3454 panel_toplevel_end_grab_op (toplevel, event->time);
3455
3456 return TRUE(!(0));
3457}
3458
3459static gboolean
3460panel_toplevel_configure_event (GtkWidget *widget,
3461 GdkEventConfigure *event)
3462{
3463 PanelToplevel *toplevel;
3464
3465 toplevel = PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
;
3466
3467 set_background_region (toplevel);
3468
3469 return TRUE(!(0));
3470}
3471
3472static gboolean
3473panel_toplevel_key_press_event (GtkWidget *widget,
3474 GdkEventKey *event)
3475{
3476 PanelToplevel *toplevel = (PanelToplevel *) widget;
3477
3478 if (toplevel->priv->grab_op != PANEL_GRAB_OP_NONE &&
3479 panel_toplevel_handle_grab_op_key_event (toplevel, event))
3480 return TRUE(!(0));
3481
3482 if (GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->key_press_event)
3483 return GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->key_press_event (widget, event);
3484
3485 return FALSE(0);
3486}
3487
3488static void
3489panel_toplevel_state_flags_changed (GtkWidget *widget,
3490 GtkStateFlags previous_state)
3491{
3492 GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->state_flags_changed (widget,
3493 previous_state);
3494
3495 set_background_default_style (widget);
3496}
3497
3498static gboolean
3499panel_toplevel_motion_notify_event (GtkWidget *widget,
3500 GdkEventMotion *event)
3501{
3502 if (gdk_event_get_screen ((GdkEvent *)event) ==
3503 gtk_window_get_screen (GTK_WINDOW (widget)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_window_get_type ()))))))
))
3504 return panel_toplevel_handle_grab_op_motion_event (
3505 PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
, event);
3506 else
3507 return FALSE(0);
3508}
3509
3510static gboolean
3511panel_toplevel_animation_timeout (PanelToplevel *toplevel)
3512{
3513 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
3514
3515 if (!toplevel->priv->animating) {
3516 toplevel->priv->animation_end_x = 0xdead;
3517 toplevel->priv->animation_end_y = 0xdead;
3518 toplevel->priv->animation_end_width = 0xdead;
3519 toplevel->priv->animation_end_height = 0xdead;
3520 toplevel->priv->animation_start_time = 0xdead;
3521 toplevel->priv->animation_duration_time = 0xdead;
3522 toplevel->priv->animation_timeout = 0;
3523 toplevel->priv->initial_animation_done = TRUE(!(0));
3524 }
3525
3526 return toplevel->priv->animating;
3527}
3528
3529static GTimeSpan
3530panel_toplevel_get_animation_time (PanelToplevel *toplevel)
3531{
3532 /* The number of seconds to complete the animation.
3533 */
3534#define ANIMATION_TIME_FAST 400
3535#define ANIMATION_TIME_MEDIUM 1200
3536#define ANIMATION_TIME_SLOW 2000
3537
3538 GTimeSpan t;
3539
3540 switch (toplevel->priv->animation_speed) {
3541 case PANEL_ANIMATION_SLOW:
3542 t = ANIMATION_TIME_SLOW * G_TIME_SPAN_MILLISECOND((1000L));
3543 break;
3544 case PANEL_ANIMATION_MEDIUM:
3545 t = ANIMATION_TIME_MEDIUM * G_TIME_SPAN_MILLISECOND((1000L));
3546 break;
3547 case PANEL_ANIMATION_FAST:
3548 t = ANIMATION_TIME_FAST * G_TIME_SPAN_MILLISECOND((1000L));
3549 break;
3550 default:
3551 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 3551, ((const char*) (__func__)), ((void*)0)); } while (0)
;
3552 break;
3553 }
3554
3555 return t;
3556
3557#undef ANIMATION_TIME_FAST
3558#undef ANIMATION_TIME_MEDIUM
3559#undef ANIMATION_TIME_SLOW
3560}
3561
3562static void
3563panel_toplevel_calculate_animation_end_geometry (PanelToplevel *toplevel)
3564{
3565 GdkRectangle monitor_geom;
3566
3567 toplevel->priv->animation_end_x = toplevel->priv->x;
3568 toplevel->priv->animation_end_y = toplevel->priv->y;
3569 toplevel->priv->animation_end_width = -1;
3570 toplevel->priv->animation_end_height = -1;
3571
3572 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
3573
3574 if (!toplevel->priv->expand) {
3575
3576 if (toplevel->priv->x_centered)
3577 toplevel->priv->animation_end_x =
3578 (monitor_geom.width - toplevel->priv->geometry.width) / 2;
3579 if (toplevel->priv->y_centered)
3580 toplevel->priv->animation_end_y =
3581 (monitor_geom.height - toplevel->priv->geometry.height) / 2;
3582 }
3583
3584 /* we consider the toplevels which are in the initial animation stage
3585 * as in a normal state */
3586 if (toplevel->priv->state == PANEL_STATE_NORMAL ||
3587 (!toplevel->priv->initial_animation_done &&
3588 !toplevel->priv->auto_hide))
3589 panel_toplevel_update_normal_position (toplevel,
3590 &toplevel->priv->animation_end_x,
3591 &toplevel->priv->animation_end_y,
3592 &toplevel->priv->animation_end_width,
3593 &toplevel->priv->animation_end_height);
3594
3595 else if (toplevel->priv->state == PANEL_STATE_AUTO_HIDDEN)
3596 panel_toplevel_update_auto_hide_position (toplevel,
3597 &toplevel->priv->animation_end_x,
3598 &toplevel->priv->animation_end_y,
3599 &toplevel->priv->animation_end_width,
3600 &toplevel->priv->animation_end_height,
3601 TRUE(!(0)));
3602 else
3603 panel_toplevel_update_hidden_position (toplevel,
3604 &toplevel->priv->animation_end_x,
3605 &toplevel->priv->animation_end_y,
3606 &toplevel->priv->animation_end_width,
3607 &toplevel->priv->animation_end_height);
3608}
3609
3610static void
3611panel_toplevel_start_animation (PanelToplevel *toplevel)
3612{
3613 GtkRequisition requisition;
3614 int deltax, deltay, deltaw = 0, deltah = 0;
3615 int cur_x = -1, cur_y = -1;
3616
3617 panel_toplevel_calculate_animation_end_geometry (toplevel);
3618
3619 toplevel->priv->animating = TRUE(!(0));
3620
3621 panel_toplevel_update_struts (toplevel, TRUE(!(0)));
3622#ifdef HAVE_X111
3623 if (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel)))(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gtk_widget_get_display (((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((toplevel)), ((gtk_widget_get_type ()))))
))))); GType __t = ((gdk_x11_display_get_type())); gboolean __r
; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
) {
3624 panel_struts_update_toplevel_geometry (toplevel,
3625 &toplevel->priv->animation_end_x,
3626 &toplevel->priv->animation_end_y,
3627 &toplevel->priv->animation_end_width,
3628 &toplevel->priv->animation_end_height);
3629 }
3630#endif /* HAVE_X11 */
3631 panel_toplevel_update_struts (toplevel, FALSE(0));
3632
3633 gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
), &cur_x, &cur_y);
3634
3635 cur_x -= panel_multimonitor_x (toplevel->priv->monitor);
3636 cur_y -= panel_multimonitor_y (toplevel->priv->monitor);
3637
3638 deltax = toplevel->priv->animation_end_x - cur_x;
3639 deltay = toplevel->priv->animation_end_y - cur_y;
3640
3641 gtk_widget_get_preferred_size (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
, &requisition, NULL((void*)0));
3642
3643 if (toplevel->priv->animation_end_width != -1)
3644 deltaw = toplevel->priv->animation_end_width - requisition.width;
3645
3646 if (toplevel->priv->animation_end_height != -1)
3647 deltah = toplevel->priv->animation_end_height - requisition.height;
3648
3649 if (deltax == 0 && deltay == 0 && deltaw == 0 && deltah == 0) {
3650 toplevel->priv->animation_end_x = -1;
3651 toplevel->priv->animation_end_y = -1;
3652 toplevel->priv->animation_end_width = -1;
3653 toplevel->priv->animation_end_height = -1;
3654 toplevel->priv->animating = FALSE(0);
3655 return;
3656 }
3657
3658 if (toplevel->priv->attached) {
3659 /* Re-map unmapped attached toplevels */
3660 if (!gtk_widget_get_visible (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
))
3661 gtk_widget_set_visible (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
, TRUE(!(0)));
3662
3663 if (!gtk_widget_get_mapped (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
))
3664 gtk_widget_map (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
3665
3666 gtk_window_present (GTK_WINDOW (toplevel->priv->attach_toplevel)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->attach_toplevel)), ((gtk_window_get_type
()))))))
);
3667 }
3668
3669 toplevel->priv->animation_start_time = g_get_monotonic_time ();
3670 toplevel->priv->animation_duration_time = panel_toplevel_get_animation_time (toplevel);
3671
3672 if (!toplevel->priv->animation_timeout)
3673 toplevel->priv->animation_timeout =
3674 g_timeout_add (20, (GSourceFunc) panel_toplevel_animation_timeout, toplevel);
3675}
3676
3677void
3678panel_toplevel_hide (PanelToplevel *toplevel,
3679 gboolean auto_hide,
3680 gint direction)
3681{
3682 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
3683
3684 if (toplevel->priv->state != PANEL_STATE_NORMAL)
3685 return;
3686
3687 g_signal_emit (toplevel, toplevel_signals [HIDE_SIGNAL], 0);
3688
3689 if (toplevel->priv->attach_toplevel)
3690 panel_toplevel_pop_autohide_disabler (toplevel->priv->attach_toplevel);
3691
3692 if (auto_hide)
3693 toplevel->priv->state = PANEL_STATE_AUTO_HIDDEN;
3694 else {
3695 GtkDirectionType hide_direction;
3696
3697 if (direction == -1) {
3698 if (toplevel->priv->orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT))
3699 hide_direction = GTK_DIR_UP;
3700 else
3701 hide_direction = GTK_DIR_LEFT;
3702 } else {
3703 hide_direction = (GtkDirectionType) direction;
3704 }
3705
3706 switch (hide_direction) {
3707 case GTK_DIR_UP:
3708 g_return_if_fail (toplevel->priv->orientation & PANEL_VERTICAL_MASK)do { if ((toplevel->priv->orientation & (PANEL_ORIENTATION_LEFT
| PANEL_ORIENTATION_RIGHT))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "toplevel->priv->orientation & PANEL_VERTICAL_MASK"
); return; } } while (0)
;
3709 toplevel->priv->state = PANEL_STATE_HIDDEN_UP;
3710 break;
3711 case GTK_DIR_DOWN:
3712 g_return_if_fail (toplevel->priv->orientation & PANEL_VERTICAL_MASK)do { if ((toplevel->priv->orientation & (PANEL_ORIENTATION_LEFT
| PANEL_ORIENTATION_RIGHT))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "toplevel->priv->orientation & PANEL_VERTICAL_MASK"
); return; } } while (0)
;
3713 toplevel->priv->state = PANEL_STATE_HIDDEN_DOWN;
3714 break;
3715 case GTK_DIR_LEFT:
3716 g_return_if_fail (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK)do { if ((toplevel->priv->orientation & (PANEL_ORIENTATION_TOP
| PANEL_ORIENTATION_BOTTOM))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "toplevel->priv->orientation & PANEL_HORIZONTAL_MASK"
); return; } } while (0)
;
3717 toplevel->priv->state = PANEL_STATE_HIDDEN_LEFT;
3718 break;
3719 case GTK_DIR_RIGHT:
3720 g_return_if_fail (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK)do { if ((toplevel->priv->orientation & (PANEL_ORIENTATION_TOP
| PANEL_ORIENTATION_BOTTOM))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "toplevel->priv->orientation & PANEL_HORIZONTAL_MASK"
); return; } } while (0)
;
3721 toplevel->priv->state = PANEL_STATE_HIDDEN_RIGHT;
3722 break;
3723 default:
3724 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 3724, ((const char*) (__func__)), ((void*)0)); } while (0)
;
3725 break;
3726 }
3727
3728 panel_toplevel_update_hide_buttons (toplevel);
3729 }
3730
3731 if (toplevel->priv->animate && gtk_widget_get_realized (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
)) {
3732 panel_toplevel_start_animation (toplevel);
3733 }
3734
3735 /* if the toplevel is attached (-> drawer), hide it after the animation
3736 * this hides the hide button properly as well */
3737 if (toplevel->priv->attached) {
3738 gtk_widget_hide (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
3739 }
3740
3741 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
3742}
3743
3744static gboolean
3745panel_toplevel_auto_hide_timeout_handler (PanelToplevel *toplevel)
3746{
3747 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return ((0));
} } while (0)
;
3748
3749 if (panel_toplevel_get_autohide_disabled (toplevel)) {
3750 toplevel->priv->hide_timeout = 0;
3751 return FALSE(0);
3752 }
3753
3754 /* keep coming back until the animation has finished.
3755 * FIXME: we should really remove the timeout/idle
3756 * completely and re-instate it when the
3757 * animation has finished.
3758 */
3759 if (toplevel->priv->animating)
3760 return TRUE(!(0));
3761
3762 panel_toplevel_hide (toplevel, TRUE(!(0)), -1);
3763
3764 toplevel->priv->hide_timeout = 0;
3765
3766 return FALSE(0);
3767}
3768
3769void
3770panel_toplevel_unhide (PanelToplevel *toplevel)
3771{
3772 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
3773
3774 if (toplevel->priv->state == PANEL_STATE_NORMAL)
3775 return;
3776
3777 toplevel->priv->state = PANEL_STATE_NORMAL;
3778
3779 panel_toplevel_update_hide_buttons (toplevel);
3780
3781 if (toplevel->priv->attach_toplevel)
3782 panel_toplevel_push_autohide_disabler (toplevel->priv->attach_toplevel);
3783
3784 if (toplevel->priv->animate && gtk_widget_get_realized (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
)) {
3785 panel_toplevel_start_animation (toplevel);
3786 }
3787
3788 /* if the toplevel is attached (-> drawer), unhide it after the animation
3789 * (same as for hide) */
3790 if (toplevel->priv->attached) {
3791 gtk_widget_show (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
3792 }
3793
3794 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
3795
3796 if (!toplevel->priv->animate)
3797 g_signal_emit (toplevel, toplevel_signals [UNHIDE_SIGNAL], 0);
3798}
3799
3800static gboolean
3801panel_toplevel_auto_unhide_timeout_handler (PanelToplevel *toplevel)
3802{
3803 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return ((0));
} } while (0)
;
3804
3805 /* keep coming back until the animation has finished.
3806 * FIXME: we should really remove the timeout/idle
3807 * completely and re-instate it when the
3808 * animation has finished.
3809 */
3810 if (toplevel->priv->animating)
3811 return TRUE(!(0));
3812
3813 if (!toplevel->priv->animate)
3814 toplevel->priv->initial_animation_done = TRUE(!(0));
3815
3816 /* initial animation for auto-hidden panels: we need to unhide and hide
3817 * again to get at the right size */
3818 if (!toplevel->priv->initial_animation_done &&
3819 toplevel->priv->auto_hide) {
3820 toplevel->priv->unhide_timeout = 0;
3821 panel_toplevel_unhide (toplevel);
3822 panel_toplevel_hide (toplevel, TRUE(!(0)), -1);
3823 return FALSE(0);
3824 }
3825
3826 if (!panel_toplevel_contains_pointer (toplevel) &&
3827 toplevel->priv->auto_hide) {
3828 toplevel->priv->unhide_timeout = 0;
3829 return FALSE(0);
3830 }
3831
3832 panel_toplevel_unhide (toplevel);
3833
3834 toplevel->priv->unhide_timeout = 0;
3835
3836 return FALSE(0);
3837}
3838
3839void
3840panel_toplevel_queue_auto_hide (PanelToplevel *toplevel)
3841{
3842 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
3843
3844 if (!toplevel->priv->auto_hide ||
3845 panel_toplevel_contains_pointer (toplevel) ||
3846 panel_toplevel_get_autohide_disabled (toplevel))
3847 return;
3848
3849 if (toplevel->priv->unhide_timeout)
3850 g_source_remove (toplevel->priv->unhide_timeout);
3851 toplevel->priv->unhide_timeout = 0;
3852
3853 if (toplevel->priv->hide_timeout ||
3854 toplevel->priv->state != PANEL_STATE_NORMAL)
3855 return;
3856
3857 if (toplevel->priv->hide_delay > 0)
3858 toplevel->priv->hide_timeout =
3859 g_timeout_add (toplevel->priv->hide_delay,
3860 (GSourceFunc) panel_toplevel_auto_hide_timeout_handler,
3861 toplevel);
3862 else
3863 toplevel->priv->hide_timeout =
3864 g_idle_add ((GSourceFunc) panel_toplevel_auto_hide_timeout_handler,
3865 toplevel);
3866}
3867
3868void
3869panel_toplevel_queue_auto_unhide (PanelToplevel *toplevel)
3870{
3871 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
3872
3873 if (toplevel->priv->unhide_timeout)
3874 return;
3875
3876 if (toplevel->priv->hide_timeout)
3877 g_source_remove (toplevel->priv->hide_timeout);
3878 toplevel->priv->hide_timeout = 0;
3879
3880 if (toplevel->priv->state != PANEL_STATE_AUTO_HIDDEN)
3881 return;
3882
3883 if (toplevel->priv->unhide_delay > 0)
3884 toplevel->priv->unhide_timeout =
3885 g_timeout_add (toplevel->priv->unhide_delay,
3886 (GSourceFunc) panel_toplevel_auto_unhide_timeout_handler,
3887 toplevel);
3888 else
3889 toplevel->priv->unhide_timeout =
3890 g_idle_add ((GSourceFunc) panel_toplevel_auto_unhide_timeout_handler,
3891 toplevel);
3892}
3893
3894void
3895panel_toplevel_queue_initial_unhide (PanelToplevel *toplevel)
3896{
3897 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
3898
3899 if (toplevel->priv->initial_animation_done)
3900 return;
3901
3902 if (toplevel->priv->unhide_timeout)
3903 return;
3904
3905 toplevel->priv->unhide_timeout =
3906 g_idle_add ((GSourceFunc) panel_toplevel_auto_unhide_timeout_handler,
3907 toplevel);
3908}
3909
3910static gboolean
3911panel_toplevel_enter_notify_event (GtkWidget *widget,
3912 GdkEventCrossing *event)
3913{
3914 PanelToplevel *toplevel;
3915
3916 g_return_val_if_fail (PANEL_IS_TOPLEVEL (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (widget)"); return ((0)); }
} while (0)
;
3917
3918 toplevel = PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
;
3919
3920 if (toplevel->priv->auto_hide && event->detail != GDK_NOTIFY_INFERIOR)
3921 panel_toplevel_queue_auto_unhide (toplevel);
3922
3923 if (GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->enter_notify_event)
3924 return GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->enter_notify_event (widget, event);
3925
3926 return FALSE(0);
3927}
3928
3929static gboolean
3930panel_toplevel_leave_notify_event (GtkWidget *widget,
3931 GdkEventCrossing *event)
3932{
3933 PanelToplevel *toplevel;
3934
3935 g_return_val_if_fail (PANEL_IS_TOPLEVEL (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (widget)"); return ((0)); }
} while (0)
;
3936
3937 toplevel = PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
;
3938
3939 if (toplevel->priv->auto_hide && event->detail != GDK_NOTIFY_INFERIOR)
3940 panel_toplevel_queue_auto_hide (toplevel);
3941
3942 if (GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->leave_notify_event)
3943 return GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->leave_notify_event (widget, event);
3944
3945 return FALSE(0);
3946}
3947
3948static gboolean
3949panel_toplevel_focus_in_event (GtkWidget *widget,
3950 GdkEventFocus *event)
3951{
3952 PanelToplevel *toplevel = PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
;
3953
3954 if (toplevel->priv->state == PANEL_STATE_AUTO_HIDDEN)
3955 panel_toplevel_unhide (toplevel);
3956
3957 if (GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->focus_in_event)
3958 return GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->focus_in_event (widget, event);
3959
3960 return FALSE(0);
3961}
3962
3963static gboolean
3964panel_toplevel_focus_out_event (GtkWidget *widget,
3965 GdkEventFocus *event)
3966{
3967 PanelToplevel *toplevel = PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
;
3968
3969 /* It appears that sometimes we don't get a leave notify event,
3970 but just a focus in/out, so queue the autohide in that case.
3971 If the pointer is inside the panel then obviously we won't hide */
3972 if (toplevel->priv->auto_hide)
3973 panel_toplevel_queue_auto_hide (toplevel);
3974
3975 if (GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->focus_out_event)
3976 return GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->focus_out_event (widget, event);
3977
3978 return FALSE(0);
3979}
3980
3981static void
3982panel_toplevel_style_updated (GtkWidget *widget)
3983{
3984 panel_toplevel_update_hide_buttons (PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
);
3985
3986 if (GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->style_updated)
3987 GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->style_updated (widget);
3988
3989 set_background_default_style (widget);
3990}
3991
3992static void
3993panel_toplevel_drag_threshold_changed (PanelToplevel *toplevel)
3994{
3995 int threshold;
3996
3997 threshold = 0;
3998 g_object_get (G_OBJECT (toplevel->priv->gtk_settings)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->gtk_settings)), (((GType) ((20) <<
(2))))))))
,
3999 "gtk-dnd-drag-threshold", &threshold,
4000 NULL((void*)0));
4001
4002 if (threshold)
4003 toplevel->priv->snap_tolerance = threshold * SNAP_TOLERANCE_FACTOR6;
4004}
4005
4006static void
4007panel_toplevel_update_gtk_settings (PanelToplevel *toplevel)
4008{
4009 if (toplevel->priv->gtk_settings)
4010 g_signal_handlers_disconnect_by_func (toplevel->priv->gtk_settings,g_signal_handlers_disconnect_matched ((toplevel->priv->
gtk_settings), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (panel_toplevel_drag_threshold_changed
))), (toplevel))
4011 G_CALLBACK (panel_toplevel_drag_threshold_changed),g_signal_handlers_disconnect_matched ((toplevel->priv->
gtk_settings), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (panel_toplevel_drag_threshold_changed
))), (toplevel))
4012 toplevel)g_signal_handlers_disconnect_matched ((toplevel->priv->
gtk_settings), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (panel_toplevel_drag_threshold_changed
))), (toplevel))
;
4013
4014 toplevel->priv->gtk_settings = gtk_widget_get_settings (GTK_WIDGET (toplevel->priv->panel_widget)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->panel_widget)), ((gtk_widget_get_type
()))))))
);
4015
4016 g_signal_connect_swapped (toplevel->priv->gtk_settings, "notify::gtk-dnd-drag-threshold",g_signal_connect_data ((toplevel->priv->gtk_settings), (
"notify::gtk-dnd-drag-threshold"), (((GCallback) (panel_toplevel_drag_threshold_changed
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
4017 G_CALLBACK (panel_toplevel_drag_threshold_changed),g_signal_connect_data ((toplevel->priv->gtk_settings), (
"notify::gtk-dnd-drag-threshold"), (((GCallback) (panel_toplevel_drag_threshold_changed
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
4018 toplevel)g_signal_connect_data ((toplevel->priv->gtk_settings), (
"notify::gtk-dnd-drag-threshold"), (((GCallback) (panel_toplevel_drag_threshold_changed
))), (toplevel), ((void*)0), G_CONNECT_SWAPPED)
;
4019
4020 panel_toplevel_drag_threshold_changed (toplevel);
4021}
4022
4023static void
4024panel_toplevel_screen_changed (GtkWidget *widget,
4025 GdkScreen *previous_screen)
4026{
4027 panel_toplevel_update_gtk_settings (PANEL_TOPLEVEL (widget)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((panel_toplevel_get_type ()))))))
);
4028
4029 if (GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->screen_changed)
4030 GTK_WIDGET_CLASS (panel_toplevel_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), ((gtk_widget_get_type ())
)))))
->screen_changed (widget, previous_screen);
4031
4032 gtk_widget_queue_resize (widget);
4033}
4034
4035static void
4036panel_toplevel_set_property (GObject *object,
4037 guint prop_id,
4038 const GValue *value,
4039 GParamSpec *pspec)
4040{
4041 PanelToplevel *toplevel;
4042
4043 g_return_if_fail (PANEL_IS_TOPLEVEL (object))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((object)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (object)"); return; } } while
(0)
;
4044
4045 toplevel = PANEL_TOPLEVEL (object)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((panel_toplevel_get_type ()))))))
;
4046
4047 switch (prop_id) {
4048 case PROP_NAME:
4049 panel_toplevel_set_name (toplevel, g_value_get_string (value));
4050 break;
4051 case PROP_SETTINGS_PATH:
4052 panel_toplevel_set_settings_path (toplevel, g_value_get_string (value));
4053 break;
4054 case PROP_EXPAND:
4055 panel_toplevel_set_expand (toplevel, g_value_get_boolean (value));
4056 break;
4057 case PROP_ORIENTATION:
4058 panel_toplevel_set_orientation (toplevel, g_value_get_enum (value));
4059 break;
4060 case PROP_SIZE:
4061 panel_toplevel_set_size (toplevel, g_value_get_int (value));
4062 break;
4063 case PROP_X:
4064 panel_toplevel_set_x (toplevel,
4065 g_value_get_int (value),
4066 toplevel->priv->x_right,
4067 toplevel->priv->x_centered);
4068 break;
4069 case PROP_X_RIGHT:
4070 panel_toplevel_set_x (toplevel,
4071 toplevel->priv->x,
4072 g_value_get_int (value),
4073 toplevel->priv->x_centered);
4074 break;
4075 case PROP_X_CENTERED:
4076 panel_toplevel_set_x (toplevel,
4077 toplevel->priv->x,
4078 toplevel->priv->x_right,
4079 g_value_get_boolean (value));
4080 break;
4081 case PROP_Y:
4082 panel_toplevel_set_y (toplevel,
4083 g_value_get_int (value),
4084 toplevel->priv->y_bottom,
4085 toplevel->priv->y_centered);
4086 break;
4087 case PROP_Y_BOTTOM:
4088 panel_toplevel_set_y (toplevel,
4089 toplevel->priv->y,
4090 g_value_get_int (value),
4091 toplevel->priv->y_centered);
4092 break;
4093 case PROP_Y_CENTERED:
4094 panel_toplevel_set_y (toplevel,
4095 toplevel->priv->y,
4096 toplevel->priv->y_bottom,
4097 g_value_get_boolean (value));
4098 break;
4099 case PROP_MONITOR:
4100 panel_toplevel_set_monitor (toplevel, g_value_get_int (value));
4101 break;
4102 case PROP_AUTOHIDE:
4103 panel_toplevel_set_auto_hide (toplevel, g_value_get_boolean (value));
4104 break;
4105 case PROP_HIDE_DELAY:
4106 panel_toplevel_set_hide_delay (toplevel, g_value_get_int (value));
4107 break;
4108 case PROP_UNHIDE_DELAY:
4109 panel_toplevel_set_unhide_delay (toplevel, g_value_get_int (value));
4110 break;
4111 case PROP_AUTOHIDE_SIZE:
4112 panel_toplevel_set_auto_hide_size (toplevel, g_value_get_int (value));
4113 break;
4114 case PROP_ANIMATE:
4115 panel_toplevel_set_animate (toplevel, g_value_get_boolean (value));
4116 break;
4117 case PROP_ANIMATION_SPEED:
4118 panel_toplevel_set_animation_speed (toplevel, g_value_get_enum (value));
4119 break;
4120 case PROP_BUTTONS_ENABLED:
4121 panel_toplevel_set_enable_buttons (toplevel, g_value_get_boolean (value));
4122 break;
4123 case PROP_ARROWS_ENABLED:
4124 panel_toplevel_set_enable_arrows (toplevel, g_value_get_boolean (value));
4125 break;
4126 default:
4127 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "panel-toplevel.c", 4127, ("property"), _glib__property_id,
_glib__pspec->name, g_type_name ((((((GTypeClass*) (((GTypeInstance
*) (_glib__pspec))->g_class))->g_type)))), (g_type_name
((((((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
4128 break;
4129 }
4130}
4131
4132static void
4133panel_toplevel_get_property (GObject *object,
4134 guint prop_id,
4135 GValue *value,
4136 GParamSpec *pspec)
4137{
4138 PanelToplevel *toplevel;
4139
4140 g_return_if_fail (PANEL_IS_TOPLEVEL (object))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((object)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (object)"); return; } } while
(0)
;
4141
4142 toplevel = PANEL_TOPLEVEL (object)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((panel_toplevel_get_type ()))))))
;
4143
4144 switch (prop_id) {
4145 case PROP_NAME:
4146 g_value_set_string (value, panel_toplevel_get_name (toplevel));
4147 break;
4148 case PROP_SETTINGS_PATH:
4149 g_value_set_string (value, toplevel->priv->settings_path);
4150 break;
4151 case PROP_EXPAND:
4152 g_value_set_boolean (value, toplevel->priv->expand);
4153 break;
4154 case PROP_ORIENTATION:
4155 g_value_set_enum (value, toplevel->priv->orientation);
4156 break;
4157 case PROP_SIZE:
4158 g_value_set_int (value, toplevel->priv->size);
4159 break;
4160 case PROP_X:
4161 g_value_set_int (value, toplevel->priv->x);
4162 break;
4163 case PROP_X_RIGHT:
4164 g_value_set_int (value, toplevel->priv->x_right);
4165 break;
4166 case PROP_X_CENTERED:
4167 g_value_set_boolean (value, toplevel->priv->x_centered);
4168 break;
4169 case PROP_Y:
4170 g_value_set_int (value, toplevel->priv->y);
4171 break;
4172 case PROP_Y_BOTTOM:
4173 g_value_set_int (value, toplevel->priv->y_bottom);
4174 break;
4175 case PROP_Y_CENTERED:
4176 g_value_set_boolean (value, toplevel->priv->y_centered);
4177 break;
4178 case PROP_MONITOR:
4179 g_value_set_int (value, toplevel->priv->monitor);
4180 break;
4181 case PROP_AUTOHIDE:
4182 g_value_set_boolean (value, toplevel->priv->auto_hide);
4183 break;
4184 case PROP_HIDE_DELAY:
4185 g_value_set_int (value, toplevel->priv->hide_delay);
4186 break;
4187 case PROP_UNHIDE_DELAY:
4188 g_value_set_int (value, toplevel->priv->unhide_delay);
4189 break;
4190 case PROP_AUTOHIDE_SIZE:
4191 g_value_set_int (value, toplevel->priv->auto_hide_size);
4192 break;
4193 case PROP_ANIMATE:
4194 g_value_set_boolean (value, toplevel->priv->animate);
4195 break;
4196 case PROP_ANIMATION_SPEED:
4197 g_value_set_enum (value, toplevel->priv->animation_speed);
4198 break;
4199 case PROP_BUTTONS_ENABLED:
4200 g_value_set_boolean (value, toplevel->priv->buttons_enabled);
4201 break;
4202 case PROP_ARROWS_ENABLED:
4203 g_value_set_boolean (value, toplevel->priv->arrows_enabled);
4204 break;
4205 default:
4206 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "panel-toplevel.c", 4206, ("property"), _glib__property_id,
_glib__pspec->name, g_type_name ((((((GTypeClass*) (((GTypeInstance
*) (_glib__pspec))->g_class))->g_type)))), (g_type_name
((((((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
4207 break;
4208 }
4209}
4210
4211static GObject*
4212panel_toplevel_constructor (GType type,
4213 guint n_construct_properties,
4214 GObjectConstructParam *construct_properties)
4215{
4216 GObject *object;
4217
4218 object = G_OBJECT_CLASS (panel_toplevel_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), (((GType) ((20) << (
2))))))))
->constructor (type,
4219 n_construct_properties,
4220 construct_properties);
4221 PanelToplevel *toplevel = PANEL_TOPLEVEL(object)((((PanelToplevel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((panel_toplevel_get_type ()))))))
;
4222 GdkScreen *screen = gtk_widget_get_screen(GTK_WIDGET(toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
4223 GdkVisual *visual = gdk_screen_get_rgba_visual(screen);
4224 gtk_widget_set_visual(GTK_WIDGET(toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
, visual);
4225
4226 return object;
4227}
4228
4229static void
4230panel_toplevel_finalize (GObject *object)
4231{
4232 PanelToplevel *toplevel = (PanelToplevel *) object;
4233
4234#ifdef HAVE_X111
4235 if (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel)))(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gtk_widget_get_display (((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((toplevel)), ((gtk_widget_get_type ()))))
))))); GType __t = ((gdk_x11_display_get_type())); gboolean __r
; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
)
4236 panel_struts_unregister_strut (toplevel);
4237#endif /* HAVE_X11 */
4238
4239 toplevel_list = g_slist_remove (toplevel_list, toplevel);
4240
4241 G_OBJECT_CLASS (panel_toplevel_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((panel_toplevel_parent_class)), (((GType) ((20) << (
2))))))))
->finalize (object);
4242}
4243
4244static void
4245panel_toplevel_class_init (PanelToplevelClass *klass)
4246{
4247 GObjectClass *gobject_class = (GObjectClass *) klass;
4248 GtkWidgetClass *widget_class = (GtkWidgetClass *) klass;
4249 GtkContainerClass *container_class = (GtkContainerClass *) klass;
4250 GtkBindingSet *binding_set;
4251
4252 binding_set = gtk_binding_set_by_class (klass);
4253
4254 gobject_class->constructor = panel_toplevel_constructor;
4255 gobject_class->set_property = panel_toplevel_set_property;
4256 gobject_class->get_property = panel_toplevel_get_property;
4257 gobject_class->finalize = panel_toplevel_finalize;
4258
4259 gobject_class->dispose = panel_toplevel_dispose;
4260
4261 widget_class->realize = panel_toplevel_realize;
4262 widget_class->unrealize = panel_toplevel_unrealize;
4263 widget_class->state_flags_changed = panel_toplevel_state_flags_changed;
4264 widget_class->draw = panel_toplevel_draw;
4265 widget_class->get_preferred_width = panel_toplevel_get_preferred_width;
4266 widget_class->get_preferred_height = panel_toplevel_get_preferred_height;
4267 widget_class->style_updated = panel_toplevel_style_updated;
4268 widget_class->size_allocate = panel_toplevel_size_allocate;
4269 widget_class->button_press_event = panel_toplevel_button_press_event;
4270 widget_class->button_release_event = panel_toplevel_button_release_event;
4271 widget_class->configure_event = panel_toplevel_configure_event;
4272 widget_class->key_press_event = panel_toplevel_key_press_event;
4273 widget_class->motion_notify_event = panel_toplevel_motion_notify_event;
4274 widget_class->enter_notify_event = panel_toplevel_enter_notify_event;
4275 widget_class->leave_notify_event = panel_toplevel_leave_notify_event;
4276 widget_class->screen_changed = panel_toplevel_screen_changed;
4277 widget_class->focus_in_event = panel_toplevel_focus_in_event;
4278 widget_class->focus_out_event = panel_toplevel_focus_out_event;
4279
4280 gtk_widget_class_set_css_name (widget_class, "PanelToplevel");
4281
4282 container_class->check_resize = panel_toplevel_check_resize;
4283
4284 klass->hiding = NULL((void*)0);
4285 klass->unhiding = NULL((void*)0);
4286 klass->popup_panel_menu = panel_toplevel_popup_panel_menu;
4287 klass->toggle_expand = panel_toplevel_toggle_expand;
4288 klass->expand = panel_toplevel_expand;
4289 klass->unexpand = panel_toplevel_unexpand;
4290 klass->toggle_hidden = panel_toplevel_toggle_hidden;
4291 klass->begin_move = panel_toplevel_begin_move;
4292 klass->begin_resize = panel_toplevel_begin_resize;
4293
4294 g_object_class_install_property (
4295 gobject_class,
4296 PROP_NAME,
4297 g_param_spec_string (
4298 "name",
4299 "Name",
4300 "The name of this panel",
4301 NULL((void*)0),
4302 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4303
4304 g_object_class_install_property (
4305 gobject_class,
4306 PROP_SETTINGS_PATH,
4307 g_param_spec_string (
4308 "settings-path",
4309 "GSettings path",
4310 "The GSettings path used for this panel",
4311 NULL((void*)0),
4312 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4313
4314 g_object_class_install_property (
4315 gobject_class,
4316 PROP_EXPAND,
4317 g_param_spec_boolean (
4318 "expand",
4319 "Expand",
4320 "Expand to take up the full monitor width/height",
4321 TRUE(!(0)),
4322 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4323
4324 g_object_class_install_property (
4325 gobject_class,
4326 PROP_ORIENTATION,
4327 g_param_spec_enum (
4328 "orientation",
4329 "Orientation",
4330 "The orientation of the panel",
4331 PANEL_TYPE_ORIENTATIONpanel_orientation_get_type(),
4332 PANEL_ORIENTATION_TOP,
4333 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4334
4335 g_object_class_install_property (
4336 gobject_class,
4337 PROP_SIZE,
4338 g_param_spec_int (
4339 "size",
4340 "Size",
4341 "The height (or width when vertical) of the panel",
4342 0,
4343 G_MAXINT2147483647,
4344 DEFAULT_SIZE48,
4345 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4346
4347 g_object_class_install_property (
4348 gobject_class,
4349 PROP_X,
4350 g_param_spec_int (
4351 "x",
4352 "X position",
4353 "The X position of the panel",
4354 0,
4355 G_MAXINT2147483647,
4356 0,
4357 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4358
4359 g_object_class_install_property (
4360 gobject_class,
4361 PROP_X_RIGHT,
4362 g_param_spec_int (
4363 "x-right",
4364 "X position, from the right",
4365 "The X position of the panel, starting from the right of the screen",
4366 -1,
4367 G_MAXINT2147483647,
4368 -1,
4369 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4370
4371 g_object_class_install_property (
4372 gobject_class,
4373 PROP_X_CENTERED,
4374 g_param_spec_boolean (
4375 "x-centered",
4376 "X centered",
4377 "The x co-ordinate is relative to center screen",
4378 FALSE(0),
4379 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4380
4381 g_object_class_install_property (
4382 gobject_class,
4383 PROP_Y,
4384 g_param_spec_int (
4385 "y",
4386 "Y position",
4387 "The Y position of the panel",
4388 0,
4389 G_MAXINT2147483647,
4390 0,
4391 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4392
4393 g_object_class_install_property (
4394 gobject_class,
4395 PROP_Y_BOTTOM,
4396 g_param_spec_int (
4397 "y_bottom",
4398 "Y position, from the bottom",
4399 "The Y position of the panel, starting from the bottom of the screen",
4400 -1,
4401 G_MAXINT2147483647,
4402 -1,
4403 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4404
4405 g_object_class_install_property (
4406 gobject_class,
4407 PROP_Y_CENTERED,
4408 g_param_spec_boolean (
4409 "y-centered",
4410 "Y centered",
4411 "The y co-ordinate is relative to center screen",
4412 FALSE(0),
4413 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4414
4415 g_object_class_install_property (
4416 gobject_class,
4417 PROP_MONITOR,
4418 g_param_spec_int (
4419 "monitor",
4420 "Xinerama monitor",
4421 "The monitor (in terms of Xinerama) which the panel is on",
4422 0,
4423 G_MAXINT2147483647,
4424 0,
4425 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4426
4427 g_object_class_install_property (
4428 gobject_class,
4429 PROP_AUTOHIDE,
4430 g_param_spec_boolean (
4431 "auto-hide",
4432 "Auto hide",
4433 "Automatically hide the panel when the mouse leaves the panel",
4434 FALSE(0),
4435 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4436
4437 g_object_class_install_property (
4438 gobject_class,
4439 PROP_HIDE_DELAY,
4440 g_param_spec_int (
4441 "hide-delay",
4442 "Hide delay",
4443 "The number of milliseconds to delay before automatically hiding",
4444 0,
4445 G_MAXINT2147483647,
4446 DEFAULT_HIDE_DELAY300,
4447 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4448
4449 g_object_class_install_property (
4450 gobject_class,
4451 PROP_UNHIDE_DELAY,
4452 g_param_spec_int (
4453 "unhide-delay",
4454 "Un-hide delay",
4455 "The number of milliseconds to delay before automatically un-hiding",
4456 0,
4457 G_MAXINT2147483647,
4458 DEFAULT_UNHIDE_DELAY100,
4459 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4460
4461 g_object_class_install_property (
4462 gobject_class,
4463 PROP_AUTOHIDE_SIZE,
4464 g_param_spec_int (
4465 "auto-hide-size",
4466 "Auto-hide size",
4467 "The number of pixels visible when the panel has been automatically hidden",
4468 1,
4469 G_MAXINT2147483647,
4470 DEFAULT_AUTO_HIDE_SIZE1,
4471 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4472
4473 g_object_class_install_property (
4474 gobject_class,
4475 PROP_ANIMATE,
4476 g_param_spec_boolean (
4477 "animate",
4478 "Animate",
4479 "Enable hiding/showing animations",
4480 TRUE(!(0)),
4481 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4482
4483 g_object_class_install_property (
4484 gobject_class,
4485 PROP_ANIMATION_SPEED,
4486 g_param_spec_enum (
4487 "animation-speed",
4488 "Animation Speed",
4489 "The speed at which to animate panel hiding/showing",
4490 PANEL_TYPE_ANIMATION_SPEEDpanel_animation_speed_get_type(),
4491 PANEL_ANIMATION_MEDIUM,
4492 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4493
4494 g_object_class_install_property (
4495 gobject_class,
4496 PROP_BUTTONS_ENABLED,
4497 g_param_spec_boolean (
4498 "buttons-enabled",
4499 "Buttons Enabled",
4500 "Enable hide/show buttons",
4501 TRUE(!(0)),
4502 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4503
4504 g_object_class_install_property (
4505 gobject_class,
4506 PROP_ARROWS_ENABLED,
4507 g_param_spec_boolean (
4508 "arrows-enabled",
4509 "Arrows Enabled",
4510 "Enable arrows on hide/show buttons",
4511 TRUE(!(0)),
4512 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
4513
4514 gtk_widget_class_install_style_property (
4515 widget_class,
4516 g_param_spec_int (
4517 "arrow-size",
4518 "Arrow Size",
4519 "The size of the arrows on the hide/show buttons",
4520 0,
4521 G_MAXINT2147483647,
4522 DEFAULT_ARROW_SIZE20,
4523 G_PARAM_READABLE));
4524
4525 toplevel_signals [HIDE_SIGNAL] =
4526 g_signal_new ("hiding",
4527 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
4528 G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
4529 G_STRUCT_OFFSET (PanelToplevelClass, hiding)((glong) __builtin_offsetof(PanelToplevelClass, hiding)),
4530 NULL((void*)0),
4531 NULL((void*)0),
4532 g_cclosure_marshal_VOID__VOID,
4533 G_TYPE_NONE((GType) ((1) << (2))),
4534 0);
4535
4536 toplevel_signals [UNHIDE_SIGNAL] =
4537 g_signal_new ("unhiding",
4538 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
4539 G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
4540 G_STRUCT_OFFSET (PanelToplevelClass, unhiding)((glong) __builtin_offsetof(PanelToplevelClass, unhiding)),
4541 NULL((void*)0),
4542 NULL((void*)0),
4543 g_cclosure_marshal_VOID__VOID,
4544 G_TYPE_NONE((GType) ((1) << (2))),
4545 0);
4546
4547 toplevel_signals [POPUP_PANEL_MENU_SIGNAL] =
4548 g_signal_new ("popup-panel-menu",
4549 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
4550 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
4551 G_STRUCT_OFFSET (PanelToplevelClass, popup_panel_menu)((glong) __builtin_offsetof(PanelToplevelClass, popup_panel_menu
))
,
4552 NULL((void*)0),
4553 NULL((void*)0),
4554 panel_marshal_BOOLEAN__VOID,
4555 G_TYPE_BOOLEAN((GType) ((5) << (2))),
4556 0);
4557
4558 toplevel_signals [TOGGLE_EXPAND_SIGNAL] =
4559 g_signal_new ("toggle-expand",
4560 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
4561 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
4562 G_STRUCT_OFFSET (PanelToplevelClass, toggle_expand)((glong) __builtin_offsetof(PanelToplevelClass, toggle_expand
))
,
4563 NULL((void*)0),
4564 NULL((void*)0),
4565 panel_marshal_BOOLEAN__VOID,
4566 G_TYPE_BOOLEAN((GType) ((5) << (2))),
4567 0);
4568
4569 toplevel_signals [EXPAND_SIGNAL] =
4570 g_signal_new ("expand",
4571 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
4572 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
4573 G_STRUCT_OFFSET (PanelToplevelClass, expand)((glong) __builtin_offsetof(PanelToplevelClass, expand)),
4574 NULL((void*)0),
4575 NULL((void*)0),
4576 panel_marshal_BOOLEAN__VOID,
4577 G_TYPE_BOOLEAN((GType) ((5) << (2))),
4578 0);
4579
4580 toplevel_signals [UNEXPAND_SIGNAL] =
4581 g_signal_new ("unexpand",
4582 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
4583 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
4584 G_STRUCT_OFFSET (PanelToplevelClass, unexpand)((glong) __builtin_offsetof(PanelToplevelClass, unexpand)),
4585 NULL((void*)0),
4586 NULL((void*)0),
4587 panel_marshal_BOOLEAN__VOID,
4588 G_TYPE_BOOLEAN((GType) ((5) << (2))),
4589 0);
4590
4591 toplevel_signals [TOGGLE_HIDDEN_SIGNAL] =
4592 g_signal_new ("toggle-hidden",
4593 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
4594 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
4595 G_STRUCT_OFFSET (PanelToplevelClass, toggle_hidden)((glong) __builtin_offsetof(PanelToplevelClass, toggle_hidden
))
,
4596 NULL((void*)0),
4597 NULL((void*)0),
4598 panel_marshal_BOOLEAN__VOID,
4599 G_TYPE_BOOLEAN((GType) ((5) << (2))),
4600 0);
4601
4602 toplevel_signals [BEGIN_MOVE_SIGNAL] =
4603 g_signal_new ("begin-move",
4604 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
4605 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
4606 G_STRUCT_OFFSET (PanelToplevelClass, begin_move)((glong) __builtin_offsetof(PanelToplevelClass, begin_move)),
4607 NULL((void*)0),
4608 NULL((void*)0),
4609 panel_marshal_BOOLEAN__VOID,
4610 G_TYPE_BOOLEAN((GType) ((5) << (2))),
4611 0);
4612
4613 toplevel_signals [BEGIN_RESIZE_SIGNAL] =
4614 g_signal_new ("begin-resize",
4615 G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type),
4616 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
4617 G_STRUCT_OFFSET (PanelToplevelClass, begin_resize)((glong) __builtin_offsetof(PanelToplevelClass, begin_resize)
)
,
4618 NULL((void*)0),
4619 NULL((void*)0),
4620 panel_marshal_BOOLEAN__VOID,
4621 G_TYPE_BOOLEAN((GType) ((5) << (2))),
4622 0);
4623
4624 gtk_binding_entry_add_signal (binding_set, GDK_KEY_F100xffc7, GDK_CONTROL_MASK,
4625 "popup_panel_menu", 0);
4626
4627 panel_bindings_set_entries (binding_set);
4628}
4629
4630static void
4631panel_toplevel_setup_widgets (PanelToplevel *toplevel)
4632{
4633 GtkWidget* container;
4634
4635 toplevel->priv->grid = gtk_grid_new ();
4636
4637 toplevel->priv->hide_button_top = panel_toplevel_add_hide_button (toplevel, GTK_ARROW_UP, 1, 0);
4638 toplevel->priv->hide_button_bottom = panel_toplevel_add_hide_button (toplevel, GTK_ARROW_DOWN, 1, 2);
4639 toplevel->priv->hide_button_left = panel_toplevel_add_hide_button (toplevel, GTK_ARROW_LEFT, 0, 1);
4640 toplevel->priv->hide_button_right = panel_toplevel_add_hide_button (toplevel, GTK_ARROW_RIGHT, 2, 1);
4641
4642 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM))
4643 {
4644 gtk_widget_show(toplevel->priv->hide_button_left);
4645 gtk_widget_show(toplevel->priv->hide_button_right);
4646 }
4647 else
4648 {
4649 gtk_widget_show(toplevel->priv->hide_button_top);
4650 gtk_widget_show(toplevel->priv->hide_button_bottom);
4651 }
4652
4653 toplevel->priv->inner_frame = g_object_new(PANEL_TYPE_FRAME(panel_frame_get_type ()), NULL((void*)0));
4654
4655 gtk_widget_set_hexpand (GTK_WIDGET (toplevel->priv->inner_frame)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->inner_frame)), ((gtk_widget_get_type
()))))))
, TRUE(!(0)));
4656 gtk_widget_set_vexpand (GTK_WIDGET (toplevel->priv->inner_frame)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->inner_frame)), ((gtk_widget_get_type
()))))))
, TRUE(!(0)));
4657
4658 gtk_grid_attach (GTK_GRID (toplevel->priv->grid)((((GtkGrid*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->grid)), ((gtk_grid_get_type ()))))
))
, GTK_WIDGET (toplevel->priv->inner_frame)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->inner_frame)), ((gtk_widget_get_type
()))))))
, 1, 1, 1, 1);
4659 gtk_widget_show (GTK_WIDGET (toplevel->priv->inner_frame)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->inner_frame)), ((gtk_widget_get_type
()))))))
);
4660
4661 container = panel_widget_new (toplevel,
4662 !toplevel->priv->expand,
4663 (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)) ?
4664 GTK_ORIENTATION_HORIZONTAL :
4665 GTK_ORIENTATION_VERTICAL,
4666 toplevel->priv->size);
4667
4668 toplevel->priv->panel_widget = PANEL_WIDGET(container)((((PanelWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((container)), ((panel_widget_get_type()))))))
;
4669
4670 gtk_container_add(GTK_CONTAINER(toplevel->priv->inner_frame)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel->priv->inner_frame)), ((gtk_container_get_type
()))))))
, container);
4671 gtk_widget_show(container);
4672
4673 gtk_container_add (GTK_CONTAINER (toplevel)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_container_get_type ()))))))
, toplevel->priv->grid);
4674 gtk_widget_show (toplevel->priv->grid);
4675}
4676
4677static void
4678background_changed (PanelBackground *background,
4679 PanelToplevel *toplevel)
4680{
4681 panel_toplevel_update_edges (toplevel);
4682 panel_widget_emit_background_changed (toplevel->priv->panel_widget);
4683}
4684
4685static void
4686panel_toplevel_init (PanelToplevel *toplevel)
4687{
4688 GtkWidget *widget;
4689 int i;
4690
4691 toplevel->priv = panel_toplevel_get_instance_private (toplevel);
4692
4693 toplevel->priv->expand = TRUE(!(0));
4694 toplevel->priv->orientation = PANEL_ORIENTATION_BOTTOM;
4695 toplevel->priv->size = DEFAULT_SIZE48;
4696 toplevel->priv->scale = gtk_widget_get_scale_factor (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
4697 toplevel->priv->x = 0;
4698 toplevel->priv->y = 0;
4699 toplevel->priv->x_right = -1;
4700 toplevel->priv->y_bottom = -1;
4701 toplevel->priv->monitor = 0;
4702 toplevel->priv->configured_monitor = -1;
4703 toplevel->priv->hide_delay = DEFAULT_HIDE_DELAY300;
4704 toplevel->priv->unhide_delay = DEFAULT_UNHIDE_DELAY100;
4705 toplevel->priv->auto_hide_size = DEFAULT_AUTO_HIDE_SIZE1;
4706 toplevel->priv->animation_speed = PANEL_ANIMATION_FAST;
4707
4708 toplevel->priv->snap_tolerance = DEFAULT_DND_THRESHOLD8 * SNAP_TOLERANCE_FACTOR6;
4709 toplevel->priv->gtk_settings = NULL((void*)0);
4710
4711 toplevel->priv->state = PANEL_STATE_NORMAL;
4712
4713 toplevel->priv->name = NULL((void*)0);
4714 toplevel->priv->description = NULL((void*)0);
4715
4716 toplevel->priv->hide_timeout = 0;
4717 toplevel->priv->unhide_timeout = 0;
4718
4719 toplevel->priv->geometry.x = -1;
4720 toplevel->priv->geometry.y = -1;
4721 toplevel->priv->geometry.width = -1;
4722 toplevel->priv->geometry.height = -1;
4723
4724 toplevel->priv->original_width = -1;
4725 toplevel->priv->original_height = -1;
4726
4727 toplevel->priv->grab_op = PANEL_GRAB_OP_NONE;
4728
4729 toplevel->priv->drag_offset_x = 0;
4730 toplevel->priv->drag_offset_y = 0;
4731
4732 toplevel->priv->animation_end_x = 0;
4733 toplevel->priv->animation_end_y = 0;
4734 toplevel->priv->animation_end_width = 0;
4735 toplevel->priv->animation_end_height = 0;
4736 toplevel->priv->animation_start_time = 0;
4737 toplevel->priv->animation_duration_time = 0;
4738 toplevel->priv->animation_timeout = 0;
4739
4740 toplevel->priv->panel_widget = NULL((void*)0);
4741 toplevel->priv->inner_frame = NULL((void*)0);
4742 toplevel->priv->grid = NULL((void*)0);
4743 toplevel->priv->hide_button_top = NULL((void*)0);
4744 toplevel->priv->hide_button_bottom = NULL((void*)0);
4745 toplevel->priv->hide_button_left = NULL((void*)0);
4746 toplevel->priv->hide_button_right = NULL((void*)0);
4747
4748 toplevel->priv->attach_toplevel = NULL((void*)0);
4749 toplevel->priv->attach_widget = NULL((void*)0);
4750 toplevel->priv->n_autohide_disablers = 0;
4751
4752 for (i = 0; i < N_ATTACH_TOPLEVEL_SIGNALS5; i++)
4753 toplevel->priv->attach_toplevel_signals [i] = 0;
4754 for (i = 0; i < N_ATTACH_WIDGET_SIGNALS5; i++)
4755 toplevel->priv->attach_widget_signals [i] = 0;
4756
4757 toplevel->priv->auto_hide = FALSE(0);
4758 toplevel->priv->buttons_enabled = TRUE(!(0));
4759 toplevel->priv->arrows_enabled = TRUE(!(0));
4760 toplevel->priv->x_centered = FALSE(0);
4761 toplevel->priv->y_centered = FALSE(0);
4762 toplevel->priv->animating = FALSE(0);
4763 toplevel->priv->grab_is_keyboard = FALSE(0);
4764 toplevel->priv->position_centered = FALSE(0);
4765 toplevel->priv->attached = FALSE(0);
4766 toplevel->priv->attach_hidden = FALSE(0);
4767 toplevel->priv->updated_geometry_initial = FALSE(0);
4768 toplevel->priv->initial_animation_done = FALSE(0);
4769
4770 widget = GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
;
4771 gtk_widget_add_events (widget,
4772 GDK_BUTTON_PRESS_MASK |
4773 GDK_BUTTON_RELEASE_MASK |
4774 GDK_POINTER_MOTION_MASK |
4775 GDK_ENTER_NOTIFY_MASK |
4776 GDK_LEAVE_NOTIFY_MASK);
4777
4778 gtk_widget_set_app_paintable (widget, TRUE(!(0)));
4779
4780 panel_toplevel_setup_widgets (toplevel);
4781 panel_toplevel_update_description (toplevel);
4782 panel_toplevel_update_gtk_settings (toplevel);
4783
4784 toplevel_list = g_slist_prepend (toplevel_list, toplevel);
4785
4786 /* Prevent the window from being deleted via Alt+F4 by accident. This
4787 * happens with "alternative" window managers such as Sawfish or XFWM4.
4788 */
4789 g_signal_connect (toplevel, "delete-event", G_CALLBACK(gtk_true), NULL)g_signal_connect_data ((toplevel), ("delete-event"), (((GCallback
) (gtk_true))), (((void*)0)), ((void*)0), (GConnectFlags) 0)
;
4790
4791 panel_background_init (&toplevel->background,
4792 (PanelBackgroundChangedNotify) background_changed,
4793 toplevel);
4794
4795 update_style_classes (toplevel);
4796
4797#ifdef HAVE_WAYLAND1
4798 if (GDK_IS_WAYLAND_DISPLAY (gdk_display_get_default ())(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gdk_display_get_default ())); GType __t = ((gdk_wayland_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
) {
4799 wayland_panel_toplevel_init (toplevel);
4800 }
4801#endif /* HAVE_WAYLAND */
4802}
4803
4804PanelWidget *
4805panel_toplevel_get_panel_widget (PanelToplevel *toplevel)
4806{
4807
4808 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return (((void
*)0)); } } while (0)
;
4809
4810 return toplevel->priv->panel_widget;
4811}
4812
4813static void
4814panel_toplevel_update_name (PanelToplevel *toplevel)
4815{
4816 char *title;
4817
4818 g_assert (toplevel->priv->description != NULL)do { if (toplevel->priv->description != ((void*)0)) ; else
g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c", 4818
, ((const char*) (__func__)), "toplevel->priv->description != NULL"
); } while (0)
;
4819
4820 title = toplevel->priv->name ? toplevel->priv->name : toplevel->priv->description;
4821
4822 gtk_window_set_title (GTK_WINDOW (toplevel)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_window_get_type ()))))))
, title);
4823
4824 panel_a11y_set_atk_name_desc (
4825 GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
,
4826 title, toplevel->priv->description);
4827}
4828
4829void
4830panel_toplevel_set_name (PanelToplevel *toplevel,
4831 const char *name)
4832{
4833 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
4834
4835 if (!toplevel->priv->name && (!name || !name [0]))
4836 return;
4837
4838 if (toplevel->priv->name && name && name [0] &&
4839 !strcmp (toplevel->priv->name, name))
4840 return;
4841
4842 g_free (toplevel->priv->name);
4843 if (name && name [0])
4844 toplevel->priv->name = g_strdup (name)g_strdup_inline (name);
4845 else
4846 toplevel->priv->name = NULL((void*)0);
4847
4848 panel_toplevel_update_name (toplevel);
4849
4850 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "name");
4851}
4852
4853void
4854panel_toplevel_set_settings_path (PanelToplevel *toplevel,
4855 const char *settings_path)
4856{
4857 toplevel->priv->settings_path = g_strdup (settings_path)g_strdup_inline (settings_path);
4858}
4859
4860const char* panel_toplevel_get_name(PanelToplevel* toplevel)
4861{
4862 g_return_val_if_fail(PANEL_IS_TOPLEVEL(toplevel), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL(toplevel)"); return (((void
*)0)); } } while (0)
;
4863
4864 return toplevel->priv->name;
4865}
4866
4867const char* panel_toplevel_get_description(PanelToplevel* toplevel)
4868{
4869 g_return_val_if_fail(PANEL_IS_TOPLEVEL(toplevel), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL(toplevel)"); return (((void
*)0)); } } while (0)
;
4870
4871 return toplevel->priv->description;
4872}
4873
4874void
4875panel_toplevel_set_expand (PanelToplevel *toplevel,
4876 gboolean expand)
4877{
4878 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
4879
4880 if (toplevel->priv->attached && expand) {
4881 g_warning ("attempt to expand attached toplevel; ignoring");
4882 return;
4883 }
4884
4885 expand = expand != FALSE(0);
4886
4887 if (toplevel->priv->expand == expand)
4888 return;
4889
4890 toplevel->priv->expand = expand;
4891
4892 if (!toplevel->priv->expand && toplevel->priv->updated_geometry_initial) {
4893 switch (toplevel->priv->orientation) {
4894 case PANEL_ORIENTATION_TOP:
4895 panel_toplevel_set_x (toplevel, 0, -1, TRUE(!(0)));
4896 break;
4897 case PANEL_ORIENTATION_BOTTOM:
4898 panel_toplevel_set_x (toplevel, 0, 0, TRUE(!(0)));
4899 break;
4900 case PANEL_ORIENTATION_LEFT:
4901 panel_toplevel_set_y (toplevel, 0, -1, TRUE(!(0)));
4902 break;
4903 case PANEL_ORIENTATION_RIGHT:
4904 panel_toplevel_set_y (toplevel, 0, 0, TRUE(!(0)));
4905 break;
4906 default:
4907 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-toplevel.c"
, 4907, ((const char*) (__func__)), ((void*)0)); } while (0)
;
4908 break;
4909 }
4910 }
4911
4912 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
4913
4914 panel_widget_set_packed (toplevel->priv->panel_widget, !toplevel->priv->expand);
4915
4916 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "expand");
4917}
4918
4919gboolean
4920panel_toplevel_get_expand (PanelToplevel *toplevel)
4921{
4922 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), TRUE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return ((!(0)
)); } } while (0)
;
4923
4924 return toplevel->priv->expand;
4925}
4926
4927gboolean
4928panel_toplevel_get_is_floating (PanelToplevel *toplevel)
4929{
4930 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), TRUE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return ((!(0)
)); } } while (0)
;
4931
4932 return toplevel->priv->floating;
4933}
4934
4935void
4936panel_toplevel_set_orientation (PanelToplevel *toplevel,
4937 PanelOrientation orientation)
4938{
4939 gboolean rotate;
4940 GdkRectangle monitor_geom;
4941
4942 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
4943
4944 if (toplevel->priv->orientation == orientation)
4945 return;
4946
4947 g_object_freeze_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
);
4948
4949 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
4950
4951 /* Un-snap from center if no longer along screen edge */
4952 if (toplevel->priv->x_centered &&
4953 (orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT))) {
4954 toplevel->priv->x_centered = FALSE(0);
4955 toplevel->priv->x = (monitor_geom.width - toplevel->priv->geometry.width) / 2;
4956 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "x");
4957 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "x-centered");
4958
4959 if (toplevel->priv->x_right != -1) {
4960 toplevel->priv->x_right = -1;
4961 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "x-right");
4962 }
4963 }
4964
4965 if (toplevel->priv->y_centered &&
4966 (orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM))) {
4967 toplevel->priv->y_centered = FALSE(0);
4968 toplevel->priv->y = (monitor_geom.height - toplevel->priv->geometry.height) / 2;
4969 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "y");
4970 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "y-centered");
4971
4972 if (toplevel->priv->y_bottom != -1) {
4973 toplevel->priv->y_bottom = -1;
4974 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "y-bottom");
4975 }
4976 }
4977
4978 rotate = FALSE(0);
4979 if ((orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)) &&
4980 (toplevel->priv->orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT)))
4981 rotate = TRUE(!(0));
4982 else if ((orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT)) &&
4983 (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)))
4984 rotate = TRUE(!(0));
4985
4986 /* rotate around the center */
4987 if (rotate && !toplevel->priv->position_centered && !toplevel->priv->expand &&
4988 toplevel->priv->updated_geometry_initial) {
4989 toplevel->priv->position_centered = TRUE(!(0));
4990
4991 /* x, y temporary refer to the panel center, so we don't care
4992 * about x_right, y_bottom. Those will get updated in
4993 * panel_toplevel_update_position() accordingly. */
4994 if (!toplevel->priv->x_centered) {
4995 toplevel->priv->x += toplevel->priv->geometry.width / 2;
4996 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "x");
4997 }
4998
4999 if (!toplevel->priv->y_centered) {
5000 toplevel->priv->y += toplevel->priv->geometry.height / 2;
5001 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "y");
5002 }
5003
5004 }
5005
5006 toplevel->priv->orientation = orientation;
5007 update_style_classes (toplevel);
5008
5009 gtk_widget_reset_style (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
5010
5011 panel_toplevel_update_hide_buttons (toplevel);
5012
5013 panel_widget_set_orientation (
5014 toplevel->priv->panel_widget,
5015 (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)) ?
5016 GTK_ORIENTATION_HORIZONTAL :
5017 GTK_ORIENTATION_VERTICAL);
5018
5019 switch (toplevel->priv->state) {
5020 case PANEL_STATE_HIDDEN_UP:
5021 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM))
5022 toplevel->priv->state = PANEL_STATE_HIDDEN_LEFT;
5023 break;
5024 case PANEL_STATE_HIDDEN_DOWN:
5025 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM))
5026 toplevel->priv->state = PANEL_STATE_HIDDEN_RIGHT;
5027 break;
5028 case PANEL_STATE_HIDDEN_LEFT:
5029 if (toplevel->priv->orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT))
5030 toplevel->priv->state = PANEL_STATE_HIDDEN_UP;
5031 break;
5032 case PANEL_STATE_HIDDEN_RIGHT:
5033 if (toplevel->priv->orientation & PANEL_VERTICAL_MASK(PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT))
5034 toplevel->priv->state = PANEL_STATE_HIDDEN_DOWN;
5035 break;
5036 default:
5037 break;
5038 }
5039
5040 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
5041
5042 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "orientation");
5043
5044 g_object_thaw_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
);
5045
5046#ifdef HAVE_WAYLAND1
5047 if (GDK_IS_WAYLAND_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel)))(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gtk_widget_get_display (((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((toplevel)), ((gtk_widget_get_type ()))))
))))); GType __t = ((gdk_wayland_display_get_type())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
) {
5048 wayland_panel_toplevel_update_placement (toplevel);
5049 }
5050#endif /* HAVE_WAYLAND */
5051}
5052
5053PanelOrientation
5054panel_toplevel_get_orientation (PanelToplevel *toplevel)
5055{
5056 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), PANEL_ORIENTATION_TOP)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return (PANEL_ORIENTATION_TOP
); } } while (0)
;
5057
5058 return toplevel->priv->orientation;
5059}
5060
5061void
5062panel_toplevel_set_size (PanelToplevel *toplevel,
5063 int size)
5064{
5065 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
5066 g_return_if_fail (size >= 0)do { if ((size >= 0)) { } else { g_return_if_fail_warning (
((gchar*) 0), ((const char*) (__func__)), "size >= 0"); return
; } } while (0)
;
5067
5068 if (toplevel->priv->size == size)
5069 return;
5070
5071 toplevel->priv->size = size;
5072
5073 panel_widget_set_size (toplevel->priv->panel_widget, toplevel->priv->size);
5074
5075 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
5076
5077 panel_toplevel_update_hide_buttons (toplevel);
5078
5079 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "size");
5080}
5081
5082int
5083panel_toplevel_get_size (PanelToplevel *toplevel)
5084{
5085 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), DEFAULT_SIZE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return (48); }
} while (0)
;
5086
5087 return toplevel->priv->size;
5088}
5089
5090void
5091panel_toplevel_set_auto_hide_size (PanelToplevel *toplevel,
5092 int auto_hide_size)
5093{
5094 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
5095
5096 if (toplevel->priv->auto_hide_size == auto_hide_size)
5097 return;
5098
5099 toplevel->priv->auto_hide_size = auto_hide_size;
5100
5101 if (toplevel->priv->state == PANEL_STATE_AUTO_HIDDEN) {
5102 if (panel_toplevel_update_struts (toplevel, FALSE(0))) {
5103 if (toplevel->priv->animate) {
5104 panel_toplevel_unhide (toplevel);
5105 panel_toplevel_hide (toplevel, TRUE(!(0)), -1);
5106 } else
5107 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
5108 }
5109 }
5110
5111 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "auto-hide-size");
5112}
5113
5114int
5115panel_toplevel_get_auto_hide_size (PanelToplevel *toplevel)
5116{
5117 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), DEFAULT_AUTO_HIDE_SIZE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return (1); }
} while (0)
;
5118
5119 return toplevel->priv->auto_hide_size;
5120}
5121
5122void
5123panel_toplevel_set_x (PanelToplevel *toplevel,
5124 int x,
5125 int x_right,
5126 gboolean x_centered)
5127{
5128 gboolean changed = FALSE(0);
5129
5130 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
5131
5132 x_centered = x_centered != FALSE(0);
5133
5134 g_object_freeze_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
);
5135
5136 if (toplevel->priv->x != x) {
5137 toplevel->priv->x = x;
5138 changed = TRUE(!(0));
5139 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "x");
5140 }
5141
5142 if (toplevel->priv->x_right != x_right) {
5143 toplevel->priv->x_right = x_right;
5144 changed = TRUE(!(0));
5145 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "x-right");
5146 }
5147
5148 if (toplevel->priv->x_centered != x_centered) {
5149 toplevel->priv->x_centered = (x_centered != FALSE(0));
5150 changed = TRUE(!(0));
5151 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "x-centered");
5152 }
5153
5154 if (changed)
5155 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
5156
5157 g_object_thaw_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
);
5158}
5159
5160void
5161panel_toplevel_set_y (PanelToplevel *toplevel,
5162 int y,
5163 int y_bottom,
5164 gboolean y_centered)
5165{
5166 gboolean changed = FALSE(0);
5167
5168 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
5169
5170 y_centered = y_centered != FALSE(0);
5171
5172 g_object_freeze_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
);
5173
5174 if (toplevel->priv->y != y) {
5175 toplevel->priv->y = y;
5176 changed = TRUE(!(0));
5177 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "y");
5178 }
5179
5180 if (toplevel->priv->y_bottom != y_bottom) {
5181 toplevel->priv->y_bottom = y_bottom;
5182 changed = TRUE(!(0));
5183 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "y-bottom");
5184 }
5185
5186 if (toplevel->priv->y_centered != y_centered) {
5187 toplevel->priv->y_centered = (y_centered != FALSE(0));
5188 changed = TRUE(!(0));
5189 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "y-centered");
5190 }
5191
5192 if (changed)
5193 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
5194
5195 g_object_thaw_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
);
5196}
5197
5198void
5199panel_toplevel_get_position (PanelToplevel *toplevel,
5200 int *x,
5201 int *x_right,
5202 int *y,
5203 int *y_bottom)
5204{
5205 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
5206
5207 if (x)
5208 *x = toplevel->priv->x;
5209
5210 if (y)
5211 *y = toplevel->priv->y;
5212
5213 if (x_right)
5214 *x_right = toplevel->priv->x_right;
5215
5216 if (y_bottom)
5217 *y_bottom = toplevel->priv->y_bottom;
5218}
5219
5220gboolean
5221panel_toplevel_get_x_centered (PanelToplevel *toplevel)
5222{
5223 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return ((0));
} } while (0)
;
5224
5225 return toplevel->priv->x_centered;
5226}
5227
5228gboolean
5229panel_toplevel_get_y_centered (PanelToplevel *toplevel)
5230{
5231 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return ((0));
} } while (0)
;
5232
5233 return toplevel->priv->y_centered;
5234}
5235
5236/**
5237 * panel_toplevel_set_monitor_internal:
5238 *
5239 * Sets the monitor of the toplevel, but only the internal state. We need to
5240 * make the difference between the internal state and the configuration of the
5241 * user because internal constraints might affect the monitor of the toplevel.
5242 *
5243 * panel_toplevel_set_monitor_internal() won't update the configuration of the
5244 * user.
5245 **/
5246static void
5247panel_toplevel_set_monitor_internal (PanelToplevel *toplevel,
5248 int monitor,
5249 gboolean force_resize)
5250{
5251 if (toplevel->priv->monitor == monitor)
5252 return;
5253
5254 toplevel->priv->monitor = monitor;
5255
5256 if (force_resize)
5257 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
5258}
5259
5260/**
5261 * panel_toplevel_update_monitor:
5262 *
5263 * Moves the toplevel to its configured monitor or the first one, if needed.
5264 * This generally happens when the configured monitor was non-existing before,
5265 * and it appeared at runtime, or if it was existing and disappeared.
5266 *
5267 * This must only be called at the beginning of the size request of the
5268 * toplevel because it doesn't queue a size request.
5269 **/
5270static void
5271panel_toplevel_update_monitor (PanelToplevel *toplevel)
5272{
5273 /* If we were not using the configured monitor, can we use it now? */
5274 if ((toplevel->priv->configured_monitor != -1) &&
5275 (toplevel->priv->configured_monitor != toplevel->priv->monitor) &&
5276 toplevel->priv->configured_monitor < panel_multimonitor_monitors ()) {
5277 panel_toplevel_set_monitor_internal (toplevel,
5278 toplevel->priv->configured_monitor,
5279 FALSE(0));
5280
5281 /* else, can we still use the monitor we were using? */
5282 } else if (toplevel->priv->monitor >= panel_multimonitor_monitors ()) {
5283 panel_toplevel_set_monitor_internal (toplevel,
5284 0,
5285 FALSE(0));
5286 }
5287}
5288
5289void
5290panel_toplevel_set_monitor (PanelToplevel *toplevel,
5291 int monitor)
5292{
5293 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
5294
5295 if (toplevel->priv->configured_monitor == monitor)
5296 return;
5297
5298 toplevel->priv->configured_monitor = monitor;
5299
5300 /* Only use the configured monitor if it's existing. Else, we ignore
5301 * the non-existing monitor, and keep the old one. The main use case is
5302 * when logging in after having used a multimonitor environment.
5303 * We will put the panel on the monitor 0 for this session, and it will
5304 * move back to the right monitor next time. */
5305 if (monitor < panel_multimonitor_monitors ())
5306 panel_toplevel_set_monitor_internal (toplevel, monitor, TRUE(!(0)));
5307
5308 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "monitor");
5309}
5310
5311int
5312panel_toplevel_get_monitor (PanelToplevel *toplevel)
5313{
5314 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), -1)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return (-1); }
} while (0)
;
5315
5316 return toplevel->priv->monitor;
5317}
5318
5319void
5320panel_toplevel_set_auto_hide (PanelToplevel *toplevel,
5321 gboolean auto_hide)
5322{
5323 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
5324
5325 auto_hide = auto_hide != FALSE(0);
5326
5327 if (toplevel->priv->auto_hide == auto_hide)
5328 return;
5329
5330 toplevel->priv->auto_hide = (auto_hide != FALSE(0));
5331
5332 if (toplevel->priv->auto_hide)
5333 panel_toplevel_queue_auto_hide (toplevel);
5334 else
5335 panel_toplevel_queue_auto_unhide (toplevel);
5336
5337 if (panel_toplevel_update_struts (toplevel, FALSE(0)))
5338 gtk_widget_queue_resize (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
);
5339
5340 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "auto-hide");
5341}
5342
5343gboolean
5344panel_toplevel_get_auto_hide (PanelToplevel *toplevel)
5345{
5346 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return ((0));
} } while (0)
;
5347
5348 return toplevel->priv->auto_hide;
5349}
5350
5351void
5352panel_toplevel_set_hide_delay (PanelToplevel *toplevel,
5353 int hide_delay)
5354{
5355 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
5356
5357 if (toplevel->priv->hide_delay == hide_delay)
5358 return;
5359
5360 toplevel->priv->hide_delay = hide_delay;
5361
5362 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "hide-delay");
5363}
5364
5365int
5366panel_toplevel_get_hide_delay (PanelToplevel *toplevel)
5367{
5368 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), -1)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return (-1); }
} while (0)
;
5369
5370 return toplevel->priv->hide_delay;
5371}
5372
5373void
5374panel_toplevel_set_unhide_delay (PanelToplevel *toplevel,
5375 int unhide_delay)
5376{
5377 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
5378
5379 if (toplevel->priv->unhide_delay == unhide_delay)
5380 return;
5381
5382 toplevel->priv->unhide_delay = unhide_delay;
5383
5384 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "unhide-delay");
5385}
5386
5387int
5388panel_toplevel_get_unhide_delay (PanelToplevel *toplevel)
5389{
5390 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), -1)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return (-1); }
} while (0)
;
5391
5392 return toplevel->priv->unhide_delay;
5393}
5394
5395void
5396panel_toplevel_set_animate (PanelToplevel *toplevel,
5397 gboolean animate)
5398{
5399 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
5400
5401 animate = animate != FALSE(0);
5402
5403 if (toplevel->priv->animate == animate)
5404 return;
5405
5406 toplevel->priv->animate = (animate != FALSE(0));
5407
5408 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "animate");
5409}
5410
5411gboolean
5412panel_toplevel_get_animate (PanelToplevel *toplevel)
5413{
5414 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return ((0));
} } while (0)
;
5415
5416 return toplevel->priv->animate;
5417}
5418
5419void
5420panel_toplevel_set_animation_speed (PanelToplevel *toplevel,
5421 PanelAnimationSpeed animation_speed)
5422{
5423 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
5424
5425 if (toplevel->priv->animation_speed == animation_speed)
5426 return;
5427
5428 toplevel->priv->animation_speed = animation_speed;
5429
5430 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "animation-speed");
5431}
5432
5433PanelAnimationSpeed
5434panel_toplevel_get_animation_speed (PanelToplevel *toplevel)
5435{
5436 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), 0)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return (0); }
} while (0)
;
5437
5438 return toplevel->priv->animation_speed;
5439}
5440
5441void
5442panel_toplevel_set_enable_buttons (PanelToplevel *toplevel,
5443 gboolean enable_buttons)
5444{
5445 enable_buttons = enable_buttons != FALSE(0);
5446
5447 if (toplevel->priv->buttons_enabled == enable_buttons)
5448 return;
5449
5450 toplevel->priv->buttons_enabled = enable_buttons;
5451
5452 panel_toplevel_update_hide_buttons (toplevel);
5453
5454 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "buttons-enabled");
5455}
5456
5457gboolean
5458panel_toplevel_get_enable_buttons (PanelToplevel *toplevel)
5459{
5460 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return ((0));
} } while (0)
;
5461
5462 return toplevel->priv->buttons_enabled;
5463}
5464
5465void
5466panel_toplevel_set_enable_arrows (PanelToplevel *toplevel,
5467 gboolean enable_arrows)
5468{
5469 g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return; } } while
(0)
;
5470
5471 enable_arrows = enable_arrows != FALSE(0);
5472
5473 if (toplevel->priv->arrows_enabled == enable_arrows)
5474 return;
5475
5476 toplevel->priv->arrows_enabled = (enable_arrows != FALSE(0));
5477
5478 panel_toplevel_update_hide_buttons (toplevel);
5479
5480 g_object_notify (G_OBJECT (toplevel)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), (((GType) ((20) << (2))))))))
, "arrows-enabled");
5481}
5482
5483gboolean
5484panel_toplevel_get_enable_arrows (PanelToplevel *toplevel)
5485{
5486 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return ((0));
} } while (0)
;
5487
5488 return toplevel->priv->arrows_enabled;
5489}
5490
5491void
5492panel_toplevel_rotate (PanelToplevel *toplevel,
5493 gboolean clockwise)
5494{
5495 PanelOrientation orientation;
5496
5497 /* Relies on PanelOrientation definition:
5498 *
5499 * typedef enum {
5500 * PANEL_ORIENTATION_TOP = 1 << 0,
5501 * PANEL_ORIENTATION_RIGHT = 1 << 1,
5502 * PANEL_ORIENTATION_BOTTOM = 1 << 2,
5503 * PANEL_ORIENTATION_LEFT = 1 << 3
5504 * } PanelOrientation;
5505 */
5506
5507 orientation = toplevel->priv->orientation;
5508
5509 if (clockwise)
5510 orientation <<= 1;
5511 else
5512 orientation >>= 1;
5513
5514 if (orientation == 0)
5515 orientation = PANEL_ORIENTATION_LEFT;
5516
5517 else if (orientation > PANEL_ORIENTATION_LEFT)
5518 orientation = PANEL_ORIENTATION_TOP;
5519
5520 panel_toplevel_set_orientation (toplevel, orientation);
5521}
5522
5523PanelState
5524panel_toplevel_get_state (PanelToplevel *toplevel)
5525{
5526 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), 0)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return (0); }
} while (0)
;
5527
5528 return toplevel->priv->state;
5529}
5530
5531gboolean
5532panel_toplevel_get_is_hidden (PanelToplevel *toplevel)
5533{
5534 g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((toplevel)); GType __t = ((panel_toplevel_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "PANEL_IS_TOPLEVEL (toplevel)"); return ((0));
} } while (0)
;
5535
5536 if (toplevel->priv->state == PANEL_STATE_HIDDEN_UP ||
5537 toplevel->priv->state == PANEL_STATE_HIDDEN_DOWN ||
5538 toplevel->priv->state == PANEL_STATE_HIDDEN_LEFT ||
5539 toplevel->priv->state == PANEL_STATE_HIDDEN_RIGHT)
5540 return TRUE(!(0));
5541
5542 return FALSE(0);
5543}
5544
5545int
5546panel_toplevel_get_minimum_size (PanelToplevel *toplevel)
5547{
5548 return calculate_minimum_height (GTK_WIDGET (toplevel)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_widget_get_type ()))))))
,
5549 toplevel->priv->orientation);
5550}
5551
5552int
5553panel_toplevel_get_maximum_size (PanelToplevel *toplevel)
5554{
5555 GdkRectangle monitor_geom;
5556
5557 panel_toplevel_get_monitor_geometry (toplevel, &monitor_geom);
5558
5559 if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK(PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM))
5560 return monitor_geom.height / MAXIMUM_SIZE_SCREEN_RATIO5;
5561 else
5562 return monitor_geom.width / MAXIMUM_SIZE_SCREEN_RATIO5;
5563}
diff --git a/2024-06-18-172109-13286-1@e182420b844f_master/report-fec02c.html b/2024-06-18-172109-13286-1@e182420b844f_master/report-fec02c.html new file mode 100644 index 00000000..85eb2453 --- /dev/null +++ b/2024-06-18-172109-13286-1@e182420b844f_master/report-fec02c.html @@ -0,0 +1,1509 @@ + + + +panel-background.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:mate-panel/panel-background.c
Warning:line 782, column 11
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name panel-background.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/mate-panel -fcoverage-compilation-dir=/rootdir/mate-panel -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I .. -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/startup-notification-1.0 -I /usr/include/mate-menus -I /usr/include/gio-unix-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/dconf -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/dconf -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I . -I . -I ../mate-panel -I ../mate-panel/mate-submodules -I ../mate-panel/libpanel-util -D MATELOCALEDIR="/usr/local/share/locale" -D PANELDATADIR="/usr/local/share/mate-panel" -I /usr/include/gtk-layer-shell -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/gtk-3.0 -I /usr/include/cloudproviders -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/atk-1.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/gio-unix-2.0 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -D PANEL_MODULES_DIR="/usr/local/lib/mate-panel/modules" -D MATEMENU_I_KNOW_THIS_IS_UNSTABLE -I /usr/include/gtk-layer-shell -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/gtk-3.0 -I /usr/include/cloudproviders -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/atk-1.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/gio-unix-2.0 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-18-172109-13286-1 -x c panel-background.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * panel-background.c: panel background rendering
3 *
4 * Copyright (C) 2002, 2003 Sun Microsystems, Inc.
5 * Copyright (C) 2012-2021 MATE Developers
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of the
10 * License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301, USA.
21 *
22 * Authors:
23 * Mark McLoughlin <mark@skynet.ie>
24 */
25
26#include <config.h>
27
28#include "panel-background.h"
29
30#include <string.h>
31#include <gdk/gdk.h>
32#include <gtk/gtk.h>
33#include <cairo.h>
34
35#ifdef HAVE_X111
36#include <xstuff.h>
37#include <cairo-xlib.h>
38#endif
39
40#include "panel-util.h"
41
42static gboolean panel_background_composite (PanelBackground *background);
43static void load_background_file (PanelBackground *background);
44
45void panel_background_apply_css (PanelBackground *background, GtkWidget *widget)
46{
47 GtkStyleContext *context;
48 PanelBackgroundType effective_type;
49
50 context = gtk_widget_get_style_context (widget);
51 effective_type = panel_background_effective_type (background);
52
53 switch (effective_type) {
54 case PANEL_BACK_NONE:
55 gtk_style_context_remove_class (context, "mate-custom-panel-background");
56 break;
57 case PANEL_BACK_COLOR:
58 case PANEL_BACK_IMAGE:
59 gtk_style_context_add_class (context, "mate-custom-panel-background");
60 break;
61 default:
62 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-background.c"
, 62, ((const char*) (__func__)), ((void*)0)); } while (0)
;
63 break;
64 }
65}
66
67static void
68panel_background_prepare_css (void)
69{
70 GtkCssProvider *provider;
71
72 provider = gtk_css_provider_new ();
73 gtk_css_provider_load_from_data (provider,
74 ".mate-custom-panel-background{\n"
75 " background-color: rgba (0, 0, 0, 0);\n"
76 " background-image: none;\n"
77 "}",
78 -1, NULL((void*)0));
79 gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
80 GTK_STYLE_PROVIDER (provider)((((GtkStyleProvider*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((provider)), ((gtk_style_provider_get_type (
)))))))
,
81 GTK_STYLE_PROVIDER_PRIORITY_APPLICATION600);
82 g_object_unref (provider);
83}
84
85static gboolean
86panel_background_prepare (PanelBackground *background)
87{
88 PanelBackgroundType effective_type;
89 GtkWidget *widget = NULL((void*)0);
90
91 if (!background->transformed)
92 return FALSE(0);
93
94 effective_type = panel_background_effective_type (background);
95
96 switch (effective_type) {
97 case PANEL_BACK_NONE:
98 if (background->default_pattern) {
99 /* the theme background-image pattern must be scaled by
100 * the width & height of the panel so that when the
101 * backing region is cleared
102 * (gdk_window_clear_backing_region), the correctly
103 * scaled pattern is used */
104 cairo_surface_t *surface;
105
106 cairo_pattern_get_surface(background->default_pattern, &surface);
107 /* catch invalid images (e.g. -gtk-gradient) before scaling and rendering */
108 if (surface != NULL((void*)0) ){
109 double width, height;
110 cairo_matrix_t m;
111
112 cairo_surface_reference(surface);
113 width = cairo_image_surface_get_width (surface);
114 height = cairo_image_surface_get_height (surface);
115 cairo_matrix_init_translate (&m, 0, 0);
116 cairo_matrix_scale (&m,
117 width / background->region.width,
118 height / background->region.height);
119 cairo_pattern_set_matrix (background->default_pattern, &m);
120
121 gdk_window_set_background_pattern (background->window,
122 background->default_pattern);
123 }
124 else {
125 g_warning ("%s", "unsupported value of 'background-image' in GTK+ theme (such as '-gtk-gradient')");
126 /* use any background color that has been set if image is invalid */
127 gdk_window_set_background_rgba (
128 background->window, &background->default_color);
129 }
130 cairo_surface_destroy(surface);
131 } else
132 gdk_window_set_background_rgba (
133 background->window, &background->default_color);
134 break;
135
136 case PANEL_BACK_COLOR:
137 {
138 GdkRGBA color = background->color;
139 if (!gdk_screen_is_composited (gdk_screen_get_default ())) {
140 color.alpha = 1.;
141 }
142 gdk_window_set_background_rgba (background->window, &color);
143 break;
144 }
145
146 case PANEL_BACK_IMAGE:
147 g_assert (background->composited_pattern)do { if (background->composited_pattern) ; else g_assertion_message_expr
(((gchar*) 0), "panel-background.c", 147, ((const char*) (__func__
)), "background->composited_pattern"); } while (0)
;
148 gdk_window_set_background_pattern (background->window, background->composited_pattern);
149 break;
150
151 default:
152 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-background.c"
, 152, ((const char*) (__func__)), ((void*)0)); } while (0)
;
153 break;
154 }
155
156 /* Panel applets may use the panel's background pixmap to
157 * decide how to draw themselves. Therefore, we need to
158 * make sure that all drawing has been completed before
159 * the applet looks at the pixmap. */
160 gdk_display_sync (gdk_window_get_display (background->window));
161
162 gdk_window_get_user_data (GDK_WINDOW (background->window)((((GdkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((background->window)), ((gdk_window_get_type ()))))))
,
163 (gpointer) &widget);
164
165 if (GTK_IS_WIDGET (widget)(((__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; }))))
) {
166 panel_background_apply_css (background, gtk_widget_get_toplevel(widget));
167 gtk_widget_set_app_paintable(widget,TRUE(!(0)));
168 gtk_widget_queue_draw (widget);
169 }
170
171 background->notify_changed (background, background->user_data);
172
173 return TRUE(!(0));
174}
175
176static void
177free_composited_resources (PanelBackground *background)
178{
179 background->composited = FALSE(0);
180
181 if (background->composited_pattern)
182 cairo_pattern_destroy (background->composited_pattern);
183 background->composited_pattern = NULL((void*)0);
184}
185
186static cairo_pattern_t *
187composite_image_onto_desktop (PanelBackground *background)
188{
189 int width, height;
190 cairo_t *cr;
191 cairo_surface_t *surface;
192 cairo_pattern_t *pattern;
193
194 width = background->region.width;
195 height = background->region.height;
196
197 surface = gdk_window_create_similar_surface (background->window,
198 CAIRO_CONTENT_COLOR_ALPHA,
199 width, height);
200 if (cairo_surface_status (surface) != CAIRO_STATUS_SUCCESS) {
201 cairo_surface_destroy (surface);
202 return NULL((void*)0);
203 }
204
205 cr = cairo_create (surface);
206
207 gdk_cairo_set_source_pixbuf (cr, background->transformed_image, 0, 0);
208 pattern = cairo_get_source (cr);
209 cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
210
211 cairo_rectangle (cr, 0, 0, width, height);
212 cairo_fill (cr);
213
214 cairo_destroy (cr);
215
216 pattern = cairo_pattern_create_for_surface (surface);
217 cairo_surface_destroy (surface);
218 return pattern;
219}
220
221static gboolean
222panel_background_composite (PanelBackground *background)
223{
224 if (!background->transformed)
225 return FALSE(0);
226
227 free_composited_resources (background);
228
229 switch (background->type) {
230 case PANEL_BACK_NONE:
231 case PANEL_BACK_COLOR:
232 break;
233 case PANEL_BACK_IMAGE:
234 if (background->transformed_image) {
235 background->composited_pattern =
236 composite_image_onto_desktop (background);
237 }
238 break;
239 default:
240 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-background.c"
, 240, ((const char*) (__func__)), ((void*)0)); } while (0)
;
241 break;
242 }
243
244 background->composited = TRUE(!(0));
245
246 panel_background_prepare (background);
247
248 return TRUE(!(0));
249}
250
251static void
252free_transformed_resources (PanelBackground *background)
253{
254 free_composited_resources (background);
255
256 background->transformed = FALSE(0);
257
258 if (background->type != PANEL_BACK_IMAGE)
259 return;
260
261 if (background->transformed_image)
262 g_object_unref (background->transformed_image);
263 background->transformed_image = NULL((void*)0);
264}
265
266static GdkPixbuf *
267get_scaled_and_rotated_pixbuf (PanelBackground *background)
268{
269 GdkPixbuf *scaled;
270 GdkPixbuf *retval;
271 int orig_width, orig_height;
272 int panel_width, panel_height;
273 int width, height;
274
275 load_background_file (background);
276 if (!background->loaded_image)
277 return NULL((void*)0);
278
279 orig_width = gdk_pixbuf_get_width (background->loaded_image);
280 orig_height = gdk_pixbuf_get_height (background->loaded_image);
281
282 panel_width = background->region.width;
283 panel_height = background->region.height;
284
285 width = orig_width;
286 height = orig_height;
287
288 if (background->fit_image) {
289 switch (background->orientation) {
290 case GTK_ORIENTATION_HORIZONTAL:
291 width = orig_width * panel_height / orig_height;
292 height = panel_height;
293 break;
294 case GTK_ORIENTATION_VERTICAL:
295 if (background->rotate_image) {
296 width = orig_width * panel_width / orig_height;
297 height = panel_width;
298 } else {
299 width = panel_width;
300 height = orig_height * panel_width / orig_width;
301 }
302 break;
303 default:
304 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "panel-background.c"
, 304, ((const char*) (__func__)), ((void*)0)); } while (0)
;
305 break;
306 }
307 } else if (background->stretch_image) {
308 if (background->orientation == GTK_ORIENTATION_VERTICAL &&
309 background->rotate_image) {
310 width = panel_height;
311 height = panel_width;
312 } else {
313 width = panel_width;
314 height = panel_height;
315 }
316 } else if (background->orientation == GTK_ORIENTATION_VERTICAL &&
317 background->rotate_image) {
318 int tmp = width;
319 width = height;
320 height = tmp;
321 }
322
323 if (width == orig_width &&
324 height == orig_height) {
325 scaled = background->loaded_image;
326 g_object_ref (scaled)((__typeof__ (scaled)) (g_object_ref) (scaled));
327 } else {
328 scaled = gdk_pixbuf_scale_simple (
329 background->loaded_image,
330 width, height,
331 GDK_INTERP_BILINEAR);
332 }
333
334 if (background->rotate_image &&
335 background->orientation == GTK_ORIENTATION_VERTICAL) {
336 if (!background->has_alpha) {
337 guchar *dest;
338 guchar *src;
339 int x, y;
340 int destrowstride;
341 int srcrowstride;
342
343 retval = gdk_pixbuf_new (
344 GDK_COLORSPACE_RGB, FALSE(0), 8, height, width);
345
346 dest = gdk_pixbuf_get_pixels (retval);
347 destrowstride = gdk_pixbuf_get_rowstride (retval);
348 src = gdk_pixbuf_get_pixels (scaled);
349 srcrowstride = gdk_pixbuf_get_rowstride (scaled);
350
351 for (y = 0; y < height; y++)
352 for (x = 0; x < width; x++) {
353 guchar *dstptr = & ( dest [3*y + destrowstride * (width - x - 1)] );
354 guchar *srcptr = & ( src [y * srcrowstride + 3*x] );
355 dstptr[0] = srcptr[0];
356 dstptr[1] = srcptr[1];
357 dstptr[2] = srcptr[2];
358 }
359
360 g_object_unref (scaled);
361 } else {
362 guint32 *dest;
363 guint32 *src;
364 int x, y;
365 int destrowstride;
366 int srcrowstride;
367
368 retval = gdk_pixbuf_new (
369 GDK_COLORSPACE_RGB, TRUE(!(0)), 8, height, width);
370
371 dest = (guint32 *) gdk_pixbuf_get_pixels (retval);
372 destrowstride = gdk_pixbuf_get_rowstride (retval) / 4;
373 src = (guint32 *) gdk_pixbuf_get_pixels (scaled);
374 srcrowstride = gdk_pixbuf_get_rowstride (scaled) / 4;
375
376 for (y = 0; y < height; y++)
377 for (x = 0; x < width; x++)
378 dest [y + destrowstride * (width - x - 1)] =
379 src [y * srcrowstride + x];
380
381 g_object_unref (scaled);
382 }
383 } else
384 retval = scaled;
385
386 return retval;
387}
388
389static gboolean
390panel_background_transform (PanelBackground *background)
391{
392 if (background->region.width == -1)
393 return FALSE(0);
394
395 free_transformed_resources (background);
396
397 if (background->type == PANEL_BACK_IMAGE)
398 background->transformed_image =
399 get_scaled_and_rotated_pixbuf (background);
400
401 background->transformed = TRUE(!(0));
402
403 panel_background_composite (background);
404
405 return TRUE(!(0));
406}
407
408static void
409panel_background_update_has_alpha (PanelBackground *background)
410{
411 gboolean has_alpha = FALSE(0);
412
413 if (background->type == PANEL_BACK_COLOR)
414 has_alpha = (background->color.alpha < 1.);
415
416 else if (background->type == PANEL_BACK_IMAGE &&
417 background->loaded_image)
418 has_alpha = gdk_pixbuf_get_has_alpha (background->loaded_image);
419
420 background->has_alpha = (has_alpha != FALSE(0));
421}
422
423static void
424load_background_file (PanelBackground *background)
425{
426 GError *error = NULL((void*)0);
427
428 if (!g_file_test (background->image, G_FILE_TEST_IS_REGULAR))
429 return;
430
431 /* FIXME add a monitor on the file so that we reload the background
432 * when it changes
433 */
434 background->loaded_image =
435 gdk_pixbuf_new_from_file (background->image, &error);
436 if (!background->loaded_image) {
437 g_assert (error != NULL)do { if (error != ((void*)0)) ; else g_assertion_message_expr
(((gchar*) 0), "panel-background.c", 437, ((const char*) (__func__
)), "error != NULL"); } while (0)
;
438 g_warning (G_STRLOC"panel-background.c" ":" "438" ": unable to open '%s': %s",
439 background->image, error->message);
440 g_error_free (error);
441 }
442
443 panel_background_update_has_alpha (background);
444}
445
446void
447panel_background_set_type (PanelBackground *background,
448 PanelBackgroundType type)
449{
450 if (background->type == type)
451 return;
452
453 free_transformed_resources (background);
454
455 background->type = type;
456
457 panel_background_update_has_alpha (background);
458
459 panel_background_transform (background);
460}
461
462static void
463panel_background_set_color_no_update (PanelBackground *background,
464 const GdkRGBA *color)
465{
466 g_return_if_fail (color != NULL)do { if ((color != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "color != NULL");
return; } } while (0)
;
467
468 if (gdk_rgba_equal (color, &background->color))
469 return;
470
471 background->color = *color;
472 panel_background_update_has_alpha (background);
473}
474
475void
476panel_background_set_color (PanelBackground *background,
477 const GdkRGBA *color)
478{
479 g_return_if_fail (color != NULL)do { if ((color != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "color != NULL");
return; } } while (0)
;
480
481 if (gdk_rgba_equal (color, &background->color))
482 return;
483
484 free_transformed_resources (background);
485 panel_background_set_color_no_update (background, color);
486 panel_background_transform (background);
487}
488
489static void
490panel_background_set_image_no_update (PanelBackground *background,
491 const char *image)
492{
493 g_clear_object (&background->loaded_image)do { _Static_assert (sizeof *((&background->loaded_image
)) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(((&background->loaded_image))) _pp = ((&background
->loaded_image)); __typeof__ (*((&background->loaded_image
))) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (g_object_unref
) (_ptr); } while (0)
;
494 g_free (background->image);
495
496 if (image && image [0])
497 background->image = g_strdup (image)g_strdup_inline (image);
498 else
499 background->image = NULL((void*)0);
500
501 panel_background_update_has_alpha (background);
502}
503
504void
505panel_background_set_image (PanelBackground *background,
506 const char *image)
507{
508 if (!background->image && !image)
509 return;
510
511 if (background->image && image && !strcmp (background->image, image))
512 return;
513
514 free_transformed_resources (background);
515 panel_background_set_image_no_update (background, image);
516 panel_background_transform (background);
517}
518
519static void
520panel_background_set_fit_no_update (PanelBackground *background,
521 gboolean fit_image)
522{
523 background->fit_image = fit_image != FALSE(0);
524}
525
526void
527panel_background_set_fit (PanelBackground *background,
528 gboolean fit_image)
529{
530 fit_image = fit_image != FALSE(0);
531
532 if (background->fit_image == fit_image)
533 return;
534
535 free_transformed_resources (background);
536 panel_background_set_fit_no_update (background, fit_image);
537 panel_background_transform (background);
538}
539
540static void
541panel_background_set_stretch_no_update (PanelBackground *background,
542 gboolean stretch_image)
543{
544 background->stretch_image = stretch_image != FALSE(0);
545}
546
547void
548panel_background_set_stretch (PanelBackground *background,
549 gboolean stretch_image)
550{
551 stretch_image = stretch_image != FALSE(0);
552
553 if (background->stretch_image == stretch_image)
554 return;
555
556 free_transformed_resources (background);
557 panel_background_set_stretch_no_update (background, stretch_image);
558 panel_background_transform (background);
559}
560
561static void
562panel_background_set_rotate_no_update (PanelBackground *background,
563 gboolean rotate_image)
564{
565 background->rotate_image = rotate_image != FALSE(0);
566}
567
568void
569panel_background_set_rotate (PanelBackground *background,
570 gboolean rotate_image)
571{
572 rotate_image = rotate_image != FALSE(0);
573
574 if (background->rotate_image == rotate_image)
575 return;
576
577 free_transformed_resources (background);
578 panel_background_set_rotate_no_update (background, rotate_image);
579 panel_background_transform (background);
580}
581
582void
583panel_background_set (PanelBackground *background,
584 PanelBackgroundType type,
585 const GdkRGBA *color,
586 const char *image,
587 gboolean fit_image,
588 gboolean stretch_image,
589 gboolean rotate_image)
590{
591 panel_background_set_color_no_update (background, color);
592 panel_background_set_image_no_update (background, image);
593 panel_background_set_fit_no_update (background, fit_image);
594 panel_background_set_stretch_no_update (background, stretch_image);
595 panel_background_set_rotate_no_update (background, rotate_image);
596 panel_background_set_type (background, type);
597}
598
599void
600panel_background_set_default_style (PanelBackground *background,
601 const GdkRGBA *color,
602 cairo_pattern_t *pattern)
603{
604 g_return_if_fail (color != NULL)do { if ((color != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "color != NULL");
return; } } while (0)
;
605
606 background->default_color = *color;
607
608 if (pattern)
609 cairo_pattern_reference (pattern);
610
611 if (background->default_pattern)
612 cairo_pattern_destroy (background->default_pattern);
613
614 background->default_pattern = pattern;
615 if (background->type == PANEL_BACK_NONE)
616 panel_background_prepare (background);
617}
618
619void
620panel_background_realized (PanelBackground *background,
621 GdkWindow *window)
622{
623 g_return_if_fail (window != NULL)do { if ((window != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "window != NULL")
; return; } } while (0)
;
624
625 if (background->window)
626 return;
627
628 background->window = g_object_ref (window)((__typeof__ (window)) (g_object_ref) (window));
629
630 panel_background_prepare_css ();
631
632 panel_background_prepare (background);
633}
634
635void
636panel_background_unrealized (PanelBackground *background)
637{
638 if (background->window)
639 g_object_unref (background->window);
640 background->window = NULL((void*)0);
641}
642
643void
644panel_background_change_region (PanelBackground *background,
645 GtkOrientation orientation,
646 int x,
647 int y,
648 int width,
649 int height)
650{
651 gboolean need_to_retransform = FALSE(0);
652 gboolean need_to_reprepare = FALSE(0);
653
654 if (background->region.x == x &&
655 background->region.y == y &&
656 background->region.width == width &&
657 background->region.height == height &&
658 background->orientation == orientation)
659 return;
660
661 /* we only need to retransform anything
662 on size/orientation changes if the
663 background is an image and some
664 conditions are met */
665 if (background->type == PANEL_BACK_IMAGE) {
666 if (background->orientation != orientation &&
667 background->rotate_image) {
668 /* if orientation changes and we are rotating */
669 need_to_retransform = TRUE(!(0));
670 } else if ((background->region.width != width ||
671 background->region.height != height) &&
672 (background->fit_image ||
673 background->stretch_image)) {
674 /* or if the size changes and we are
675 stretching or fitting the image */
676 need_to_retransform = TRUE(!(0));
677 }
678 }
679
680 /* if size changed, we at least need
681 to "prepare" the background again */
682 if (background->region.width != width ||
683 background->region.height != height)
684 need_to_reprepare = TRUE(!(0));
685
686 background->region.x = x;
687 background->region.y = y;
688 background->region.width = width;
689 background->region.height = height;
690
691 background->orientation = orientation;
692
693 if (need_to_retransform || ! background->transformed)
694 /* only retransform the background if we have in
695 fact changed size/orientation */
696 panel_background_transform (background);
697 else if (background->has_alpha || ! background->composited)
698 /* only do compositing if we have some alpha
699 value to worry about */
700 panel_background_composite (background);
701 else if (need_to_reprepare)
702 /* at least we must prepare the background
703 if the size changed */
704 panel_background_prepare (background);
705}
706
707void
708panel_background_init (PanelBackground *background,
709 PanelBackgroundChangedNotify notify_changed,
710 gpointer user_data)
711{
712 background->type = PANEL_BACK_NONE;
713 background->notify_changed = notify_changed;
714 background->user_data = user_data;
715
716 background->color.red = 0.;
717 background->color.blue = 0.;
718 background->color.green = 0.;
719 background->color.alpha = 1.;
720
721 background->image = NULL((void*)0);
722 background->loaded_image = NULL((void*)0);
723
724 background->orientation = GTK_ORIENTATION_HORIZONTAL;
725 background->region.x = -1;
726 background->region.y = -1;
727 background->region.width = -1;
728 background->region.height = -1;
729 background->transformed_image = NULL((void*)0);
730 background->composited_pattern = NULL((void*)0);
731
732 background->window = NULL((void*)0);
733
734 background->default_pattern = NULL((void*)0);
735
736 background->default_color.red = 0.;
737 background->default_color.green = 0.;
738 background->default_color.blue = 0.;
739 background->default_color.alpha = 1.;
740
741 background->fit_image = FALSE(0);
742 background->stretch_image = FALSE(0);
743 background->rotate_image = FALSE(0);
744
745 background->has_alpha = FALSE(0);
746
747 background->transformed = FALSE(0);
748 background->composited = FALSE(0);
749}
750
751void
752panel_background_free (PanelBackground *background)
753{
754 free_transformed_resources (background);
755
756 g_clear_pointer (&background->image, g_free)do { _Static_assert (sizeof *(&background->image) == sizeof
(gpointer), "Expression evaluates to false"); __typeof__ ((&
background->image)) _pp = (&background->image); __typeof__
(*(&background->image)) _ptr = *_pp; *_pp = ((void*)0
); if (_ptr) (g_free) (_ptr); } while (0)
;
757
758 g_clear_object (&background->loaded_image)do { _Static_assert (sizeof *((&background->loaded_image
)) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(((&background->loaded_image))) _pp = ((&background
->loaded_image)); __typeof__ (*((&background->loaded_image
))) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (g_object_unref
) (_ptr); } while (0)
;
759 g_clear_object (&background->window)do { _Static_assert (sizeof *((&background->window)) ==
sizeof (gpointer), "Expression evaluates to false"); __typeof__
(((&background->window))) _pp = ((&background->
window)); __typeof__ (*((&background->window))) _ptr =
*_pp; *_pp = ((void*)0); if (_ptr) (g_object_unref) (_ptr); }
while (0)
;
760
761 if (background->default_pattern)
762 cairo_pattern_destroy (background->default_pattern);
763 background->default_pattern = NULL((void*)0);
764}
765
766char *
767panel_background_make_string (PanelBackground *background,
768 int x,
769 int y)
770{
771 PanelBackgroundType effective_type;
772 char *retval;
773
774 retval = NULL((void*)0);
775
776 effective_type = panel_background_effective_type (background);
777
778 if (effective_type == PANEL_BACK_IMAGE) {
779 cairo_surface_t *surface;
780
781 if (!background->composited_pattern)
782 return NULL((void*)0);
This statement is never executed
783
784 if (cairo_pattern_get_surface (background->composited_pattern, &surface) != CAIRO_STATUS_SUCCESS)
785 return NULL((void*)0);
786
787 if (cairo_surface_get_type (surface) != CAIRO_SURFACE_TYPE_XLIB)
788 return NULL((void*)0);
789
790 retval = g_strdup_printf ("pixmap:%d,%d,%d", (guint32)cairo_xlib_surface_get_drawable (surface), x, y);
791 } else if (effective_type == PANEL_BACK_COLOR) {
792 gchar *rgba = gdk_rgba_to_string (&background->color);
793 retval = g_strdup_printf (
794 "color:%s",
795 rgba);
796 g_free (rgba);
797 } else
798 retval = g_strdup ("none:")g_strdup_inline ("none:");
799
800 return retval;
801}
802
803PanelBackgroundType
804panel_background_get_type (PanelBackground *background)
805{
806 return background->type;
807}
808
809const GdkRGBA *
810panel_background_get_color (PanelBackground *background)
811{
812 return &(background->color);
813}
814
815/* What are we actually rendering - e.g. if we're supposed to
816 * be rendering an image, but haven't got a valid image, then
817 * we're rendering the default gtk background.
818 */
819PanelBackgroundType
820panel_background_effective_type (PanelBackground *background)
821{
822 PanelBackgroundType retval;
823
824 retval = background->type;
825 if (background->type == PANEL_BACK_IMAGE && !background->composited_pattern)
826 retval = PANEL_BACK_NONE;
827
828 return retval;
829}
diff --git a/2024-06-18-172109-13286-1@e182420b844f_master/scanview.css b/2024-06-18-172109-13286-1@e182420b844f_master/scanview.css new file mode 100644 index 00000000..cf8a5a6a --- /dev/null +++ b/2024-06-18-172109-13286-1@e182420b844f_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/2024-06-18-172109-13286-1@e182420b844f_master/sorttable.js b/2024-06-18-172109-13286-1@e182420b844f_master/sorttable.js new file mode 100644 index 00000000..32faa078 --- /dev/null +++ b/2024-06-18-172109-13286-1@e182420b844f_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("