Bug Summary

File:cafe-panel/panel-context-menu.c
Warning:line 304, 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-pc-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 pic -pic-level 2 -pic-is-pie -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 -fcoverage-compilation-dir=/rootdir/cafe-panel -resource-dir /usr/lib/llvm-16/lib/clang/16 -D HAVE_CONFIG_H -I . -I .. -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libpng16 -I /usr/include/x86_64-linux-gnu -I /usr/include/webp -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/fribidi -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/ctk-3.0 -I /usr/include/gio-unix-2.0 -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib/x86_64-linux-gnu/dbus-1.0/include -I /usr/include/cafe-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/cafe-menus -I /usr/include/dconf -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/libmount -I /usr/include/blkid -I . -I . -I ../cafe-panel -I ../cafe-panel/libpanel-util -D CAFELOCALEDIR="/usr/share/locale" -D PANELDATADIR="/usr/share/cafe-panel" -D PANEL_MODULES_DIR="/usr/lib/cafe-panel/modules" -D CAFEMENU_I_KNOW_THIS_IS_UNSTABLE -internal-isystem /usr/lib/llvm-16/lib/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/13/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir=/rootdir/cafe-panel -ferror-limit 19 -fgnuc-version=4.2.1 -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-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-02-11-203333-55970-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 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19 * 02110-1301, USA.
20 *
21 * Most of the original code come from menu.c
22 *
23 * Authors:
24 * Vincent Untz <vincent@vuntz.net>
25 *
26 */
27
28#include <config.h>
29
30#include "panel-context-menu.h"
31
32#include <string.h>
33
34#include <glib/gi18n.h>
35#include <cdk/cdkkeysyms.h>
36
37#include <libpanel-util/panel-error.h>
38#include <libpanel-util/panel-show.h>
39#include <libpanel-util/panel-ctk.h>
40
41#include "panel-util.h"
42#include "panel.h"
43#include "menu.h"
44#include "applet.h"
45#include "panel-config-global.h"
46#include "panel-profile.h"
47#include "panel-properties-dialog.h"
48#include "panel-lockdown.h"
49#include "panel-addto.h"
50#include "panel-icon-names.h"
51#include "panel-reset.h"
52
53static void
54panel_context_menu_show_help (CtkWidget *w,
55 gpointer data)
56{
57 panel_show_help (ctk_widget_get_screen (w),
58 "cafe-user-guide", "gospanel-1", NULL((void*)0));
59}
60
61static void
62panel_context_menu_show_about_dialog (CtkWidget *menuitem)
63{
64 static CtkWidget *about = NULL((void*)0);
65 char *authors [] = {
66 /* CAFE */
67 "Perberos <perberos@gmail.com>",
68 "Stefano Karapetsas <stefano@karapetsas.com>",
69 "Steve Zesch <stevezesch2@gmail.com>",
70 /* GNOME */
71 "Alex Larsson <alexl@redhat.com>",
72 "Anders Carlsson <andersca@gnu.org>",
73 "Arvind Samptur <arvind.samptur@wipro.com>",
74 "Darin Adler <darin@bentspoon.com>",
75 "Elliot Lee <sopwith@redhat.com>",
76 "Federico Mena <quartic@gimp.org>",
77 "George Lebl <jirka@5z.com>",
78 "Glynn Foster <glynn.foster@sun.com>",
79 "Ian Main <imain@ctk.org>",
80 "Ian McKellar <yakk@yakk.net>",
81 "Jacob Berkman <jberkman@andrew.cmu.edu>",
82 "Mark McLoughlin <mark@skynet.ie>",
83 "Martin Baulig <baulig@suse.de>",
84 "Miguel de Icaza <miguel@kernel.org>",
85 "Owen Taylor <otaylor@redhat.com>",
86 "Padraig O'Briain <padraig.obriain@sun.com>",
87 "Seth Nickell <snickell@stanford.edu>",
88 "Stephen Browne <stephen.browne@sun.com>",
89 "Tom Tromey <tromey@cygnus.com>",
90 "Vincent Untz <vuntz@gnome.org>",
91 N_("And many, many others…")("And many, many others…"),
92 NULL((void*)0)
93 };
94 char *documenters[] = {
95 "Alexander Kirillov <kirillov@math.sunysb.edu>",
96 "Dan Mueth <d-mueth@uchicago.edu>",
97 "Dave Mason <dcm@redhat.com>",
98 NULL((void*)0)
99 };
100 int i;
101
102 if (about) {
103 ctk_window_set_screen (CTK_WINDOW (about)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((about)), ((ctk_window_get_type ()))))))
,
104 menuitem_to_screen (menuitem));
105 ctk_window_present (CTK_WINDOW (about)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((about)), ((ctk_window_get_type ()))))))
);
106 return;
107 }
108
109 for (i = 0; authors [i]; i++)
110 authors [i] = _(authors [i])gettext (authors [i]);
111
112 about = ctk_about_dialog_new ();
113 g_object_set (about,
114 "program-name", _("The CAFE Panel")gettext ("The CAFE Panel"),
115 "version", VERSION"1.25.0",
116 "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-2020 MATE developers\n"
"Copyright \xc2\xa9 2022-2024 Pablo Barciela")
117 "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-2020 MATE developers\n"
"Copyright \xc2\xa9 2022-2024 Pablo Barciela")
118 "Copyright \xc2\xa9 2011-2020 MATE developers\n"gettext ("Copyright \xc2\xa9 1997-2003 Free Software Foundation, Inc.\n"
"Copyright \xc2\xa9 2004 Vincent Untz\n" "Copyright \xc2\xa9 2011-2020 MATE developers\n"
"Copyright \xc2\xa9 2022-2024 Pablo Barciela")
119 "Copyright \xc2\xa9 2022-2024 Pablo Barciela")gettext ("Copyright \xc2\xa9 1997-2003 Free Software Foundation, Inc.\n"
"Copyright \xc2\xa9 2004 Vincent Untz\n" "Copyright \xc2\xa9 2011-2020 MATE developers\n"
"Copyright \xc2\xa9 2022-2024 Pablo Barciela")
,
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 CAFE Panel")gettext ("About the CAFE Panel"),
125 "translator-credits", _("translator-credits")gettext ("translator-credits"),
126 "logo-icon-name", PANEL_ICON_PANEL"cafe-panel",
127 NULL((void*)0));
128
129 ctk_window_set_screen (CTK_WINDOW (about)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((about)), ((ctk_window_get_type ()))))))
,
130 menuitem_to_screen (menuitem));
131 g_signal_connect (about, "destroy",g_signal_connect_data ((about), ("destroy"), (((GCallback) (ctk_widget_destroyed
))), (&about), ((void*)0), (GConnectFlags) 0)
132 G_CALLBACK (ctk_widget_destroyed),g_signal_connect_data ((about), ("destroy"), (((GCallback) (ctk_widget_destroyed
))), (&about), ((void*)0), (GConnectFlags) 0)
133 &about)g_signal_connect_data ((about), ("destroy"), (((GCallback) (ctk_widget_destroyed
))), (&about), ((void*)0), (GConnectFlags) 0)
;
134
135 g_signal_connect (about, "response",g_signal_connect_data ((about), ("response"), (((GCallback) (
ctk_widget_destroy))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
136 G_CALLBACK (ctk_widget_destroy),g_signal_connect_data ((about), ("response"), (((GCallback) (
ctk_widget_destroy))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
137 NULL)g_signal_connect_data ((about), ("response"), (((GCallback) (
ctk_widget_destroy))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
138
139 ctk_widget_show (about);
140}
141
142static void
143panel_context_menu_create_new_panel (CtkWidget *menuitem)
144{
145 panel_profile_create_toplevel (ctk_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 (CTK_WINDOW (toplevel)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((ctk_window_get_type ()))))))
,
153 ctk_window_get_screen (CTK_WINDOW (toplevel)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((ctk_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 (CtkWidget *menu,
165 CtkWidget *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 ctk_widget_set_sensitive (menuitem, sensitive);
180}
181
182static void
183panel_reset_response (CtkWidget *dialog,
184 int response)
185{
186 if (response == CTK_RESPONSE_OK) {
187 panel_reset ();
188 }
189
190 ctk_widget_destroy (dialog);
191}
192
193static void
194query_panel_reset (PanelToplevel *toplevel)
195{
196 CtkWidget *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 = ctk_message_dialog_new (
205 CTK_WINDOW (toplevel)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((ctk_window_get_type ()))))))
,
206 CTK_DIALOG_MODAL,
207 CTK_MESSAGE_WARNING,
208 CTK_BUTTONS_NONE,
209 "%s", text1);
210
211 ctk_message_dialog_format_secondary_text (CTK_MESSAGE_DIALOG (dialog)((((CtkMessageDialog*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((dialog)), ((ctk_message_dialog_get_type ())
)))))
,
212 "%s", text2);
213 ctk_dialog_add_buttons (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_dialog_get_type ()))))))
,
214 _("_Cancel")gettext ("_Cancel"), CTK_RESPONSE_CANCEL,
215 _("_Reset Panels")gettext ("_Reset Panels"), CTK_RESPONSE_OK,
216 NULL((void*)0));
217
218 ctk_dialog_set_default_response (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_dialog_get_type ()))))))
, CTK_RESPONSE_CANCEL);
219
220 ctk_window_set_position (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_window_get_type ()))))))
, CTK_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 ctk_widget_show_all (dialog);
227}
228
229static void
230panel_context_menu_build_edition (PanelWidget *panel_widget,
231 CtkWidget *menu)
232{
233 CtkWidget *menuitem;
234
235 ctk_menu_set_reserve_toggle_size (CTK_MENU (menu)((((CtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((menu)), ((ctk_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 ctk_widget_show (menuitem);
240 ctk_menu_shell_append (CTK_MENU_SHELL (menu)((((CtkMenuShell*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((menu)), ((ctk_menu_shell_get_type ()))))))
, menuitem);
241 g_signal_connect (G_OBJECT (menuitem), "activate",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((menuitem)), (((GType) ((20) << (2)
)))))))), ("activate"), (((GCallback) (panel_addto_present)))
, (panel_widget), ((void*)0), (GConnectFlags) 0)
242 G_CALLBACK (panel_addto_present), panel_widget)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((menuitem)), (((GType) ((20) << (2)
)))))))), ("activate"), (((GCallback) (panel_addto_present)))
, (panel_widget), ((void*)0), (GConnectFlags) 0)
;
243
244 if (!panel_profile_id_lists_are_writable ())
245 ctk_widget_set_sensitive (menuitem, FALSE(0));
246
247 menuitem = panel_image_menu_item_new_from_icon ("document-properties", _("_Properties")gettext ("_Properties"));
248
249 ctk_widget_show (menuitem);
250 ctk_menu_shell_append (CTK_MENU_SHELL (menu)((((CtkMenuShell*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((menu)), ((ctk_menu_shell_get_type ()))))))
, menuitem);
251 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)
252 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)
253 panel_widget->toplevel)g_signal_connect_data ((menuitem), ("activate"), (((GCallback
) (panel_properties_dialog_present))), (panel_widget->toplevel
), ((void*)0), G_CONNECT_SWAPPED)
;
254
255 add_menu_separator (menu);
256
257 menuitem = panel_image_menu_item_new_from_icon ("document-revert", _("_Reset All Panels")gettext ("_Reset All Panels"));
258
259 ctk_widget_show (menuitem);
260 ctk_menu_shell_append (CTK_MENU_SHELL (menu)((((CtkMenuShell*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((menu)), ((ctk_menu_shell_get_type ()))))))
, menuitem);
261 g_signal_connect_swapped (menuitem, "activate",g_signal_connect_data ((menuitem), ("activate"), (((GCallback
) (query_panel_reset))), (panel_widget->toplevel), ((void*
)0), G_CONNECT_SWAPPED)
262 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)
;
263
264 menuitem = panel_image_menu_item_new_from_icon ("edit-delete", _("_Delete This Panel")gettext ("_Delete This Panel"));
265
266 ctk_widget_show (menuitem);
267 ctk_menu_shell_append (CTK_MENU_SHELL (menu)((((CtkMenuShell*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((menu)), ((ctk_menu_shell_get_type ()))))))
, menuitem);
268 g_signal_connect_swapped (G_OBJECT (menuitem), "activate",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((menuitem)), (((GType) ((20) << (2)
)))))))), ("activate"), (((GCallback) (panel_context_menu_delete_panel
))), (panel_widget->toplevel), ((void*)0), G_CONNECT_SWAPPED
)
269 G_CALLBACK (panel_context_menu_delete_panel),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((menuitem)), (((GType) ((20) << (2)
)))))))), ("activate"), (((GCallback) (panel_context_menu_delete_panel
))), (panel_widget->toplevel), ((void*)0), G_CONNECT_SWAPPED
)
270 panel_widget->toplevel)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((menuitem)), (((GType) ((20) << (2)
)))))))), ("activate"), (((GCallback) (panel_context_menu_delete_panel
))), (panel_widget->toplevel), ((void*)0), G_CONNECT_SWAPPED
)
;
271 g_signal_connect (G_OBJECT (menu), "show",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((menu)), (((GType) ((20) << (2)))))
)))), ("show"), (((GCallback) (panel_context_menu_setup_delete_panel_item
))), (menuitem), ((void*)0), (GConnectFlags) 0)
272 G_CALLBACK (panel_context_menu_setup_delete_panel_item),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((menu)), (((GType) ((20) << (2)))))
)))), ("show"), (((GCallback) (panel_context_menu_setup_delete_panel_item
))), (menuitem), ((void*)0), (GConnectFlags) 0)
273 menuitem)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((menu)), (((GType) ((20) << (2)))))
)))), ("show"), (((GCallback) (panel_context_menu_setup_delete_panel_item
))), (menuitem), ((void*)0), (GConnectFlags) 0)
;
274
275 add_menu_separator (menu);
276
277 menuitem = panel_image_menu_item_new_from_icon ("document-new", _("_New Panel")gettext ("_New Panel"));
278
279 ctk_widget_show (menuitem);
280 ctk_menu_shell_append (CTK_MENU_SHELL (menu)((((CtkMenuShell*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((menu)), ((ctk_menu_shell_get_type ()))))))
, menuitem);
281 g_signal_connect (menuitem, "activate",g_signal_connect_data ((menuitem), ("activate"), (((GCallback
) (panel_context_menu_create_new_panel))), (((void*)0)), ((void
*)0), (GConnectFlags) 0)
282 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)
283 NULL)g_signal_connect_data ((menuitem), ("activate"), (((GCallback
) (panel_context_menu_create_new_panel))), (((void*)0)), ((void
*)0), (GConnectFlags) 0)
;
284 ctk_widget_set_sensitive (menuitem,
285 panel_profile_id_lists_are_writable ());
286
287 add_menu_separator (menu);
288}
289
290CtkWidget *
291panel_context_menu_create (PanelWidget *panel)
292{
293 CtkWidget *retval;
294 CtkWidget *menuitem;
295
296 if (panel->master_widget) {
297 gpointer *pointer;
298 AppletInfo *info;
299
300 pointer = g_object_get_data (G_OBJECT (panel->master_widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((panel->master_widget)), (((GType) ((20) << (2))
))))))
,
301 "applet_info");
302
303 g_assert (pointer != NULL)do { if (pointer != ((void*)0)) ; else g_assertion_message_expr
(((gchar*) 0), "panel-context-menu.c", 303, ((const char*) (
__func__)), "pointer != NULL"); } while (0)
;
304 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
305
306 if (info->menu == NULL((void*)0)) {
307 info->menu = cafe_panel_applet_create_menu (info);
308 }
309
310 return info->menu;
311 }
312
313 retval = create_empty_menu ();
314 ctk_widget_set_name (retval, "cafe-panel-context-menu");
315
316 if (!panel_lockdown_get_locked_down ())
317 panel_context_menu_build_edition (panel, retval);
318
319 menuitem = panel_image_menu_item_new_from_icon ("help-browser", _("_Help")gettext ("_Help"));
320
321 ctk_widget_show (menuitem);
322 ctk_menu_shell_append (CTK_MENU_SHELL (retval)((((CtkMenuShell*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((retval)), ((ctk_menu_shell_get_type ()))))))
, menuitem);
323 g_signal_connect (menuitem, "activate",g_signal_connect_data ((menuitem), ("activate"), (((GCallback
) (panel_context_menu_show_help))), (((void*)0)), ((void*)0),
(GConnectFlags) 0)
324 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)
;
325
326 menuitem = panel_image_menu_item_new_from_icon ("help-about", _("A_bout Panels")gettext ("A_bout Panels"));
327
328 ctk_widget_show (menuitem);
329 ctk_menu_shell_append (CTK_MENU_SHELL (retval)((((CtkMenuShell*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((retval)), ((ctk_menu_shell_get_type ()))))))
, menuitem);
330 g_signal_connect (menuitem, "activate",g_signal_connect_data ((menuitem), ("activate"), (((GCallback
) (panel_context_menu_show_about_dialog))), (((void*)0)), ((void
*)0), (GConnectFlags) 0)
331 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)
332 NULL)g_signal_connect_data ((menuitem), ("activate"), (((GCallback
) (panel_context_menu_show_about_dialog))), (((void*)0)), ((void
*)0), (GConnectFlags) 0)
;
333
334 //FIXME: can we get rid of this? (needed by menu_get_panel())
335 g_object_set_data (G_OBJECT (retval)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((retval)), (((GType) ((20) << (2))))))))
, "menu_panel", panel);
336
337/* Set up theme and transparency support */
338 CtkWidget *toplevel = ctk_widget_get_toplevel (retval);
339/* Fix any failures of compiz/other wm's to communicate with ctk for transparency */
340 CdkScreen *screen = ctk_widget_get_screen(CTK_WIDGET(toplevel)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((ctk_widget_get_type ()))))))
);
341 CdkVisual *visual = cdk_screen_get_rgba_visual(screen);
342 ctk_widget_set_visual(CTK_WIDGET(toplevel)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((ctk_widget_get_type ()))))))
, visual);
343/* Set menu and it's toplevel window to follow panel theme */
344 CtkStyleContext *context;
345 context = ctk_widget_get_style_context (CTK_WIDGET(toplevel)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((ctk_widget_get_type ()))))))
);
346 ctk_style_context_add_class(context,"gnome-panel-menu-bar");
347 ctk_style_context_add_class(context,"cafe-panel-menu-bar");
348
349 return retval;
350}