From d303b5b853d52e61e0163c29307cb0c94e193504 Mon Sep 17 00:00:00 2001 From: "raveit65 (via Travis CI)" Date: Wed, 27 Nov 2024 05:12:52 +0000 Subject: Deploy mate-desktop/mate-applets to github.com/mate-desktop/mate-applets.git:gh-pages --- .../index.html | 112 + .../report-0cb404.html | 1380 +++++++++++ .../report-3faa94.html | 1169 +++++++++ .../report-782963.html | 1025 ++++++++ .../report-8b7574.html | 2531 ++++++++++++++++++++ .../report-ad73bf.html | 1232 ++++++++++ .../scanview.css | 62 + .../sorttable.js | 492 ++++ 8 files changed, 8003 insertions(+) create mode 100644 2023-10-06-143029-14295-1@5e7148e14497_gtk-image-menu-item/index.html create mode 100644 2023-10-06-143029-14295-1@5e7148e14497_gtk-image-menu-item/report-0cb404.html create mode 100644 2023-10-06-143029-14295-1@5e7148e14497_gtk-image-menu-item/report-3faa94.html create mode 100644 2023-10-06-143029-14295-1@5e7148e14497_gtk-image-menu-item/report-782963.html create mode 100644 2023-10-06-143029-14295-1@5e7148e14497_gtk-image-menu-item/report-8b7574.html create mode 100644 2023-10-06-143029-14295-1@5e7148e14497_gtk-image-menu-item/report-ad73bf.html create mode 100644 2023-10-06-143029-14295-1@5e7148e14497_gtk-image-menu-item/scanview.css create mode 100644 2023-10-06-143029-14295-1@5e7148e14497_gtk-image-menu-item/sorttable.js (limited to '2023-10-06-143029-14295-1@5e7148e14497_gtk-image-menu-item') diff --git a/2023-10-06-143029-14295-1@5e7148e14497_gtk-image-menu-item/index.html b/2023-10-06-143029-14295-1@5e7148e14497_gtk-image-menu-item/index.html new file mode 100644 index 00000000..d017e24c --- /dev/null +++ b/2023-10-06-143029-14295-1@5e7148e14497_gtk-image-menu-item/index.html @@ -0,0 +1,112 @@ + + +rootdir - scan-build results + + + + + + +

rootdir - scan-build results

+ + + + + + + +
User:root@c2a79abda11e
Working Directory:/rootdir
Command Line:make -j 2
Clang Version:clang version 16.0.6 (Fedora 16.0.6-3.fc38) +
Date:Fri Oct 6 14:30:29 2023
+

Bug Summary

+ + + + + + + + + + +
Bug TypeQuantityDisplay?
All Bugs5
Logic error
Division by zero1
Out-of-bound access1
Result of operation is garbage or undefined1
Security
Potential insecure memory buffer bounds restriction in call 'strcpy'1
Unused code
Dead assignment1
+

Reports

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Bug GroupBug Type ▾FileFunction/MethodLinePath Length
Unused codeDead assignmentgeyes/src/themes.cparse_theme_file801View Report
Logic errorDivision by zeromultiload/src/load-graph.cload_graph_draw10614View Report
Logic errorOut-of-bound accessnetspeed/src/netspeed.cmac_addr_n2a67125View Report
SecurityPotential insecure memory buffer bounds restriction in call 'strcpy'battstat/apmlib/apmlib.capm_read891View Report
Logic errorResult of operation is garbage or undefinedstickynotes/stickynotes_applet.cstickynotes_applet_init22411View Report
+ + diff --git a/2023-10-06-143029-14295-1@5e7148e14497_gtk-image-menu-item/report-0cb404.html b/2023-10-06-143029-14295-1@5e7148e14497_gtk-image-menu-item/report-0cb404.html new file mode 100644 index 00000000..6ce75ef3 --- /dev/null +++ b/2023-10-06-143029-14295-1@5e7148e14497_gtk-image-menu-item/report-0cb404.html @@ -0,0 +1,1380 @@ + + + +stickynotes_applet.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:stickynotes/stickynotes_applet.c
Warning:line 224, column 42
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 stickynotes_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 static -mframe-pointer=none -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/stickynotes -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -I . -I . -I /usr/include/gtksourceview-4 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -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/lib64/dbus-1.0/include -I /usr/include/mate-panel-4.0/libmate-panel-applet -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -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/lib64/dbus-1.0/include -I /usr/include/libwnck-3.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -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/lib64/dbus-1.0/include -I /usr/include/startup-notification-1.0 -I /usr/include/libxml2 -D GRESOURCE="/org/mate/mate-applets/sticky-notes/" -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-unused-parameter -fdebug-compilation-dir=/rootdir/stickynotes -ferror-limit 19 -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-10-06-143029-14295-1 -x c stickynotes_applet.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* Sticky Notes
2 * Copyright (C) 2002-2003 Loban A Rahman
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2, or (at your option)
7 * any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
17 * 02110-1301, USA.
18 */
19
20#include <config.h>
21#include <string.h>
22#include "stickynotes_applet.h"
23#include "stickynotes_applet_callbacks.h"
24#include "stickynotes.h"
25
26#include <gtk/gtk.h>
27#include <gdk/gdkx.h>
28
29StickyNotes *stickynotes = NULL((void*)0);
30
31/* Popup menu on the applet */
32static const GtkActionEntry stickynotes_applet_menu_actions[] =
33{
34 { "new_note", "document-new", N_("_New Note")("_New Note"),
35 NULL((void*)0), NULL((void*)0),
36 G_CALLBACK (menu_new_note_cb)((GCallback) (menu_new_note_cb)) },
37 { "hide_notes", NULL((void*)0), N_("Hi_de Notes")("Hi_de Notes"),
38 NULL((void*)0), NULL((void*)0),
39 G_CALLBACK (menu_hide_notes_cb)((GCallback) (menu_hide_notes_cb)) },
40 { "destroy_all", "edit-delete", N_("_Delete Notes")("_Delete Notes"),
41 NULL((void*)0), NULL((void*)0),
42 G_CALLBACK (menu_destroy_all_cb)((GCallback) (menu_destroy_all_cb)) },
43 { "preferences", "document-properties", N_("_Preferences")("_Preferences"),
44 NULL((void*)0), NULL((void*)0),
45 G_CALLBACK (menu_preferences_cb)((GCallback) (menu_preferences_cb)) },
46 { "help", "help-browser", N_("_Help")("_Help"),
47 NULL((void*)0), NULL((void*)0),
48 G_CALLBACK (menu_help_cb)((GCallback) (menu_help_cb)) },
49 { "about", "help-about", N_("_About")("_About"),
50 NULL((void*)0), NULL((void*)0),
51 G_CALLBACK (menu_about_cb)((GCallback) (menu_about_cb)) }
52};
53
54static const GtkToggleActionEntry stickynotes_applet_menu_toggle_actions[] =
55{
56 { "lock", NULL((void*)0), N_("_Lock Notes")("_Lock Notes"),
57 NULL((void*)0), NULL((void*)0),
58 G_CALLBACK (menu_toggle_lock_cb)((GCallback) (menu_toggle_lock_cb)), FALSE(0) }
59};
60
61/* Sticky Notes applet factory */
62static gboolean
63stickynotes_applet_factory (MatePanelApplet *mate_panel_applet,
64 const gchar *iid,
65 gpointer data)
66{
67 if (!strcmp (iid, "StickyNotesApplet")) {
1
Taking true branch
68 if (!stickynotes)
2
Assuming 'stickynotes' is null
3
Taking true branch
69 stickynotes_applet_init (mate_panel_applet);
4
Calling 'stickynotes_applet_init'
70
71 mate_panel_applet_set_flags (mate_panel_applet, MATE_PANEL_APPLET_EXPAND_MINOR);
72
73 /* Add applet to linked list of all applets */
74 stickynotes->applets = g_list_append (stickynotes->applets,
75 stickynotes_applet_new (mate_panel_applet));
76
77 stickynotes_applet_update_menus ();
78 stickynotes_applet_update_tooltips ();
79
80 return TRUE(!(0));
81 }
82
83 return FALSE(0);
84}
85
86/* Sticky Notes applet factory */
87PANEL_APPLET_FACTORY ("StickyNotesAppletFactory",int main(int argc, char *argv[]) { GOptionContext *context; GError
*error; int retval; do { bindtextdomain ("mate-applets", "/usr/local/share/locale"
); bind_textdomain_codeset ("mate-applets", "UTF-8"); if ((!(
0))) textdomain ("mate-applets"); } 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 ("StickyNotesAppletFactory"
,(!(0)), mate_panel_applet_get_type (), stickynotes_applet_factory
, ((void*)0)); g_option_context_free (context); return retval
; }
88 PANEL_TYPE_APPLET,int main(int argc, char *argv[]) { GOptionContext *context; GError
*error; int retval; do { bindtextdomain ("mate-applets", "/usr/local/share/locale"
); bind_textdomain_codeset ("mate-applets", "UTF-8"); if ((!(
0))) textdomain ("mate-applets"); } 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 ("StickyNotesAppletFactory"
,(!(0)), mate_panel_applet_get_type (), stickynotes_applet_factory
, ((void*)0)); g_option_context_free (context); return retval
; }
89 "stickynotes_applet",int main(int argc, char *argv[]) { GOptionContext *context; GError
*error; int retval; do { bindtextdomain ("mate-applets", "/usr/local/share/locale"
); bind_textdomain_codeset ("mate-applets", "UTF-8"); if ((!(
0))) textdomain ("mate-applets"); } 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 ("StickyNotesAppletFactory"
,(!(0)), mate_panel_applet_get_type (), stickynotes_applet_factory
, ((void*)0)); g_option_context_free (context); return retval
; }
90 stickynotes_applet_factory,int main(int argc, char *argv[]) { GOptionContext *context; GError
*error; int retval; do { bindtextdomain ("mate-applets", "/usr/local/share/locale"
); bind_textdomain_codeset ("mate-applets", "UTF-8"); if ((!(
0))) textdomain ("mate-applets"); } 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 ("StickyNotesAppletFactory"
,(!(0)), mate_panel_applet_get_type (), stickynotes_applet_factory
, ((void*)0)); g_option_context_free (context); return retval
; }
91 NULL)int main(int argc, char *argv[]) { GOptionContext *context; GError
*error; int retval; do { bindtextdomain ("mate-applets", "/usr/local/share/locale"
); bind_textdomain_codeset ("mate-applets", "UTF-8"); if ((!(
0))) textdomain ("mate-applets"); } 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 ("StickyNotesAppletFactory"
,(!(0)), mate_panel_applet_get_type (), stickynotes_applet_factory
, ((void*)0)); g_option_context_free (context); return retval
; }
92
93/* colorshift a surface */
94static void
95stickynotes_make_prelight_icon (cairo_surface_t *dest,
96 cairo_surface_t *src,
97 int shift)
98{
99 gint i, j;
100 gint width, height, has_alpha, srcrowstride, destrowstride;
101 guchar *target_pixels;
102 guchar *original_pixels;
103 guchar *pixsrc;
104 guchar *pixdest;
105 int val;
106 guchar r,g,b;
107
108 has_alpha = cairo_surface_get_content (src) != CAIRO_CONTENT_COLOR;
109 width = cairo_image_surface_get_width (src);
110 height = cairo_image_surface_get_height (src);
111 srcrowstride = cairo_image_surface_get_stride (src);
112 destrowstride = cairo_image_surface_get_stride (dest);
113 original_pixels = cairo_image_surface_get_data (src);
114 target_pixels = cairo_image_surface_get_data (dest);
115
116 for (i = 0; i < height; i++) {
117 pixdest = target_pixels + i*destrowstride;
118 pixsrc = original_pixels + i*srcrowstride;
119 for (j = 0; j < width; j++) {
120 r = *(pixsrc++);
121 g = *(pixsrc++);
122 b = *(pixsrc++);
123 val = r + shift;
124 *(pixdest++) = CLAMP (val, 0, 255)(((val) > (255)) ? (255) : (((val) < (0)) ? (0) : (val)
))
;
125 val = g + shift;
126 *(pixdest++) = CLAMP (val, 0, 255)(((val) > (255)) ? (255) : (((val) < (0)) ? (0) : (val)
))
;
127 val = b + shift;
128 *(pixdest++) = CLAMP (val, 0, 255)(((val) > (255)) ? (255) : (((val) < (0)) ? (0) : (val)
))
;
129 if (has_alpha)
130 *(pixdest++) = *(pixsrc++);
131 }
132 }
133}
134
135static void
136icon_theme_changed (GtkIconTheme *icon_theme,
137 gpointer user_data)
138{
139 gtk_icon_theme_append_search_path (icon_theme,
140 PKG_DATA_DIR"/usr/local/share/mate-applets" G_DIR_SEPARATOR_S"/" "icons");
141}
142
143static void
144stickynotes_applet_init_icons (void)
145{
146 GtkIconTheme *icon_theme;
147
148 icon_theme = gtk_icon_theme_get_default ();
149 icon_theme_changed (icon_theme, NULL((void*)0));
150
151 g_signal_connect (gtk_icon_theme_get_default (), "changed",g_signal_connect_data ((gtk_icon_theme_get_default ()), ("changed"
), (((GCallback) (icon_theme_changed))), (((void*)0)), ((void
*)0), (GConnectFlags) 0)
152 G_CALLBACK (icon_theme_changed), NULL)g_signal_connect_data ((gtk_icon_theme_get_default ()), ("changed"
), (((GCallback) (icon_theme_changed))), (((void*)0)), ((void
*)0), (GConnectFlags) 0)
;
153}
154
155static void
156stickynotes_destroy (GtkWidget *widget,
157 gpointer user_dta)
158{
159 g_signal_handlers_disconnect_by_func (gtk_icon_theme_get_default (),g_signal_handlers_disconnect_matched ((gtk_icon_theme_get_default
()), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (icon_theme_changed), (((void*)0)))
160 icon_theme_changed, NULL)g_signal_handlers_disconnect_matched ((gtk_icon_theme_get_default
()), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (icon_theme_changed), (((void*)0)))
;
161}
162
163/* Create and initalize global sticky notes instance */
164void
165stickynotes_applet_init (MatePanelApplet *mate_panel_applet)
166{
167 cairo_t *cr;
168 gint size, scale;
169 int screen_height;
5
'screen_height' declared without an initial value
170 GdkScreen *screen;
171
172 stickynotes = g_new (StickyNotes, 1)(StickyNotes *) (__extension__ ({ gsize __n = (gsize) (1); gsize
__s = sizeof (StickyNotes); gpointer __p; if (__s == 1) __p =
g_malloc (__n); else if (__builtin_constant_p (__n) &&
(__s == 0 || __n <= (9223372036854775807L *2UL+1UL) / __s
)) __p = g_malloc (__n * __s); else __p = g_malloc_n (__n, __s
); __p; }))
;
6
Taking false branch
173
174 stickynotes->notes = NULL((void*)0);
175 stickynotes->applets = NULL((void*)0);
176 stickynotes->last_timeout_data = 0;
177
178 size = mate_panel_applet_get_size (mate_panel_applet);
179 scale = gtk_widget_get_scale_factor (GTK_WIDGET (mate_panel_applet)((((GtkWidget*) (void *) ((mate_panel_applet))))));
180
181#ifndef ENABLE_IN_PROCESS
182 g_set_application_name (_("Sticky Notes")dcgettext (((void*)0), "Sticky Notes", 5));
183#endif
184 gtk_window_set_default_icon_name ("mate-sticky-notes-applet");
185
186 stickynotes->icon_normal =
187 gtk_icon_theme_load_surface (gtk_icon_theme_get_default (),
188 "mate-sticky-notes-applet",
189 size, scale, NULL((void*)0), 0, NULL((void*)0));
190
191 stickynotes->icon_prelight =
192 cairo_surface_create_similar (stickynotes->icon_normal,
193 cairo_surface_get_content (stickynotes->icon_normal),
194 cairo_image_surface_get_width (stickynotes->icon_normal),
195 cairo_image_surface_get_height (stickynotes->icon_normal));
196
197 stickynotes_make_prelight_icon (stickynotes->icon_prelight,
198 stickynotes->icon_normal, 30);
199
200 cr = cairo_create (stickynotes->icon_prelight);
201 cairo_set_operator (cr, CAIRO_OPERATOR_DEST_IN);
202 cairo_mask_surface (cr, stickynotes->icon_normal, 0, 0);
203
204 stickynotes->settings = g_settings_new (STICKYNOTES_SCHEMA"org.mate.stickynotes");
205 stickynotes->visible = TRUE(!(0));
206
207 stickynotes_applet_init_icons ();
208 stickynotes_applet_init_prefs ();
209
210 /* Watch GSettings values */
211 g_signal_connect (stickynotes->settings, "changed",g_signal_connect_data ((stickynotes->settings), ("changed"
), (((GCallback) (preferences_apply_cb))), (((void*)0)), ((void
*)0), (GConnectFlags) 0)
212 G_CALLBACK (preferences_apply_cb), NULL)g_signal_connect_data ((stickynotes->settings), ("changed"
), (((GCallback) (preferences_apply_cb))), (((void*)0)), ((void
*)0), (GConnectFlags) 0)
;
213
214 /* Max height for large notes in x11 only
215 * In wayland we do not have access to global screen dimensions
216 */
217
218 screen = gtk_widget_get_screen (GTK_WIDGET (mate_panel_applet)((((GtkWidget*) (void *) ((mate_panel_applet))))));
219#ifdef GDK_WINDOWING_X11
220 if (GDK_IS_X11_DISPLAY (gdk_screen_get_display (screen))(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gdk_screen_get_display (screen))); 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; }))))
)
7
Assuming '__inst' is null
8
Taking true branch
9
Taking false branch
221 screen_height = HeightOfScreen (gdk_x11_screen_get_xscreen (screen))((gdk_x11_screen_get_xscreen (screen))->height) / scale;
222#endif
223
224 stickynotes->max_height = (int) (0.8 * (double) screen_height);
10
The right operand of '*' is a garbage value
225
226 /* Load sticky notes */
227 stickynotes_load (screen);
228
229 install_check_click_on_desktop (screen);
230}
231
232void
233stickynotes_applet_init_prefs (void)
234{
235
236 stickynotes->builder = gtk_builder_new ();
237
238 gtk_builder_add_from_resource (stickynotes->builder,
239 GRESOURCE"/org/mate/mate-applets/sticky-notes/" "sticky-notes-preferences.ui",
240 NULL((void*)0));
241
242 stickynotes->w_prefs =
243 GTK_WIDGET (gtk_builder_get_object (stickynotes->builder,((((GtkWidget*) (void *) ((gtk_builder_get_object (stickynotes
->builder, "preferences_dialog"))))))
244 "preferences_dialog"))((((GtkWidget*) (void *) ((gtk_builder_get_object (stickynotes
->builder, "preferences_dialog"))))))
;
245
246 stickynotes->w_prefs_width =
247 gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (gtk_builder_get_object (stickynotes->builder,((((GtkSpinButton*) (void *) ((gtk_builder_get_object (stickynotes
->builder, "width_spin"))))))
248 "width_spin"))((((GtkSpinButton*) (void *) ((gtk_builder_get_object (stickynotes
->builder, "width_spin"))))))
);
249 stickynotes->w_prefs_height =
250 gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (gtk_builder_get_object (stickynotes->builder,((((GtkSpinButton*) (void *) ((gtk_builder_get_object (stickynotes
->builder, "height_spin"))))))
251 "height_spin"))((((GtkSpinButton*) (void *) ((gtk_builder_get_object (stickynotes
->builder, "height_spin"))))))
);
252 stickynotes->w_prefs_color =
253 GTK_WIDGET (gtk_builder_get_object (stickynotes->builder,((((GtkWidget*) (void *) ((gtk_builder_get_object (stickynotes
->builder, "default_color"))))))
254 "default_color"))((((GtkWidget*) (void *) ((gtk_builder_get_object (stickynotes
->builder, "default_color"))))))
;
255 stickynotes->w_prefs_font_color =
256 GTK_WIDGET (gtk_builder_get_object (stickynotes->builder,((((GtkWidget*) (void *) ((gtk_builder_get_object (stickynotes
->builder, "prefs_font_color"))))))
257 "prefs_font_color"))((((GtkWidget*) (void *) ((gtk_builder_get_object (stickynotes
->builder, "prefs_font_color"))))))
;
258 stickynotes->w_prefs_sys_color =
259 GTK_WIDGET (&GTK_CHECK_BUTTON (gtk_builder_get_object (stickynotes->builder,((((GtkWidget*) (void *) ((&((((GtkCheckButton*) (void *)
((gtk_builder_get_object (stickynotes->builder, "sys_color_check"
))))))->toggle_button)))))
260 "sys_color_check"))->toggle_button)((((GtkWidget*) (void *) ((&((((GtkCheckButton*) (void *)
((gtk_builder_get_object (stickynotes->builder, "sys_color_check"
))))))->toggle_button)))))
;
261 stickynotes->w_prefs_font =
262 GTK_WIDGET (gtk_builder_get_object (stickynotes->builder,((((GtkWidget*) (void *) ((gtk_builder_get_object (stickynotes
->builder, "default_font"))))))
263 "default_font"))((((GtkWidget*) (void *) ((gtk_builder_get_object (stickynotes
->builder, "default_font"))))))
;
264 stickynotes->w_prefs_sys_font =
265 GTK_WIDGET (&GTK_CHECK_BUTTON (gtk_builder_get_object (stickynotes->builder,((((GtkWidget*) (void *) ((&((((GtkCheckButton*) (void *)
((gtk_builder_get_object (stickynotes->builder, "sys_font_check"
))))))->toggle_button)))))
266 "sys_font_check"))->toggle_button)((((GtkWidget*) (void *) ((&((((GtkCheckButton*) (void *)
((gtk_builder_get_object (stickynotes->builder, "sys_font_check"
))))))->toggle_button)))))
;
267 stickynotes->w_prefs_sticky =
268 GTK_WIDGET (&GTK_CHECK_BUTTON (gtk_builder_get_object (stickynotes->builder,((((GtkWidget*) (void *) ((&((((GtkCheckButton*) (void *)
((gtk_builder_get_object (stickynotes->builder, "sticky_check"
))))))->toggle_button)))))
269 "sticky_check"))->toggle_button)((((GtkWidget*) (void *) ((&((((GtkCheckButton*) (void *)
((gtk_builder_get_object (stickynotes->builder, "sticky_check"
))))))->toggle_button)))))
;
270 stickynotes->w_prefs_force =
271 GTK_WIDGET (&GTK_CHECK_BUTTON (gtk_builder_get_object (stickynotes->builder,((((GtkWidget*) (void *) ((&((((GtkCheckButton*) (void *)
((gtk_builder_get_object (stickynotes->builder, "force_default_check"
))))))->toggle_button)))))
272 "force_default_check"))->toggle_button)((((GtkWidget*) (void *) ((&((((GtkCheckButton*) (void *)
((gtk_builder_get_object (stickynotes->builder, "force_default_check"
))))))->toggle_button)))))
;
273 stickynotes->w_prefs_desktop =
274 GTK_WIDGET (&GTK_CHECK_BUTTON (gtk_builder_get_object (stickynotes->builder,((((GtkWidget*) (void *) ((&((((GtkCheckButton*) (void *)
((gtk_builder_get_object (stickynotes->builder, "desktop_hide_check"
))))))->toggle_button)))))
275 "desktop_hide_check"))->toggle_button)((((GtkWidget*) (void *) ((&((((GtkCheckButton*) (void *)
((gtk_builder_get_object (stickynotes->builder, "desktop_hide_check"
))))))->toggle_button)))))
;
276
277 g_signal_connect (stickynotes->w_prefs, "response",g_signal_connect_data ((stickynotes->w_prefs), ("response"
), (((GCallback) (preferences_response_cb))), (((void*)0)), (
(void*)0), (GConnectFlags) 0)
278 G_CALLBACK (preferences_response_cb), NULL)g_signal_connect_data ((stickynotes->w_prefs), ("response"
), (((GCallback) (preferences_response_cb))), (((void*)0)), (
(void*)0), (GConnectFlags) 0)
;
279 g_signal_connect (stickynotes->w_prefs, "delete-event",g_signal_connect_data ((stickynotes->w_prefs), ("delete-event"
), (((GCallback) (preferences_delete_cb))), (((void*)0)), ((void
*)0), (GConnectFlags) 0)
280 G_CALLBACK (preferences_delete_cb), NULL)g_signal_connect_data ((stickynotes->w_prefs), ("delete-event"
), (((GCallback) (preferences_delete_cb))), (((void*)0)), ((void
*)0), (GConnectFlags) 0)
;
281 g_signal_connect_swapped (stickynotes->w_prefs_width, "value-changed",g_signal_connect_data ((stickynotes->w_prefs_width), ("value-changed"
), (((GCallback) (preferences_save_cb))), (((void*)0)), ((void
*)0), G_CONNECT_SWAPPED)
282 G_CALLBACK (preferences_save_cb), NULL)g_signal_connect_data ((stickynotes->w_prefs_width), ("value-changed"
), (((GCallback) (preferences_save_cb))), (((void*)0)), ((void
*)0), G_CONNECT_SWAPPED)
;
283 g_signal_connect_swapped (stickynotes->w_prefs_height, "value-changed",g_signal_connect_data ((stickynotes->w_prefs_height), ("value-changed"
), (((GCallback) (preferences_save_cb))), (((void*)0)), ((void
*)0), G_CONNECT_SWAPPED)
284 G_CALLBACK (preferences_save_cb), NULL)g_signal_connect_data ((stickynotes->w_prefs_height), ("value-changed"
), (((GCallback) (preferences_save_cb))), (((void*)0)), ((void
*)0), G_CONNECT_SWAPPED)
;
285 g_signal_connect_swapped (stickynotes->w_prefs_sys_color, "toggled",g_signal_connect_data ((stickynotes->w_prefs_sys_color), (
"toggled"), (((GCallback) (preferences_save_cb))), (((void*)0
)), ((void*)0), G_CONNECT_SWAPPED)
286 G_CALLBACK (preferences_save_cb), NULL)g_signal_connect_data ((stickynotes->w_prefs_sys_color), (
"toggled"), (((GCallback) (preferences_save_cb))), (((void*)0
)), ((void*)0), G_CONNECT_SWAPPED)
;
287 g_signal_connect_swapped (stickynotes->w_prefs_sys_font, "toggled",g_signal_connect_data ((stickynotes->w_prefs_sys_font), ("toggled"
), (((GCallback) (preferences_save_cb))), (((void*)0)), ((void
*)0), G_CONNECT_SWAPPED)
288 G_CALLBACK (preferences_save_cb), NULL)g_signal_connect_data ((stickynotes->w_prefs_sys_font), ("toggled"
), (((GCallback) (preferences_save_cb))), (((void*)0)), ((void
*)0), G_CONNECT_SWAPPED)
;
289 g_signal_connect (stickynotes->w_prefs_color, "color-set",g_signal_connect_data ((stickynotes->w_prefs_color), ("color-set"
), (((GCallback) (preferences_color_cb))), (((void*)0)), ((void
*)0), (GConnectFlags) 0)
290 G_CALLBACK (preferences_color_cb), NULL)g_signal_connect_data ((stickynotes->w_prefs_color), ("color-set"
), (((GCallback) (preferences_color_cb))), (((void*)0)), ((void
*)0), (GConnectFlags) 0)
;
291 g_signal_connect (stickynotes->w_prefs_font_color, "color-set",g_signal_connect_data ((stickynotes->w_prefs_font_color), (
"color-set"), (((GCallback) (preferences_color_cb))), (((void
*)0)), ((void*)0), (GConnectFlags) 0)
292 G_CALLBACK (preferences_color_cb), NULL)g_signal_connect_data ((stickynotes->w_prefs_font_color), (
"color-set"), (((GCallback) (preferences_color_cb))), (((void
*)0)), ((void*)0), (GConnectFlags) 0)
;
293 g_signal_connect (stickynotes->w_prefs_font, "font-set",g_signal_connect_data ((stickynotes->w_prefs_font), ("font-set"
), (((GCallback) (preferences_font_cb))), (((void*)0)), ((void
*)0), (GConnectFlags) 0)
294 G_CALLBACK (preferences_font_cb), NULL)g_signal_connect_data ((stickynotes->w_prefs_font), ("font-set"
), (((GCallback) (preferences_font_cb))), (((void*)0)), ((void
*)0), (GConnectFlags) 0)
;
295 g_signal_connect_swapped (stickynotes->w_prefs_sticky, "toggled",g_signal_connect_data ((stickynotes->w_prefs_sticky), ("toggled"
), (((GCallback) (preferences_save_cb))), (((void*)0)), ((void
*)0), G_CONNECT_SWAPPED)
296 G_CALLBACK (preferences_save_cb), NULL)g_signal_connect_data ((stickynotes->w_prefs_sticky), ("toggled"
), (((GCallback) (preferences_save_cb))), (((void*)0)), ((void
*)0), G_CONNECT_SWAPPED)
;
297 g_signal_connect_swapped (stickynotes->w_prefs_force, "toggled",g_signal_connect_data ((stickynotes->w_prefs_force), ("toggled"
), (((GCallback) (preferences_save_cb))), (((void*)0)), ((void
*)0), G_CONNECT_SWAPPED)
298 G_CALLBACK (preferences_save_cb), NULL)g_signal_connect_data ((stickynotes->w_prefs_force), ("toggled"
), (((GCallback) (preferences_save_cb))), (((void*)0)), ((void
*)0), G_CONNECT_SWAPPED)
;
299 g_signal_connect_swapped (stickynotes->w_prefs_desktop, "toggled",g_signal_connect_data ((stickynotes->w_prefs_desktop), ("toggled"
), (((GCallback) (preferences_save_cb))), (((void*)0)), ((void
*)0), G_CONNECT_SWAPPED)
300 G_CALLBACK (preferences_save_cb), NULL)g_signal_connect_data ((stickynotes->w_prefs_desktop), ("toggled"
), (((GCallback) (preferences_save_cb))), (((void*)0)), ((void
*)0), G_CONNECT_SWAPPED)
;
301
302 {
303 GtkSizeGroup *group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
304
305 gtk_size_group_add_widget (group,
306 GTK_WIDGET (gtk_builder_get_object (stickynotes->builder,((((GtkWidget*) (void *) ((gtk_builder_get_object (stickynotes
->builder, "width_label"))))))
307 "width_label"))((((GtkWidget*) (void *) ((gtk_builder_get_object (stickynotes
->builder, "width_label"))))))
);
308 gtk_size_group_add_widget (group,
309 GTK_WIDGET (gtk_builder_get_object (stickynotes->builder,((((GtkWidget*) (void *) ((gtk_builder_get_object (stickynotes
->builder, "height_label"))))))
310 "height_label"))((((GtkWidget*) (void *) ((gtk_builder_get_object (stickynotes
->builder, "height_label"))))))
);
311 gtk_size_group_add_widget (group,
312 GTK_WIDGET (gtk_builder_get_object (stickynotes->builder,((((GtkWidget*) (void *) ((gtk_builder_get_object (stickynotes
->builder, "prefs_color_label"))))))
313 "prefs_color_label"))((((GtkWidget*) (void *) ((gtk_builder_get_object (stickynotes
->builder, "prefs_color_label"))))))
);
314
315 g_object_unref (group);
316 }
317
318 if (!g_settings_is_writable (stickynotes->settings, "default-width")) {
319 gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (stickynotes->builder,((((GtkWidget*) (void *) ((gtk_builder_get_object (stickynotes
->builder, "width_label"))))))
320 "width_label"))((((GtkWidget*) (void *) ((gtk_builder_get_object (stickynotes
->builder, "width_label"))))))
,
321 FALSE(0));
322 gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (stickynotes->builder,((((GtkWidget*) (void *) ((gtk_builder_get_object (stickynotes
->builder, "width_spin"))))))
323 "width_spin"))((((GtkWidget*) (void *) ((gtk_builder_get_object (stickynotes
->builder, "width_spin"))))))
,
324 FALSE(0));
325 }
326 if (!g_settings_is_writable (stickynotes->settings, "default-height")) {
327 gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (stickynotes->builder,((((GtkWidget*) (void *) ((gtk_builder_get_object (stickynotes
->builder, "height_label"))))))
328 "height_label"))((((GtkWidget*) (void *) ((gtk_builder_get_object (stickynotes
->builder, "height_label"))))))
,
329 FALSE(0));
330 gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (stickynotes->builder,((((GtkWidget*) (void *) ((gtk_builder_get_object (stickynotes
->builder, "height_spin"))))))
331 "height_spin"))((((GtkWidget*) (void *) ((gtk_builder_get_object (stickynotes
->builder, "height_spin"))))))
,
332 FALSE(0));
333 }
334 if (!g_settings_is_writable (stickynotes->settings, "default-color")) {
335 gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (stickynotes->builder,((((GtkWidget*) (void *) ((gtk_builder_get_object (stickynotes
->builder, "prefs_color_label"))))))
336 "prefs_color_label"))((((GtkWidget*) (void *) ((gtk_builder_get_object (stickynotes
->builder, "prefs_color_label"))))))
,
337 FALSE(0));
338 gtk_widget_set_sensitive (stickynotes->w_prefs_color, FALSE(0));
339 }
340 if (!g_settings_is_writable (stickynotes->settings, "default-font-color")) {
341 gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (stickynotes->builder,((((GtkWidget*) (void *) ((gtk_builder_get_object (stickynotes
->builder, "prefs_font_color_label"))))))
342 "prefs_font_color_label"))((((GtkWidget*) (void *) ((gtk_builder_get_object (stickynotes
->builder, "prefs_font_color_label"))))))
,
343 FALSE(0));
344 gtk_widget_set_sensitive (stickynotes->w_prefs_font_color, FALSE(0));
345 }
346 if (!g_settings_is_writable (stickynotes->settings, "use-system-color"))
347 gtk_widget_set_sensitive (stickynotes->w_prefs_sys_color, FALSE(0));
348 if (!g_settings_is_writable (stickynotes->settings, "default-font")) {
349 gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (stickynotes->builder,((((GtkWidget*) (void *) ((gtk_builder_get_object (stickynotes
->builder, "prefs_font_label"))))))
350 "prefs_font_label"))((((GtkWidget*) (void *) ((gtk_builder_get_object (stickynotes
->builder, "prefs_font_label"))))))
,
351 FALSE(0));
352 gtk_widget_set_sensitive (stickynotes->w_prefs_font, FALSE(0));
353 }
354 if (!g_settings_is_writable (stickynotes->settings, "use-system-font"))
355 gtk_widget_set_sensitive (stickynotes->w_prefs_sys_font, FALSE(0));
356 if (!g_settings_is_writable (stickynotes->settings, "sticky"))
357 gtk_widget_set_sensitive (stickynotes->w_prefs_sticky, FALSE(0));
358 if (!g_settings_is_writable (stickynotes->settings, "force-default"))
359 gtk_widget_set_sensitive (stickynotes->w_prefs_force, FALSE(0));
360
361 stickynotes_applet_update_prefs ();
362}
363
364/* Create a Sticky Notes applet */
365StickyNotesApplet *
366stickynotes_applet_new (MatePanelApplet *mate_panel_applet)
367{
368 AtkObject *atk_obj;
369
370 /* Create Sticky Notes Applet */
371 StickyNotesApplet *applet = g_new (StickyNotesApplet, 1)(StickyNotesApplet *) (__extension__ ({ gsize __n = (gsize) (
1); gsize __s = sizeof (StickyNotesApplet); gpointer __p; if (
__s == 1) __p = g_malloc (__n); else if (__builtin_constant_p
(__n) && (__s == 0 || __n <= (9223372036854775807L
*2UL+1UL) / __s)) __p = g_malloc (__n * __s); else __p = g_malloc_n
(__n, __s); __p; }))
;
372
373 /* Initialize Sticky Notes Applet */
374 applet->w_applet = GTK_WIDGET (mate_panel_applet)((((GtkWidget*) (void *) ((mate_panel_applet)))));
375 applet->w_image = gtk_image_new ();
376 applet->destroy_all_dialog = NULL((void*)0);
377 applet->prelighted = FALSE(0);
378
379 applet->menu_tip = NULL((void*)0);
380
381 /* Expand the applet for Fitts' law complience. */
382 mate_panel_applet_set_flags (mate_panel_applet,
383 MATE_PANEL_APPLET_EXPAND_MINOR);
384
385 /* Add the applet icon */
386 gtk_container_add (GTK_CONTAINER (mate_panel_applet)((((GtkContainer*) (void *) ((mate_panel_applet))))),
387 applet->w_image);
388 applet->panel_size = mate_panel_applet_get_size (mate_panel_applet);
389 applet->panel_orient = mate_panel_applet_get_orient (mate_panel_applet);
390 stickynotes_applet_update_icon (applet);
391
392 /* Add the popup menu */
393 applet->action_group = gtk_action_group_new ("StickyNotes Applet Actions");
394 gtk_action_group_set_translation_domain (applet->action_group,
395 GETTEXT_PACKAGE"mate-applets");
396 gtk_action_group_add_actions (applet->action_group,
397 stickynotes_applet_menu_actions,
398 G_N_ELEMENTS (stickynotes_applet_menu_actions)(sizeof (stickynotes_applet_menu_actions) / sizeof ((stickynotes_applet_menu_actions
)[0]))
,
399 applet);
400 gtk_action_group_add_toggle_actions (applet->action_group,
401 stickynotes_applet_menu_toggle_actions,
402 G_N_ELEMENTS (stickynotes_applet_menu_toggle_actions)(sizeof (stickynotes_applet_menu_toggle_actions) / sizeof ((stickynotes_applet_menu_toggle_actions
)[0]))
,
403 applet);
404 mate_panel_applet_setup_menu_from_resource (mate_panel_applet,
405 GRESOURCE"/org/mate/mate-applets/sticky-notes/" "menu.xml",
406 applet->action_group);
407
408 if (mate_panel_applet_get_locked_down (mate_panel_applet)) {
409 GtkAction *action;
410
411 action = gtk_action_group_get_action (applet->action_group,
412 "preferences");
413 gtk_action_set_visible (action, FALSE(0));
414 }
415
416 /* Connect all signals for applet management */
417 g_signal_connect (applet->w_applet, "button-press-event",g_signal_connect_data ((applet->w_applet), ("button-press-event"
), (((GCallback) (applet_button_cb))), (applet), ((void*)0), (
GConnectFlags) 0)
418 G_CALLBACK (applet_button_cb), applet)g_signal_connect_data ((applet->w_applet), ("button-press-event"
), (((GCallback) (applet_button_cb))), (applet), ((void*)0), (
GConnectFlags) 0)
;
419 g_signal_connect (applet->w_applet, "key-press-event",g_signal_connect_data ((applet->w_applet), ("key-press-event"
), (((GCallback) (applet_key_cb))), (applet), ((void*)0), (GConnectFlags
) 0)
420 G_CALLBACK (applet_key_cb), applet)g_signal_connect_data ((applet->w_applet), ("key-press-event"
), (((GCallback) (applet_key_cb))), (applet), ((void*)0), (GConnectFlags
) 0)
;
421 g_signal_connect (applet->w_applet, "focus-in-event",g_signal_connect_data ((applet->w_applet), ("focus-in-event"
), (((GCallback) (applet_focus_cb))), (applet), ((void*)0), (
GConnectFlags) 0)
422 G_CALLBACK (applet_focus_cb), applet)g_signal_connect_data ((applet->w_applet), ("focus-in-event"
), (((GCallback) (applet_focus_cb))), (applet), ((void*)0), (
GConnectFlags) 0)
;
423 g_signal_connect (applet->w_applet, "focus-out-event",g_signal_connect_data ((applet->w_applet), ("focus-out-event"
), (((GCallback) (applet_focus_cb))), (applet), ((void*)0), (
GConnectFlags) 0)
424 G_CALLBACK (applet_focus_cb), applet)g_signal_connect_data ((applet->w_applet), ("focus-out-event"
), (((GCallback) (applet_focus_cb))), (applet), ((void*)0), (
GConnectFlags) 0)
;
425 g_signal_connect (applet->w_applet, "enter-notify-event",g_signal_connect_data ((applet->w_applet), ("enter-notify-event"
), (((GCallback) (applet_cross_cb))), (applet), ((void*)0), (
GConnectFlags) 0)
426 G_CALLBACK (applet_cross_cb), applet)g_signal_connect_data ((applet->w_applet), ("enter-notify-event"
), (((GCallback) (applet_cross_cb))), (applet), ((void*)0), (
GConnectFlags) 0)
;
427 g_signal_connect (applet->w_applet, "leave-notify-event",g_signal_connect_data ((applet->w_applet), ("leave-notify-event"
), (((GCallback) (applet_cross_cb))), (applet), ((void*)0), (
GConnectFlags) 0)
428 G_CALLBACK (applet_cross_cb), applet)g_signal_connect_data ((applet->w_applet), ("leave-notify-event"
), (((GCallback) (applet_cross_cb))), (applet), ((void*)0), (
GConnectFlags) 0)
;
429 g_signal_connect (applet->w_applet, "size-allocate",g_signal_connect_data ((applet->w_applet), ("size-allocate"
), (((GCallback) (applet_size_allocate_cb))), (applet), ((void
*)0), (GConnectFlags) 0)
430 G_CALLBACK (applet_size_allocate_cb), applet)g_signal_connect_data ((applet->w_applet), ("size-allocate"
), (((GCallback) (applet_size_allocate_cb))), (applet), ((void
*)0), (GConnectFlags) 0)
;
431 g_signal_connect (applet->w_applet, "change-orient",g_signal_connect_data ((applet->w_applet), ("change-orient"
), (((GCallback) (applet_change_orient_cb))), (applet), ((void
*)0), (GConnectFlags) 0)
432 G_CALLBACK (applet_change_orient_cb), applet)g_signal_connect_data ((applet->w_applet), ("change-orient"
), (((GCallback) (applet_change_orient_cb))), (applet), ((void
*)0), (GConnectFlags) 0)
;
433 g_signal_connect (applet->w_applet, "destroy",g_signal_connect_data ((applet->w_applet), ("destroy"), ((
(GCallback) (applet_destroy_cb))), (applet), ((void*)0), (GConnectFlags
) 0)
434 G_CALLBACK (applet_destroy_cb), applet)g_signal_connect_data ((applet->w_applet), ("destroy"), ((
(GCallback) (applet_destroy_cb))), (applet), ((void*)0), (GConnectFlags
) 0)
;
435 g_signal_connect (applet->w_applet, "destroy",g_signal_connect_data ((applet->w_applet), ("destroy"), ((
(GCallback) (stickynotes_destroy))), (((void*)0)), ((void*)0)
, (GConnectFlags) 0)
436 G_CALLBACK (stickynotes_destroy), NULL)g_signal_connect_data ((applet->w_applet), ("destroy"), ((
(GCallback) (stickynotes_destroy))), (((void*)0)), ((void*)0)
, (GConnectFlags) 0)
;
437
438 atk_obj = gtk_widget_get_accessible (applet->w_applet);
439 atk_object_set_name (atk_obj, _("Sticky Notes")dcgettext (((void*)0), "Sticky Notes", 5));
440
441 /* Show the applet */
442 gtk_widget_show_all (applet->w_applet);
443
444 return applet;
445}
446
447void
448stickynotes_applet_update_icon (StickyNotesApplet *applet)
449{
450 cairo_t *cr;
451 cairo_surface_t *surface;
452
453 gint size = applet->panel_size;
454
455 if (size > 3)
456 size = size - 3;
457
458 /* Choose appropriate icon and size it */
459 if (applet->prelighted)
460 surface = cairo_surface_create_similar (stickynotes->icon_prelight,
461 cairo_surface_get_content (stickynotes->icon_prelight),
462 size, size);
463 else
464 surface = cairo_surface_create_similar (stickynotes->icon_normal,
465 cairo_surface_get_content (stickynotes->icon_normal),
466 size, size);
467
468 cr = cairo_create (surface);
469 cairo_set_source_surface (cr, applet->prelighted ? stickynotes->icon_prelight : stickynotes->icon_normal, 0, 0);
470 cairo_paint (cr);
471
472 /* Apply the finished surface to the applet image */
473 gtk_image_set_from_surface (GTK_IMAGE (applet->w_image)((((GtkImage*) (void *) ((applet->w_image))))), surface);
474
475 cairo_surface_destroy (surface);
476}
477
478void
479stickynotes_applet_update_prefs (void)
480{
481 gint width, height;
482 gboolean sys_color, sys_font, sticky, force_default, desktop_hide;
483 char *font_str;
484 char *color_str, *font_color_str;
485 GdkRGBA color, font_color;
486
487 width = g_settings_get_int (stickynotes->settings,
488 "default-width");
489 width = MAX (width, 1)(((width) > (1)) ? (width) : (1));
490 height = g_settings_get_int (stickynotes->settings,
491 "default-height");
492 height = MAX (height, 1)(((height) > (1)) ? (height) : (1));
493
494 sys_color = g_settings_get_boolean (stickynotes->settings,
495 "use-system-color");
496 sys_font = g_settings_get_boolean (stickynotes->settings,
497 "use-system-font");
498 sticky = g_settings_get_boolean (stickynotes->settings,
499 "sticky");
500 force_default = g_settings_get_boolean (stickynotes->settings,
501 "force-default");
502 desktop_hide = g_settings_get_boolean (stickynotes->settings,
503 "desktop-hide");
504
505 font_str = g_settings_get_string (stickynotes->settings,
506 "default-font");
507 if (!font_str)
508 font_str = g_strdup ("Sans 10")g_strdup_inline ("Sans 10");
509
510 color_str = g_settings_get_string (stickynotes->settings,
511 "default-color");
512 if (!color_str)
513 color_str = g_strdup ("#ECF833")g_strdup_inline ("#ECF833");
514
515 font_color_str = g_settings_get_string (stickynotes->settings,
516 "default-font-color");
517 if (!font_color_str)
518 font_color_str = g_strdup ("#000000")g_strdup_inline ("#000000");
519
520 gdk_rgba_parse (&color, color_str);
521 gdk_rgba_parse (&font_color, font_color_str);
522
523 g_free (color_str);
524 g_free (font_color_str);
525
526 gtk_adjustment_set_value (stickynotes->w_prefs_width, width);
527 gtk_adjustment_set_value (stickynotes->w_prefs_height, height);
528 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (stickynotes->w_prefs_sys_color)((((GtkToggleButton*) (void *) ((stickynotes->w_prefs_sys_color
)))))
,
529 sys_color);
530 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (stickynotes->w_prefs_sys_font)((((GtkToggleButton*) (void *) ((stickynotes->w_prefs_sys_font
)))))
,
531 sys_font);
532 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (stickynotes->w_prefs_sticky)((((GtkToggleButton*) (void *) ((stickynotes->w_prefs_sticky
)))))
,
533 sticky);
534 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (stickynotes->w_prefs_force)((((GtkToggleButton*) (void *) ((stickynotes->w_prefs_force
)))))
,
535 force_default);
536 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (stickynotes->w_prefs_desktop)((((GtkToggleButton*) (void *) ((stickynotes->w_prefs_desktop
)))))
,
537 desktop_hide);
538
539 gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (stickynotes->w_prefs_color)((((GtkColorChooser*) (void *) ((stickynotes->w_prefs_color
)))))
,
540 &color);
541 gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (stickynotes->w_prefs_font_color)((((GtkColorChooser*) (void *) ((stickynotes->w_prefs_font_color
)))))
,
542 &font_color);
543
544 gtk_font_button_set_font_name (GTK_FONT_BUTTON (stickynotes->w_prefs_font)((((GtkFontButton*) (void *) ((stickynotes->w_prefs_font))
)))
,
545 font_str);
546 g_free (font_str);
547
548 if (g_settings_is_writable (stickynotes->settings, "default-color")) {
549 gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (stickynotes->builder,((((GtkWidget*) (void *) ((gtk_builder_get_object (stickynotes
->builder, "prefs_color_label"))))))
550 "prefs_color_label"))((((GtkWidget*) (void *) ((gtk_builder_get_object (stickynotes
->builder, "prefs_color_label"))))))
,
551 !sys_color);
552 gtk_widget_set_sensitive (stickynotes->w_prefs_color, !sys_color);
553 }
554 if (g_settings_is_writable (stickynotes->settings, "default-font-color")) {
555 gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (stickynotes->builder,((((GtkWidget*) (void *) ((gtk_builder_get_object (stickynotes
->builder, "prefs_font_color_label"))))))
556 "prefs_font_color_label"))((((GtkWidget*) (void *) ((gtk_builder_get_object (stickynotes
->builder, "prefs_font_color_label"))))))
,
557 !sys_color);
558 gtk_widget_set_sensitive (stickynotes->w_prefs_font_color, !sys_color);
559 }
560 if (g_settings_is_writable (stickynotes->settings, "default-font")) {
561 gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (stickynotes->builder,((((GtkWidget*) (void *) ((gtk_builder_get_object (stickynotes
->builder, "prefs_font_label"))))))
562 "prefs_font_label"))((((GtkWidget*) (void *) ((gtk_builder_get_object (stickynotes
->builder, "prefs_font_label"))))))
,
563 !sys_font);
564 gtk_widget_set_sensitive (stickynotes->w_prefs_font, !sys_font);
565 }
566}
567
568void
569stickynotes_applet_update_menus (void)
570{
571 GList *l;
572 gboolean inconsistent = FALSE(0);
573
574 gboolean locked = g_settings_get_boolean (stickynotes->settings,
575 "locked");
576 gboolean locked_writable = g_settings_is_writable (stickynotes->settings,
577 "locked");
578
579 for (l = stickynotes->notes; l != NULL((void*)0); l = l->next) {
580 StickyNote *note = l->data;
581
582 if (note->locked != locked) {
583 inconsistent = TRUE(!(0));
584 break;
585 }
586 }
587
588 for (l = stickynotes->applets; l != NULL((void*)0); l = l->next) {
589 StickyNotesApplet *applet = l->data;
590 GSList *proxies, *p;
591
592 GtkAction *action = gtk_action_group_get_action (applet->action_group,
593 "lock");
594
595 g_object_set (action,
596 "active", locked,
597 "sensitive", locked_writable,
598 NULL((void*)0));
599
600 proxies = gtk_action_get_proxies (action);
601 for (p = proxies; p; p = g_slist_next (p)((p) ? (((GSList *)(p))->next) : ((void*)0))) {
602 if (GTK_IS_CHECK_MENU_ITEM (p->data)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(p->data)); GType __t = ((gtk_check_menu_item_get_type ())
); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
)
603 gtk_check_menu_item_set_inconsistent (GTK_CHECK_MENU_ITEM (p->data)((((GtkCheckMenuItem*) (void *) ((p->data))))),
604 inconsistent);
605 }
606 }
607}
608
609void
610stickynotes_applet_update_tooltips (void)
611{
612 int num;
613 char *tooltip, *no_notes;
614 StickyNotesApplet *applet;
615 GList *l;
616
617 num = g_list_length (stickynotes->notes);
618
619 no_notes = g_strdup_printf (ngettext ("%d note",dcngettext (((void*)0), "%d note", "%d notes", num, 5)
620 "%d notes",dcngettext (((void*)0), "%d note", "%d notes", num, 5)
621 num)dcngettext (((void*)0), "%d note", "%d notes", num, 5),
622 num);
623
624 tooltip = g_strdup_printf ("%s\n%s",
625 _("Show sticky notes")dcgettext (((void*)0), "Show sticky notes", 5),
626 no_notes);
627
628 for (l = stickynotes->applets; l; l = l->next)
629 {
630 applet = l->data;
631 gtk_widget_set_tooltip_text (applet->w_applet,
632 tooltip);
633
634 if (applet->menu_tip)
635 gtk_label_set_text (GTK_LABEL (gtk_bin_get_child (GTK_BIN (applet->menu_tip)))((((GtkLabel*) (void *) ((gtk_bin_get_child (((((GtkBin*) (void
*) ((applet->menu_tip)))))))))))
,
636 no_notes);
637 }
638
639 g_free (tooltip);
640 g_free (no_notes);
641}
642
643void
644stickynotes_applet_panel_icon_get_geometry (int *x,
645 int *y,
646 int *width,
647 int *height)
648{
649 GtkWidget *widget;
650 GtkAllocation allocation;
651 GtkRequisition requisition;
652 StickyNotesApplet *applet;
653
654 applet = stickynotes->applets->data;
655
656 widget = GTK_WIDGET (applet->w_image)((((GtkWidget*) (void *) ((applet->w_image)))));
657
658 gtk_widget_get_preferred_size (widget,
659 NULL((void*)0), &requisition);
660
661 gdk_window_get_origin (gtk_widget_get_window (widget), x, y);
662
663 gtk_widget_get_allocation (widget, &allocation);
664 *width = allocation.x;
665 *height = allocation.y;
666}
diff --git a/2023-10-06-143029-14295-1@5e7148e14497_gtk-image-menu-item/report-3faa94.html b/2023-10-06-143029-14295-1@5e7148e14497_gtk-image-menu-item/report-3faa94.html new file mode 100644 index 00000000..319072b6 --- /dev/null +++ b/2023-10-06-143029-14295-1@5e7148e14497_gtk-image-menu-item/report-3faa94.html @@ -0,0 +1,1169 @@ + + + +apmlib.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:battstat/apmlib/apmlib.c
Warning:line 89, column 5
Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcpy'. CWE-119
+ +

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 apmlib.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=none -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/battstat/apmlib -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I ../.. -I ../.. -I ../../apmlib -D G_LOG_DOMAIN="battstat_applet" -D PIC -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -fdebug-compilation-dir=/rootdir/battstat/apmlib -ferror-limit 19 -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-10-06-143029-14295-1 -x c apmlib.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* apmlib.c -- Sample APM interface routines
2 * Created: Mon Jan 8 10:28:16 1996 by faith@acm.org
3 * Revised: Fri Dec 26 21:38:29 1997 by faith@acm.org
4 * Copyright 1996, 1997 Rickard E. Faith (faith@acm.org)
5 *
6 * This library is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU Library General Public License as published
8 * by the Free Software Foundation; either version 2 of the License, or (at
9 * your option) any later version.
10 *
11 * This library 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 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
19 *
20 */
21#include <stdio.h>
22#include <stdlib.h>
23#include <unistd.h>
24#include <string.h>
25#include <fcntl.h>
26#include <ctype.h>
27#include <sys/stat.h>
28#include <sys/time.h>
29#include <sys/ioctl.h>
30#include <sys/types.h>
31#include <sys/sysmacros.h>
32#include "apm.h"
33
34#define BACKWARD_COMPAT1 1
35
36/* If APM support of the right version exists in kernel, return zero.
37 * Otherwise, return 1 if no support exists, or 2 if it is the wrong
38 * version. *NOTE* The sense of the return value is not intuitive.
39 */
40int
41apm_exists (void)
42{
43 apm_info i;
44
45 if (access (APM_PROC"/proc/apm", R_OK4))
46 return 1;
47 return apm_read (&i);
48}
49
50/* Read information from /proc/apm. Return 0 on success, 1 if APM not
51 * installed, 2 if APM installed, but old version.
52 */
53int
54apm_read (apm_info * i)
55{
56 FILE *str;
57 char units[10];
58 char buffer[100];
59 int retcode = 0;
60
61 if (!(str = fopen (APM_PROC"/proc/apm", "r")))
62 return 1;
63
64 if (fgets (buffer, sizeof (buffer) - 1, str) == NULL((void*)0))
65 printf ("fgets error\n");
66
67 buffer[sizeof (buffer) - 1] = '\0';
68
69 /* Should check for other driver versions; driver 1.9 (and some
70 * others) uses this format, which doesn't expose # batteries.
71 */
72 sscanf (buffer, "%s %d.%d %hx %hx %hx %hx %d%% %d %s\n",
73 (char *) i->driver_version,
74 &i->apm_version_major,
75 &i->apm_version_minor,
76 &i->apm_flags,
77 &i->ac_line_status,
78 &i->battery_status,
79 &i->battery_flags,
80 &i->battery_percentage,
81 &i->battery_time,
82 units);
83 i->using_minutes = !strncmp (units, "min", 3) ? 1 : 0;
84 if (i->driver_version[0] == 'B')
85 { /* old style. argh. */
86#if !BACKWARD_COMPAT1
87 retcode = 2;
88#else
89 strcpy ((char *) i->driver_version, "pre-0.7");
Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcpy'. CWE-119
90 i->apm_version_major = 0;
91 i->apm_version_minor = 0;
92 i->apm_flags = 0;
93 i->ac_line_status = 0xff;
94 i->battery_status = 0xff;
95 i->battery_flags = 0xff;
96 i->battery_percentage = -1;
97 i->battery_time = -1;
98 i->using_minutes = 1;
99
100 sscanf (buffer, "BIOS version: %d.%d",
101 &i->apm_version_major, &i->apm_version_minor);
102
103 if (fgets (buffer, sizeof (buffer) - 1, str) == NULL((void*)0))
104 printf ("fgets error\n");
105
106 sscanf (buffer, "Flags: 0x%02hx", &i->apm_flags);
107 if (i->apm_flags & APM_32_BIT_SUPPORT0x0002)
108 {
109 if (fgets (buffer, sizeof (buffer) - 1, str) == NULL((void*)0))
110 printf ("fgets error\n");
111
112 if (fgets (buffer, sizeof (buffer) - 1, str) == NULL((void*)0))
113 printf ("fgets error\n");
114
115 if (buffer[0] != 'P')
116 {
117 if (!strncmp (buffer + 4, "off line", 8))
118 i->ac_line_status = 0;
119 else if (!strncmp (buffer + 4, "on line", 7))
120 i->ac_line_status = 1;
121 else if (!strncmp (buffer + 4, "on back", 7))
122 i->ac_line_status = 2;
123
124 if (fgets (buffer, sizeof (buffer) - 1, str) == NULL((void*)0))
125 printf ("fgets error\n");
126
127 if (!strncmp (buffer + 16, "high", 4))
128 i->battery_status = 0;
129 else if (!strncmp (buffer + 16, "low", 3))
130 i->battery_status = 1;
131 else if (!strncmp (buffer + 16, "crit", 4))
132 i->battery_status = 2;
133 else if (!strncmp (buffer + 16, "charg", 5))
134 i->battery_status = 3;
135
136 if (fgets (buffer, sizeof (buffer) - 1, str) == NULL((void*)0))
137 printf ("fgets error\n");
138
139 if (strncmp (buffer + 14, "unknown", 7))
140 i->battery_percentage = atoi (buffer + 14);
141 if (i->apm_version_major >= 1 && i->apm_version_minor >= 1)
142 {
143 if (fgets (buffer, sizeof (buffer) - 1, str) == NULL((void*)0))
144 printf ("fgets error\n");
145
146 sscanf (buffer, "Battery flag: 0x%02hx", &i->battery_flags);
147
148 if (fgets (buffer, sizeof (buffer) - 1, str) == NULL((void*)0))
149 printf ("fgets error\n");
150
151 if (strncmp (buffer + 14, "unknown", 7))
152 i->battery_time = atoi (buffer + 14);
153 }
154 }
155 }
156#endif
157 }
158
159 /* Fix possible kernel bug -- percentage
160 * set to 0xff (==255) instead of -1.
161 */
162 if (i->battery_percentage > 100)
163 i->battery_percentage = -1;
164
165 fclose (str);
166 return retcode;
167}
168
169/* Lookup the device number for the apm_bios device. */
170dev_t apm_dev (void)
171{
172 FILE *str;
173 static int cached = -1;
174 char buf[80];
175 char *pt;
176 apm_info i;
177
178 if (cached >= 0)
179 return cached;
180
181 if (access (APM_PROC"/proc/apm", R_OK4) || apm_read (&i) == 1)
182 return cached = -1;
183 if (i.driver_version[0] == '1')
184 return cached = makedev (10, 134)gnu_dev_makedev (10, 134);
185
186 if (!(str = fopen (APM_DEV"/proc/devices", "r")))
187 return -1;
188 while (fgets (buf, sizeof (buf) - 1, str))
189 {
190 buf[sizeof (buf) - 1] = '\0';
191 for (pt = buf; *pt && isspace (*pt)((*__ctype_b_loc ())[(int) ((*pt))] & (unsigned short int
) _ISspace)
; ++pt); /* skip leading spaces */
192 for (; *pt && !isspace (*pt)((*__ctype_b_loc ())[(int) ((*pt))] & (unsigned short int
) _ISspace)
; ++pt); /* find next space */
193 if (isspace (*pt)((*__ctype_b_loc ())[(int) ((*pt))] & (unsigned short int
) _ISspace)
)
194 {
195 *pt++ = '\0';
196 pt[strlen (pt) - 1] = '\0'; /* get rid of newline */
197 if (!strcmp (pt, APM_NAME"apm_bios"))
198 {
199 fclose (str);
200 return cached = makedev (atoi (buf), 0)gnu_dev_makedev (atoi (buf), 0);
201 }
202 }
203 }
204 fclose (str);
205 return cached = -1;
206}
207
208/* Return a file descriptor for the apm_bios device, or -1 if there is an
209 * error. Is this method secure? Should we make the device in /dev
210 * instead of /tmp?
211 *
212 * apenwarr 2001/05/11: just throw out the weird temporary device file stuff.
213 * It was only for ancient kernel versions anyway.
214 */
215int
216apm_open (void)
217{
218 int fd;
219 apm_info i;
220
221 if (access (APM_PROC"/proc/apm", R_OK4) || apm_read (&i) == 1)
222 return -1;
223 if (i.driver_version[0] >= '1')
224 {
225 if ((fd = open (APM_DEVICE"/dev/apm_bios", O_RDWR02)) < 0)
226 {
227 /* Try to create it. This is reasonable
228 * for backward compatibility.
229 */
230 if (mknod (APM_DEVICE"/dev/apm_bios", S_IFCHR0020000 | S_IRUSR0400 | S_IWUSR0200, apm_dev ()))
231 {
232 unlink (APM_DEVICE"/dev/apm_bios");
233 return -1;
234 }
235 fd = open (APM_DEVICE"/dev/apm_bios", O_RDWR02);
236 }
237 return fd;
238 }
239 return -1;
240}
241
242/* Given a file descriptor for the apm_bios device, close it. */
243int
244apm_close (int fd)
245{
246 return close (fd);
247}
248
249/* Given a file descriptor for the apm_bios device, this routine will wait
250 * timeout seconds for APM events. Up to n events will be placed in the
251 * events queue. The return code will indicate the number of events
252 * stored. Since this routine uses select (2), it will return if an
253 * unblocked signal is caught. A timeout < 0 means to block indefinately.
254 *
255 * Note that if you read a request to standby or to suspend, the kernel
256 * will be waiting for you to respond to it with a call to apm_suspend ()
257 * or to apm_standby () !
258 */
259int
260apm_get_events (int fd, int timeout, apm_event_t * events, int n)
261{
262 int retcode;
263 fd_set fds;
264 struct timeval t;
265
266 t.tv_sec = timeout;
267 t.tv_usec = 0;
268
269 FD_ZERO (&fds)do { unsigned int __i; fd_set *__arr = (&fds); for (__i =
0; __i < sizeof (fd_set) / sizeof (__fd_mask); ++__i) ((__arr
)->__fds_bits)[__i] = 0; } while (0)
;
270 FD_SET (fd, &fds)((void) (((&fds)->__fds_bits)[((fd) / (8 * (int) sizeof
(__fd_mask)))] |= ((__fd_mask) (1UL << ((fd) % (8 * (int
) sizeof (__fd_mask)))))))
;
271 retcode = select (fd + 1, &fds, NULL((void*)0), NULL((void*)0), timeout < 0 ? NULL((void*)0) : &t);
272 if (retcode <= 0)
273 return 0;
274 return read (fd, events, n * sizeof (apm_event_t)) / sizeof (apm_event_t);
275}
276
277/* Try to set the Power State to Suspend. */
278int
279apm_suspend (int fd)
280{
281 sync ();
282 return ioctl (fd, APM_IOC_SUSPEND(((0U) << (((0 +8)+8)+14)) | ((('A')) << (0 +8)) |
(((2)) << 0) | ((0) << ((0 +8)+8)))
, NULL((void*)0));
283}
284
285/* Try to set the Power State to Standby. */
286int
287apm_standby (int fd)
288{
289 sync ();
290 return ioctl (fd, APM_IOC_STANDBY(((0U) << (((0 +8)+8)+14)) | ((('A')) << (0 +8)) |
(((1)) << 0) | ((0) << ((0 +8)+8)))
, NULL((void*)0));
291}
292
293/* Return the last error code generated by the kernel APM driver */
294unsigned int
295apm_last_error ( int fd )
296{
297 int err = 0;
298
299#ifdef APM_IOC_LAST_ERROR
300 int ierr = 0;
301 if ((ierr = ioctl (fd, APM_IOC_LAST_ERROR, &err)))
302 return ierr;
303#endif
304 return err;
305}
306
307/* Define lookup table for error messages */
308typedef struct lookup_t {
309 int key;
310 char* msg;
311} lookup_t;
312
313/* APM error messages, arranged by error code */
314static const lookup_t error_table[] = {
315/* N/A { APM_SUCCESS, "Operation succeeded" }, */
316 { APM_DISABLED0x01, "Power management disabled" },
317 { APM_CONNECTED0x02, "Real mode interface already connected" },
318 { APM_NOT_CONNECTED0x03, "Interface not connected" },
319 { APM_16_CONNECTED0x05, "16 bit interface already connected" },
320/* N/A { APM_16_UNSUPPORTED, "16 bit interface not supported" }, */
321 { APM_32_CONNECTED0x07, "32 bit interface already connected" },
322 { APM_32_UNSUPPORTED0x08, "32 bit interface not supported" },
323 { APM_BAD_DEVICE0x09, "Unrecognized device ID" },
324 { APM_BAD_PARAM0x0a, "Parameter out of range" },
325 { APM_NOT_ENGAGED0x0b, "Interface not engaged" },
326#ifdef APM_BAD_FUNCTION0x0c
327 { APM_BAD_FUNCTION0x0c, "Function not supported" },
328#endif
329#ifdef APM_RESUME_DISABLED0x0d
330 { APM_RESUME_DISABLED0x0d, "Resume timer disabled" },
331#endif
332 { APM_BAD_STATE0x60, "Unable to enter requested state" },
333/* N/A { APM_NO_EVENTS, "No events pending" }, */
334 { APM_NOT_PRESENT0x86, "No APM present" }
335};
336#define ERROR_COUNT(sizeof(error_table)/sizeof(lookup_t)) (sizeof(error_table)/sizeof(lookup_t))
337
338/* Return character string describing error messages from APM kernel */
339const char *
340apm_error_name (unsigned int err)
341{
342 int i;
343
344 for (i=0; i<ERROR_COUNT(sizeof(error_table)/sizeof(lookup_t)); i++)
345 if (err == error_table[i].key) return (error_table[i].msg);
346
347 return "Unknown error";
348}
349
350int
351apm_reject (int fd)
352{
353#ifdef APM_IOC_REJECT
354 if (ioctl fd, APM_IOC_REJECT, NULL((void*)0) ))
355 return apm_last_error (fd);
356 else
357#endif
358 return 0;
359}
360
361#ifdef APM_IOC_IGNORE /* detect kernel support of IGNORE/NOIGNORE functions */
362int
363apm_set_ignore (int fd, int mode)
364/* Ignore Standby. */
365{
366 if (mode == IGNORE2)
367 {
368 printf ("Telling kernel to ignore system standby/suspend mode\n");
369 return ioctl (fd, APM_IOC_IGNORE, NULL((void*)0));
370 }
371 else
372 {
373 printf ("Telling kernel not to ignore system standby/suspend mode\n");
374 return ioctl (fd, APM_IOC_NOIGNORE, NULL((void*)0));
375 }
376 printf ("NOTE: User-generated suspend/standby requests are not ignored\n");
377}
378#endif
379
380/* Return a string describing the event. From p. 16 of the Intel/Microsoft
381 * Advanded Power Management (APM) BIOS Interface Specification, Revision
382 * 1.1 (September 1993). Intel Order Number: 241704-001. Microsoft Part
383 * Number: 781-110-X01.
384 *
385 * Updated to APM BIOS 1.2 spec (February 1996). Available on-line.
386 */
387const char *
388apm_event_name (apm_event_t event)
389{
390 switch (event)
391 {
392 case APM_SYS_STANDBY0x0001:
393 return "System Standby Request";
394 case APM_SYS_SUSPEND0x0002:
395 return "System Suspend Request";
396 case APM_NORMAL_RESUME0x0003:
397 return "Normal Resume System";
398 case APM_CRITICAL_RESUME0x0004:
399 return "Critical Resume System";
400 case APM_LOW_BATTERY0x0005:
401 return "Battery Low";
402 case APM_POWER_STATUS_CHANGE0x0006:
403 return "Power Status Change";
404 case APM_UPDATE_TIME0x0007:
405 return "Update Time";
406 case APM_CRITICAL_SUSPEND0x0008:
407 return "Critical Suspend";
408 case APM_USER_STANDBY0x0009:
409 return "User System Standby Request";
410 case APM_USER_SUSPEND0x000a:
411 return "User System Suspend Request";
412 case APM_STANDBY_RESUME0x000b:
413 return "System Standby Resume";
414#ifdef APM_CAPABILITY_CHANGE0x000c
415 case APM_CAPABILITY_CHANGE0x000c:
416 return "Capability Change";
417#endif
418 }
419 return "Unknown";
420}
421
422/* This is a convenience function that has nothing to do with APM. It just
423 * formats a time nicely. If you don't like this format, then write your
424 * own.
425 */
426#define SEC_PER_DAY(60*60*24) (60*60*24)
427#define SEC_PER_HOUR(60*60) (60*60)
428#define SEC_PER_MIN(60) (60)
429
430const char *
431apm_delta_time (time_t then, time_t now)
432{
433 return apm_time (now - then);
434}
435
436const char *
437apm_time (time_t t)
438{
439 static char buffer[128];
440 unsigned long s, m, h, d;
441
442 d = t / SEC_PER_DAY(60*60*24);
443 t -= d * SEC_PER_DAY(60*60*24);
444 h = t / SEC_PER_HOUR(60*60);
445 t -= h * SEC_PER_HOUR(60*60);
446 m = t / SEC_PER_MIN(60);
447 t -= m * SEC_PER_MIN(60);
448 s = t;
449
450 if (d)
451 sprintf (buffer, "%lu day%s, %02lu:%02lu:%02lu",
452 d, d > 1 ? "s" : "", h, m, s);
453 else
454 sprintf (buffer, "%02lu:%02lu:%02lu", h, m, s);
455
456 if (t == -1)
457 sprintf (buffer, "unknown");
458
459 return buffer;
460}
461
462const char *
463apm_time_nosec (time_t t)
464{
465 static char buffer[128];
466 unsigned long s, m, h, d;
467
468 d = t / SEC_PER_DAY(60*60*24);
469 t -= d * SEC_PER_DAY(60*60*24);
470 h = t / SEC_PER_HOUR(60*60);
471 t -= h * SEC_PER_HOUR(60*60);
472 m = t / SEC_PER_MIN(60);
473 t -= m * SEC_PER_MIN(60);
474 s = t;
475
476 if (s > 30)
477 ++m;
478
479 if (d)
480 sprintf (buffer, "%lu day%s, %lu:%02lu",
481 d, d > 1 ? "s" : "", h, m);
482 else
483 sprintf (buffer, "%lu:%02lu", h, m);
484
485 if (t == -1)
486 sprintf (buffer, "unknown");
487
488 return buffer;
489}
diff --git a/2023-10-06-143029-14295-1@5e7148e14497_gtk-image-menu-item/report-782963.html b/2023-10-06-143029-14295-1@5e7148e14497_gtk-image-menu-item/report-782963.html new file mode 100644 index 00000000..f929632c --- /dev/null +++ b/2023-10-06-143029-14295-1@5e7148e14497_gtk-image-menu-item/report-782963.html @@ -0,0 +1,1025 @@ + + + +themes.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:geyes/src/themes.c
Warning:line 80, column 13
Value stored to 'token' 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 themes.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=none -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/geyes/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I ../.. -I . -I . -I /usr/include/mate-panel-4.0/libmate-panel-applet -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -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/lib64/dbus-1.0/include -I /usr/local/include -D GEYES_THEMES_DIR="/usr/local/share/mate-applets/geyes/" -D GEYES_RESOURCE_PATH="/org/mate/mate-applets/eyes/" -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-unused-parameter -fdebug-compilation-dir=/rootdir/geyes/src -ferror-limit 19 -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-10-06-143029-14295-1 -x c themes.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * Copyright (C) 1999 Dave Camp <dave@davec.dhs.org>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
17 */
18
19#include <config.h>
20#include <string.h>
21#include <ctype.h>
22#include <gtk/gtk.h>
23#include <gio/gio.h>
24#include "geyes.h"
25
26#define GET_WIDGET(x)(((((GtkWidget*) (void *) ((gtk_builder_get_object (builder, (
x))))))))
(GTK_WIDGET (gtk_builder_get_object (builder, (x)))((((GtkWidget*) (void *) ((gtk_builder_get_object (builder, (
x)))))))
)
27#define NUM_THEME_DIRECTORIES2 2
28
29static char *theme_directories[NUM_THEME_DIRECTORIES2];
30
31enum {
32 COL_THEME_DIR = 0,
33 COL_THEME_NAME,
34 TOTAL_COLS
35};
36
37void
38theme_dirs_create (void)
39{
40 static gboolean themes_created = FALSE(0);
41
42 if (themes_created == TRUE(!(0)))
43 return;
44
45 theme_directories[0] = g_build_filename (GEYES_THEMES_DIR"/usr/local/share/mate-applets/geyes/", NULL((void*)0));
46
47 theme_directories[1] = g_build_filename (g_get_user_config_dir (), "mate",
48 "geyes-themes", NULL((void*)0));
49
50 themes_created = TRUE(!(0));
51}
52
53static void
54parse_theme_file (EyesApplet *eyes_applet,
55 FILE *theme_file)
56{
57 gchar line_buf[512]; /* prolly overkill */
58 gchar *token;
59
60 if (fgets (line_buf, 512, theme_file) == NULL((void*)0))
61 g_debug ("fgets error");
62
63 while (!feof (theme_file)) {
64 token = strtok (line_buf, "=");
65 if (strncmp (token, "wall-thickness", strlen ("wall-thickness")) == 0) {
66 token += strlen ("wall-thickness");
67 while (!isdigit (*token)((*__ctype_b_loc ())[(int) ((*token))] & (unsigned short int
) _ISdigit)
) {
68 token++;
69 }
70 sscanf (token, "%d", &eyes_applet->wall_thickness);
71 } else if (strncmp (token, "num-eyes", strlen ("num-eyes")) == 0) {
72 token += strlen ("num-eyes");
73 while (!isdigit (*token)((*__ctype_b_loc ())[(int) ((*token))] & (unsigned short int
) _ISdigit)
) {
74 token++;
75 }
76 sscanf (token, "%" G_GSIZE_FORMAT"lu", &eyes_applet->num_eyes);
77 if (eyes_applet->num_eyes > MAX_EYES1000)
78 eyes_applet->num_eyes = MAX_EYES1000;
79 } else if (strncmp (token, "eye-pixmap", strlen ("eye-pixmap")) == 0) {
80 token = strtok (NULL((void*)0), "\"");
Value stored to 'token' is never read
81 token = strtok (NULL((void*)0), "\"");
82 if (eyes_applet->eye_filename != NULL((void*)0))
83 g_free (eyes_applet->eye_filename);
84 eyes_applet->eye_filename
85 = g_build_filename (eyes_applet->theme_dir, token, NULL((void*)0));
86 } else if (strncmp (token, "pupil-pixmap", strlen ("pupil-pixmap")) == 0) {
87 token = strtok (NULL((void*)0), "\"");
88 token = strtok (NULL((void*)0), "\"");
89 if (eyes_applet->pupil_filename != NULL((void*)0))
90 g_free (eyes_applet->pupil_filename);
91 eyes_applet->pupil_filename
92 = g_build_filename (eyes_applet->theme_dir, token, NULL((void*)0));
93 }
94 if (fgets (line_buf, 512, theme_file) == NULL((void*)0))
95 g_debug ("fgets error");
96 }
97}
98
99int
100load_theme (EyesApplet *eyes_applet,
101 const gchar *theme_dir)
102{
103 GtkWidget *dialog;
104 FILE *theme_file;
105 gchar *file_name;
106
107 eyes_applet->theme_dir = g_strdup (theme_dir)g_strdup_inline (theme_dir);
108
109 file_name = g_build_filename (theme_dir, "config", NULL((void*)0));
110 if ((theme_file = fopen (file_name, "r")) == NULL((void*)0)) {
111 g_free (eyes_applet->theme_dir);
112 eyes_applet->theme_dir = g_build_filename (GEYES_THEMES_DIR"/usr/local/share/mate-applets/geyes/", "Default-tiny", NULL((void*)0));
113 theme_file = fopen (GEYES_THEMES_DIR"/usr/local/share/mate-applets/geyes/" "Default-tiny/config", "r");
114 }
115 g_free (file_name);
116
117 /* if it's still NULL we've got a major problem */
118 if (theme_file == NULL((void*)0)) {
119 dialog = gtk_message_dialog_new_with_markup (NULL((void*)0),
120 GTK_DIALOG_DESTROY_WITH_PARENT,
121 GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
122 "<b>%s</b>\n\n%s",
123 _("Can not launch the eyes applet.")dcgettext (((void*)0), "Can not launch the eyes applet.", 5),
124 _("There was a fatal error while trying to load the theme.")dcgettext (((void*)0), "There was a fatal error while trying to load the theme."
, 5)
);
125
126 gtk_dialog_run (GTK_DIALOG (dialog)((((GtkDialog*) (void *) ((dialog))))));
127 gtk_widget_destroy (dialog);
128
129 gtk_widget_destroy (GTK_WIDGET (eyes_applet->applet)((((GtkWidget*) (void *) ((eyes_applet->applet))))));
130
131 return FALSE(0);
132 }
133
134 parse_theme_file (eyes_applet, theme_file);
135 fclose (theme_file);
136
137 eyes_applet->theme_name = g_strdup (theme_dir)g_strdup_inline (theme_dir);
138
139 if (eyes_applet->eye_image)
140 g_object_unref (eyes_applet->eye_image);
141
142 eyes_applet->eye_image
143 = gdk_pixbuf_new_from_file (eyes_applet->eye_filename,
144 NULL((void*)0));
145
146 if (eyes_applet->pupil_image)
147 g_object_unref (eyes_applet->pupil_image);
148
149 eyes_applet->pupil_image
150 = gdk_pixbuf_new_from_file (eyes_applet->pupil_filename,
151 NULL((void*)0));
152
153 eyes_applet->eye_height = gdk_pixbuf_get_height (eyes_applet->eye_image);
154 eyes_applet->eye_width = gdk_pixbuf_get_width (eyes_applet->eye_image);
155 eyes_applet->pupil_height = gdk_pixbuf_get_height (eyes_applet->pupil_image);
156 eyes_applet->pupil_width = gdk_pixbuf_get_width (eyes_applet->pupil_image);
157
158 return TRUE(!(0));
159}
160
161static void
162destroy_theme (EyesApplet *eyes_applet)
163{
164 /* Dunno about this - to unref or not to unref? */
165 if (eyes_applet->eye_image != NULL((void*)0)) {
166 g_object_unref (eyes_applet->eye_image);
167 eyes_applet->eye_image = NULL((void*)0);
168 }
169 if (eyes_applet->pupil_image != NULL((void*)0)) {
170 g_object_unref (eyes_applet->pupil_image);
171 eyes_applet->pupil_image = NULL((void*)0);
172 }
173
174 g_free (eyes_applet->theme_dir);
175 g_free (eyes_applet->theme_name);
176}
177
178static void
179theme_selected_cb (GtkTreeSelection *selection,
180 gpointer data)
181{
182 EyesApplet *eyes_applet = data;
183 GtkTreeModel *model;
184 GtkTreeIter iter;
185 gchar *theme;
186
187 if (!gtk_tree_selection_get_selected (selection, &model, &iter))
188 return;
189
190 gtk_tree_model_get (model, &iter, COL_THEME_DIR, &theme, -1);
191
192 g_return_if_fail (theme)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_11
; if (theme) _g_boolean_var_11 = 1; else _g_boolean_var_11 = 0
; _g_boolean_var_11; }), 1))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "theme"); return;
} } while (0)
;
193
194 if (!g_ascii_strncasecmp (theme, eyes_applet->theme_dir,
195 strlen (theme))) {
196 g_free (theme);
197 return;
198 }
199
200 destroy_eyes (eyes_applet);
201 destroy_theme (eyes_applet);
202 load_theme (eyes_applet, theme);
203 setup_eyes (eyes_applet);
204
205 g_settings_set_string (eyes_applet->settings,
206 GEYES_SETTINGS_THEME_PATH_KEY"theme-path",
207 theme);
208
209 g_free (theme);
210}
211
212static void
213phelp_cb (GtkDialog *dialog)
214{
215 GError *error = NULL((void*)0);
216
217 gtk_show_uri_on_window (GTK_WINDOW (dialog)((((GtkWindow*) (void *) ((dialog))))), "help:mate-geyes/geyes-settings",
218 gtk_get_current_event_time (),
219 &error);
220
221 if (error) {
222 GtkWidget *error_dialog
223 = gtk_message_dialog_new (NULL((void*)0), GTK_DIALOG_MODAL,
224 GTK_MESSAGE_ERROR,
225 GTK_BUTTONS_CLOSE,
226 _("There was an error displaying help: %s")dcgettext (((void*)0), "There was an error displaying help: %s"
, 5)
,
227 error->message);
228 g_signal_connect (error_dialog, "response",g_signal_connect_data ((error_dialog), ("response"), (((GCallback
) (gtk_widget_destroy))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
229 G_CALLBACK (gtk_widget_destroy),g_signal_connect_data ((error_dialog), ("response"), (((GCallback
) (gtk_widget_destroy))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
230 NULL)g_signal_connect_data ((error_dialog), ("response"), (((GCallback
) (gtk_widget_destroy))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
231 gtk_window_set_resizable (GTK_WINDOW (error_dialog)((((GtkWindow*) (void *) ((error_dialog))))), FALSE(0));
232 gtk_window_set_screen (GTK_WINDOW (error_dialog)((((GtkWindow*) (void *) ((error_dialog))))),
233 gtk_widget_get_screen (GTK_WIDGET (dialog)((((GtkWidget*) (void *) ((dialog)))))));
234 gtk_widget_show (error_dialog);
235 g_clear_error (&error);
236 }
237}
238
239static void
240presponse_cb (GtkDialog *dialog,
241 gint id,
242 gpointer data)
243{
244 EyesApplet *eyes_applet = data;
245 if (id == GTK_RESPONSE_HELP) {
246 phelp_cb (dialog);
247 return;
248 }
249
250 gtk_widget_destroy (GTK_WIDGET (dialog)((((GtkWidget*) (void *) ((dialog))))));
251
252 eyes_applet->prop_box.pbox = NULL((void*)0);
253}
254
255void
256properties_cb (GtkAction *action,
257 EyesApplet *eyes_applet)
258{
259 GtkBuilder *builder;
260 GtkWidget *tree;
261 GtkWidget *label;
262 GtkListStore *model;
263 GtkTreeViewColumn *column;
264 GtkCellRenderer *cell;
265 GtkTreeIter iter;
266 GDir *dfd;
267 const char *dp;
268 GError *error = NULL((void*)0);
269 int i;
270
271 if (eyes_applet->prop_box.pbox) {
272 gtk_window_set_screen (GTK_WINDOW (eyes_applet->prop_box.pbox)((((GtkWindow*) (void *) ((eyes_applet->prop_box.pbox))))),
273 gtk_widget_get_screen (GTK_WIDGET (eyes_applet->applet)((((GtkWidget*) (void *) ((eyes_applet->applet)))))));
274
275 gtk_window_present (GTK_WINDOW (eyes_applet->prop_box.pbox)((((GtkWindow*) (void *) ((eyes_applet->prop_box.pbox))))));
276 return;
277 }
278
279 builder = gtk_builder_new_from_resource (GEYES_RESOURCE_PATH"/org/mate/mate-applets/eyes/" "themes.ui");
280
281 eyes_applet->prop_box.pbox = GET_WIDGET("preferences_dialog")(((((GtkWidget*) (void *) ((gtk_builder_get_object (builder, (
"preferences_dialog"))))))))
;
282 tree = GET_WIDGET("themes_treeview")(((((GtkWidget*) (void *) ((gtk_builder_get_object (builder, (
"themes_treeview"))))))))
;
283 label = GET_WIDGET("select_theme_label")(((((GtkWidget*) (void *) ((gtk_builder_get_object (builder, (
"select_theme_label"))))))))
;
284
285 model = gtk_list_store_new (TOTAL_COLS, G_TYPE_STRING((GType) ((16) << (2))), G_TYPE_STRING((GType) ((16) << (2))));
286 gtk_tree_view_set_model (GTK_TREE_VIEW (tree)((((GtkTreeView*) (void *) ((tree))))), GTK_TREE_MODEL (model)((((GtkTreeModel*) (void *) ((model))))));
287 cell = gtk_cell_renderer_text_new ();
288 column = gtk_tree_view_column_new_with_attributes ("not used", cell, "text",
289 COL_THEME_NAME,
290 NULL((void*)0));
291 gtk_tree_view_append_column (GTK_TREE_VIEW (tree)((((GtkTreeView*) (void *) ((tree))))), column);
292
293 if (!g_settings_is_writable (eyes_applet->settings, GEYES_SETTINGS_THEME_PATH_KEY"theme-path")) {
294 gtk_widget_set_sensitive (tree, FALSE(0));
295 gtk_widget_set_sensitive (label, FALSE(0));
296 }
297
298 for (i = 0; i < NUM_THEME_DIRECTORIES2; i++) {
299 dfd = g_dir_open (theme_directories[i], 0, &error);
300 if (error) {
301 g_debug ("Could not open the folder: %s", error->message);
302 g_clear_error (&error);
303 continue;
304 }
305 while ((dp = g_dir_read_name (dfd)) != NULL((void*)0)) {
306 if (dp[0] != '.') {
307 gchar *theme_dir;
308
309 theme_dir = g_build_filename (theme_directories[i], dp, NULL((void*)0));
310 gtk_list_store_append (model, &iter);
311 gtk_list_store_set (model, &iter,
312 COL_THEME_DIR, theme_dir,
313 COL_THEME_NAME, dp,
314 -1);
315
316 if (!g_ascii_strncasecmp (eyes_applet->theme_dir, theme_dir,
317 strlen (theme_dir))) {
318 GtkTreePath *path;
319
320 path = gtk_tree_model_get_path (GTK_TREE_MODEL (model)((((GtkTreeModel*) (void *) ((model))))), &iter);
321 gtk_tree_view_set_cursor (GTK_TREE_VIEW (tree)((((GtkTreeView*) (void *) ((tree))))),
322 path, NULL((void*)0), FALSE(0));
323 gtk_tree_path_free (path);
324 }
325 g_free (theme_dir);
326 }
327 }
328 g_dir_close (dfd);
329 }
330 g_object_unref (model);
331
332 /* signals */
333 gtk_builder_add_callback_symbols (builder, "on_preferences_dialog_response",
334 G_CALLBACK (presponse_cb)((GCallback) (presponse_cb)),
335 "on_themes_treeselection_changed",
336 G_CALLBACK (theme_selected_cb)((GCallback) (theme_selected_cb)),
337 NULL((void*)0));
338 gtk_builder_connect_signals (builder, eyes_applet);
339
340 g_object_unref (builder);
341
342 gtk_widget_show_all (eyes_applet->prop_box.pbox);
343
344 return;
345}
diff --git a/2023-10-06-143029-14295-1@5e7148e14497_gtk-image-menu-item/report-8b7574.html b/2023-10-06-143029-14295-1@5e7148e14497_gtk-image-menu-item/report-8b7574.html new file mode 100644 index 00000000..cdd18627 --- /dev/null +++ b/2023-10-06-143029-14295-1@5e7148e14497_gtk-image-menu-item/report-8b7574.html @@ -0,0 +1,2531 @@ + + + +netspeed.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:netspeed/src/netspeed.c
Warning:line 671, column 9
Out of bound memory access (access exceeds upper limit of memory block)
+ +

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 netspeed.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=none -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/netspeed/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I ../.. -I ../.. -I /usr/local/include -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gio-unix-2.0 -I /usr/include/libgtop-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/mate-panel-4.0/libmate-panel-applet -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -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/lib64/dbus-1.0/include -D NETSPEED_RESOURCE_PATH="/org/mate/mate-applets/netspeed/" -I /usr/include/libnl3 -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-unused-parameter -fdebug-compilation-dir=/rootdir/netspeed/src -ferror-limit 19 -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-10-06-143029-14295-1 -x c netspeed.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1 /* netspeed.c
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Library General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
16 *
17 * Netspeed Applet was writen by Jörgen Scheibengruber <mfcn@gmx.de>
18 *
19 * MATE Netspeed Applet migrated by Stefano Karapetsas <stefano@karapetsas.com>
20 */
21
22#ifdef HAVE_CONFIG_H1
23#include "config.h"
24#endif
25
26#include <math.h>
27#include <gtk/gtk.h>
28#include <mate-panel-applet.h>
29#include <mate-panel-applet-gsettings.h>
30#include <glib.h>
31#include <glib/gi18n.h>
32#include <gio/gio.h>
33
34#include "backend.h"
35#include "netspeed-preferences.h"
36
37#include "netspeed.h"
38
39#define GET_COLOR_CHOOSER(x)(((((GtkColorChooser*) (void *) ((gtk_builder_get_object (builder
, (x))))))))
(GTK_COLOR_CHOOSER (gtk_builder_get_object (builder, (x)))((((GtkColorChooser*) (void *) ((gtk_builder_get_object (builder
, (x)))))))
)
40#define GET_DRAWING_AREA(x)(((((GtkDrawingArea*) (void *) ((gtk_builder_get_object (builder
, (x))))))))
(GTK_DRAWING_AREA (gtk_builder_get_object (builder, (x)))((((GtkDrawingArea*) (void *) ((gtk_builder_get_object (builder
, (x)))))))
)
41#define GET_WIDGET(x)(((((GtkWidget*) (void *) ((gtk_builder_get_object (builder, (
x))))))))
(GTK_WIDGET (gtk_builder_get_object (builder, (x)))((((GtkWidget*) (void *) ((gtk_builder_get_object (builder, (
x)))))))
)
42
43 /* Icons for the interfaces */
44static const char* const dev_type_icon [DEV_UNKNOWN + 1] = {
45 /* FIXME: Need an actual loopback icon... */
46 "reload", /* DEV_LO */
47 "network-wired", /* DEV_ETHERNET */
48 "network-wireless", /* DEV_WIRELESS */
49 "modem", /* DEV_PPP */
50 "mate-netspeed-plip", /* DEV_PLIP */
51 "mate-netspeed-plip", /* DEV_SLIP */
52 "network-workgroup", /* DEV_UNKNOWN */
53};
54
55static const char* wireless_quality_icon [] = {
56 "mate-netspeed-wireless-25",
57 "mate-netspeed-wireless-50",
58 "mate-netspeed-wireless-75",
59 "mate-netspeed-wireless-100"
60};
61
62static const char IN_ICON[] = "go-down";
63static const char OUT_ICON[] = "go-up";
64static const char ERROR_ICON[] = "gtk-dialog-error";
65static const char LOGO_ICON[] = "mate-netspeed-applet";
66
67/* How many old in out values do we store?
68 * The value actually shown in the applet is the average
69 * of these values -> prevents the value from
70 * "jumping around like crazy"
71 */
72#define OLD_VALUES5 5
73#define OLD_VALUES_DBL5.0 5.0
74#define GRAPH_VALUES180 180
75#define GRAPH_LINES4 4
76#define REFRESH_TIME1000 1000
77
78/* A struct containing all the "global" data of the
79 * applet
80 */
81struct _NetspeedApplet
82{
83 MatePanelApplet parent;
84
85 GtkWidget *box;
86 GtkWidget *pix_box;
87 GtkWidget *speed_box;
88 GtkWidget *in_box;
89 GtkWidget *in_label;
90 GtkWidget *in_pix;
91 GtkWidget *out_box;
92 GtkWidget *out_label;
93 GtkWidget *out_pix;
94 GtkWidget *sum_box;
95 GtkWidget *sum_label;
96 GtkWidget *dev_pix;
97 GtkWidget *qual_pix;
98 cairo_surface_t *qual_surfaces[4];
99 gboolean labels_dont_shrink;
100 DevInfo *devinfo;
101 gboolean device_has_changed;
102 guint timeout_id;
103 char *up_cmd;
104 char *down_cmd;
105 gboolean show_all_addresses;
106 gboolean show_sum;
107 gboolean show_bits;
108 gboolean change_icon;
109 gboolean auto_change_device;
110 gboolean show_icon;
111 gboolean show_quality_icon;
112 GdkRGBA in_color;
113 GdkRGBA out_color;
114 int width;
115 /* details dialog */
116 GtkWidget *details;
117 GtkDrawingArea *drawingarea;
118 GtkWidget *ip_text;
119 GtkWidget *netmask_text;
120 GtkWidget *ptpip_text;
121 GtkWidget *ipv6_text;
122 GtkWidget *hwaddr_text;
123 GtkWidget *inbytes_text;
124 GtkWidget *outbytes_text;
125 GtkWidget *essid_text;
126 GtkWidget *signalbar;
127#ifdef HAVE_NL1
128 GtkWidget *station_text;
129 GtkWidget *channel_text;
130 GtkWidget *connected_time_text;
131#endif
132 GtkWidget *ipv6_box;
133 GtkWidget *netlink_box;
134 GtkWidget *wireless_box;
135 /* settings dialog */
136 GtkWidget *preferences;
137
138 guint index_old;
139 guint64 in_old [OLD_VALUES5];
140 guint64 out_old [OLD_VALUES5];
141 double max_graph;
142 double in_graph [GRAPH_VALUES180];
143 double out_graph [GRAPH_VALUES180];
144 int index_graph;
145 GtkWidget *connect_dialog;
146 gboolean show_tooltip;
147 GtkIconTheme *icon_theme;
148 GSettings *settings;
149};
150
151G_DEFINE_TYPE (NetspeedApplet, netspeed_applet, PANEL_TYPE_APPLET)static void netspeed_applet_init (NetspeedApplet *self); static
void netspeed_applet_class_init (NetspeedAppletClass *klass)
; static GType netspeed_applet_get_type_once (void); static gpointer
netspeed_applet_parent_class = ((void*)0); static gint NetspeedApplet_private_offset
; static void netspeed_applet_class_intern_init (gpointer klass
) { netspeed_applet_parent_class = g_type_class_peek_parent (
klass); if (NetspeedApplet_private_offset != 0) g_type_class_adjust_private_offset
(klass, &NetspeedApplet_private_offset); netspeed_applet_class_init
((NetspeedAppletClass*) klass); } __attribute__ ((__unused__
)) static inline gpointer netspeed_applet_get_instance_private
(NetspeedApplet *self) { return (((gpointer) ((guint8*) (self
) + (glong) (NetspeedApplet_private_offset)))); } GType netspeed_applet_get_type
(void) { static gsize 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 (&static_g_define_type_id
)); }))) { GType g_define_type_id = netspeed_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 ((&static_g_define_type_id
), (gsize) (g_define_type_id)); })); } return static_g_define_type_id
; } __attribute__ ((__noinline__)) static GType netspeed_applet_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
(mate_panel_applet_get_type (), g_intern_static_string ("NetspeedApplet"
), sizeof (NetspeedAppletClass), (GClassInitFunc)(void (*)(void
)) netspeed_applet_class_intern_init, sizeof (NetspeedApplet)
, (GInstanceInitFunc)(void (*)(void)) netspeed_applet_init, (
GTypeFlags) 0); { {{};} } return g_define_type_id; }
152
153static void
154update_tooltip (NetspeedApplet *netspeed);
155
156GSettings *
157netspeed_applet_get_settings (NetspeedApplet *netspeed)
158{
159 return netspeed->settings;
160}
161
162const gchar *
163netspeed_applet_get_current_device_name (NetspeedApplet *netspeed)
164{
165 return netspeed->devinfo->name;
166}
167
168/* Adds a Pango markup "foreground" to a bytestring
169 */
170static void
171add_markup_fgcolor (char **string,
172 const char *color)
173{
174 char *tmp = *string;
175
176 *string = g_strdup_printf ("<span foreground=\"%s\">%s</span>", color, tmp);
177 g_free (tmp);
178}
179
180/* Change the icons according to the selected device
181 */
182static void
183change_icons (NetspeedApplet *netspeed)
184{
185 cairo_surface_t *dev, *down;
186 cairo_surface_t *in_arrow, *out_arrow;
187 gint icon_scale;
188 gint icon_size = mate_panel_applet_get_size (MATE_PANEL_APPLET (netspeed)) - 8;
189
190 /* FIXME: Not all network icons include a high enough resolution, so to make them all
191 * consistent, we cap them at 48px.*/
192 icon_size = CLAMP (icon_size, 16, 48)(((icon_size) > (48)) ? (48) : (((icon_size) < (16)) ? (
16) : (icon_size)))
;
193
194 icon_scale = gtk_widget_get_scale_factor (GTK_WIDGET (netspeed)((((GtkWidget*) (void *) ((netspeed))))));
195
196 /* If the user wants a different icon than current, we load it */
197 if (netspeed->show_icon && netspeed->change_icon && netspeed->devinfo) {
198 dev = gtk_icon_theme_load_surface (netspeed->icon_theme,
199 dev_type_icon [netspeed->devinfo->type],
200 icon_size, icon_scale, NULL((void*)0), 0, NULL((void*)0));
201 } else {
202 dev = gtk_icon_theme_load_surface (netspeed->icon_theme,
203 dev_type_icon [DEV_UNKNOWN],
204 icon_size, icon_scale, NULL((void*)0), 0, NULL((void*)0));
205 }
206
207 /* We need a fallback */
208 if (dev == NULL((void*)0))
209 dev = gtk_icon_theme_load_surface (netspeed->icon_theme,
210 dev_type_icon [DEV_UNKNOWN],
211 icon_size, icon_scale, NULL((void*)0), 0, NULL((void*)0));
212
213 in_arrow = gtk_icon_theme_load_surface (netspeed->icon_theme,
214 IN_ICON,
215 16, icon_scale, NULL((void*)0), 0, NULL((void*)0));
216
217 out_arrow = gtk_icon_theme_load_surface (netspeed->icon_theme,
218 OUT_ICON,
219 16, icon_scale, NULL((void*)0), 0, NULL((void*)0));
220
221 /* Set the windowmanager icon for the applet */
222 gtk_window_set_default_icon_name (LOGO_ICON);
223
224 gtk_image_set_from_surface (GTK_IMAGE (netspeed->out_pix)((((GtkImage*) (void *) ((netspeed->out_pix))))), out_arrow);
225 gtk_image_set_from_surface (GTK_IMAGE (netspeed->in_pix)((((GtkImage*) (void *) ((netspeed->in_pix))))), in_arrow);
226 cairo_surface_destroy (in_arrow);
227 cairo_surface_destroy (out_arrow);
228
229 if (netspeed->devinfo && netspeed->devinfo->running) {
230 gtk_widget_show (netspeed->in_box);
231 gtk_widget_show (netspeed->out_box);
232 } else {
233 cairo_t *cr;
234 cairo_surface_t *copy;
235 gint down_coords;
236
237 gtk_widget_hide (netspeed->in_box);
238 gtk_widget_hide (netspeed->out_box);
239
240 /* We're not allowed to modify "dev" */
241 copy = cairo_surface_create_similar (dev,
242 cairo_surface_get_content (dev),
243 cairo_image_surface_get_width (dev) / icon_scale,
244 cairo_image_surface_get_height (dev) / icon_scale);
245 cr = cairo_create (copy);
246 cairo_set_source_surface (cr, dev, 0, 0);
247 cairo_paint (cr);
248
249 down = gtk_icon_theme_load_surface (netspeed->icon_theme,
250 ERROR_ICON,
251 icon_size, icon_scale, NULL((void*)0), 0, NULL((void*)0));
252
253 down_coords = cairo_image_surface_get_width (copy) / icon_scale;
254 cairo_scale (cr, 0.5, 0.5);
255 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
256 cairo_set_source_surface (cr, down, down_coords, down_coords);
257 cairo_paint (cr);
258
259 cairo_surface_destroy (down);
260 cairo_surface_destroy (dev);
261 dev = copy;
262 }
263
264 if (netspeed->show_icon) {
265 gtk_widget_show (netspeed->dev_pix);
266 gtk_image_set_from_surface (GTK_IMAGE (netspeed->dev_pix)((((GtkImage*) (void *) ((netspeed->dev_pix))))), dev);
267 } else {
268 gtk_widget_hide (netspeed->dev_pix);
269 }
270
271 cairo_surface_destroy (dev);
272}
273
274/* Here some rearangement of the icons and the labels occurs
275 * according to the panelsize and wether we show in and out
276 * or just the sum
277 */
278static void
279applet_change_size_or_orient (MatePanelApplet *applet,
280 int arg1,
281 NetspeedApplet *netspeed)
282{
283 int size;
284 MatePanelAppletOrient orient;
285
286 g_assert (netspeed)do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_15
; if (netspeed) _g_boolean_var_15 = 1; else _g_boolean_var_15
= 0; _g_boolean_var_15; }), 1)) ; else g_assertion_message_expr
(((gchar*) 0), "netspeed.c", 286, ((const char*) (__func__))
, "netspeed"); } while (0)
;
287
288 size = mate_panel_applet_get_size (applet);
289 orient = mate_panel_applet_get_orient (applet);
290
291 g_object_ref (netspeed->pix_box)((__typeof__ (netspeed->pix_box)) (g_object_ref) (netspeed
->pix_box))
;
292 g_object_ref (netspeed->in_pix)((__typeof__ (netspeed->in_pix)) (g_object_ref) (netspeed->
in_pix))
;
293 g_object_ref (netspeed->in_label)((__typeof__ (netspeed->in_label)) (g_object_ref) (netspeed
->in_label))
;
294 g_object_ref (netspeed->out_pix)((__typeof__ (netspeed->out_pix)) (g_object_ref) (netspeed
->out_pix))
;
295 g_object_ref (netspeed->out_label)((__typeof__ (netspeed->out_label)) (g_object_ref) (netspeed
->out_label))
;
296 g_object_ref (netspeed->sum_label)((__typeof__ (netspeed->sum_label)) (g_object_ref) (netspeed
->sum_label))
;
297
298 if (netspeed->in_box) {
299 gtk_container_remove (GTK_CONTAINER (netspeed->in_box)((((GtkContainer*) (void *) ((netspeed->in_box))))), netspeed->in_label);
300 gtk_container_remove (GTK_CONTAINER (netspeed->in_box)((((GtkContainer*) (void *) ((netspeed->in_box))))), netspeed->in_pix);
301 gtk_widget_destroy (netspeed->in_box);
302 }
303 if (netspeed->out_box) {
304 gtk_container_remove (GTK_CONTAINER (netspeed->out_box)((((GtkContainer*) (void *) ((netspeed->out_box))))), netspeed->out_label);
305 gtk_container_remove (GTK_CONTAINER (netspeed->out_box)((((GtkContainer*) (void *) ((netspeed->out_box))))), netspeed->out_pix);
306 gtk_widget_destroy (netspeed->out_box);
307 }
308 if (netspeed->sum_box) {
309 gtk_container_remove (GTK_CONTAINER (netspeed->sum_box)((((GtkContainer*) (void *) ((netspeed->sum_box))))), netspeed->sum_label);
310 gtk_widget_destroy (netspeed->sum_box);
311 }
312 if (netspeed->box) {
313 gtk_container_remove (GTK_CONTAINER (netspeed->box)((((GtkContainer*) (void *) ((netspeed->box))))), netspeed->pix_box);
314 gtk_widget_destroy (netspeed->box);
315 }
316
317 if (orient == MATE_PANEL_APPLET_ORIENT_LEFT || orient == MATE_PANEL_APPLET_ORIENT_RIGHT) {
318 netspeed->box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
319 netspeed->speed_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
320 if (size > 64) {
321 netspeed->sum_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
322 netspeed->in_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 1);
323 netspeed->out_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 1);
324 } else {
325 netspeed->sum_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
326 netspeed->in_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
327 netspeed->out_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
328 }
329 netspeed->labels_dont_shrink = FALSE(0);
330 } else {
331 netspeed->in_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 1);
332 netspeed->out_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 1);
333 netspeed->box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 1);
334 netspeed->sum_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
335 if (size < 48) {
336 netspeed->speed_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 1);
337 netspeed->labels_dont_shrink = TRUE(!(0));
338 } else {
339 netspeed->speed_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
340 netspeed->labels_dont_shrink = !netspeed->show_sum;
341 }
342 }
343
344 gtk_box_pack_start (GTK_BOX (netspeed->in_box)((((GtkBox*) (void *) ((netspeed->in_box))))), netspeed->in_pix, FALSE(0), FALSE(0), 0);
345 gtk_box_pack_start (GTK_BOX (netspeed->in_box)((((GtkBox*) (void *) ((netspeed->in_box))))), netspeed->in_label, TRUE(!(0)), TRUE(!(0)), 0);
346 gtk_box_pack_start (GTK_BOX (netspeed->out_box)((((GtkBox*) (void *) ((netspeed->out_box))))), netspeed->out_pix, FALSE(0), FALSE(0), 0);
347 gtk_box_pack_start (GTK_BOX (netspeed->out_box)((((GtkBox*) (void *) ((netspeed->out_box))))), netspeed->out_label, TRUE(!(0)), TRUE(!(0)), 0);
348 gtk_box_pack_start (GTK_BOX (netspeed->sum_box)((((GtkBox*) (void *) ((netspeed->sum_box))))), netspeed->sum_label, TRUE(!(0)), TRUE(!(0)), 0);
349 gtk_box_pack_start (GTK_BOX (netspeed->box)((((GtkBox*) (void *) ((netspeed->box))))), netspeed->pix_box, FALSE(0), FALSE(0), 0);
350
351 g_object_unref (netspeed->pix_box);
352 g_object_unref (netspeed->in_pix);
353 g_object_unref (netspeed->in_label);
354 g_object_unref (netspeed->out_pix);
355 g_object_unref (netspeed->out_label);
356 g_object_unref (netspeed->sum_label);
357
358 if (netspeed->show_sum) {
359 gtk_box_pack_start (GTK_BOX (netspeed->speed_box)((((GtkBox*) (void *) ((netspeed->speed_box))))), netspeed->sum_box, TRUE(!(0)), TRUE(!(0)), 0);
360 } else {
361 gtk_box_pack_start (GTK_BOX (netspeed->speed_box)((((GtkBox*) (void *) ((netspeed->speed_box))))), netspeed->in_box, TRUE(!(0)), TRUE(!(0)), 0);
362 gtk_box_pack_start (GTK_BOX (netspeed->speed_box)((((GtkBox*) (void *) ((netspeed->speed_box))))), netspeed->out_box, TRUE(!(0)), TRUE(!(0)), 0);
363 }
364 gtk_box_pack_start (GTK_BOX (netspeed->box)((((GtkBox*) (void *) ((netspeed->box))))), netspeed->speed_box, TRUE(!(0)), TRUE(!(0)), 0);
365
366 gtk_widget_show_all (netspeed->box);
367 if (!netspeed->show_icon) {
368 gtk_widget_hide (netspeed->dev_pix);
369 }
370 gtk_container_add (GTK_CONTAINER (netspeed)((((GtkContainer*) (void *) ((netspeed))))), netspeed->box);
371
372 change_icons (netspeed);
373}
374
375/* Change visibility of signal quality icon for wireless devices
376 */
377static void
378change_quality_icon (NetspeedApplet *netspeed)
379{
380 if (netspeed->devinfo->type == DEV_WIRELESS &&
381 netspeed->devinfo->up && netspeed->show_quality_icon) {
382 gtk_widget_show (netspeed->qual_pix);
383 } else {
384 gtk_widget_hide (netspeed->qual_pix);
385 }
386}
387
388static void
389update_quality_icon (NetspeedApplet *netspeed)
390{
391 if (!netspeed->show_quality_icon) {
392 return;
393 }
394
395 unsigned int q;
396
397 q = (netspeed->devinfo->qual);
398 q /= 25;
399 q = MIN (q, 3)(((q) < (3)) ? (q) : (3)); /* q out of range would crash when accessing qual_surfaces[q] */
400 gtk_image_set_from_surface (GTK_IMAGE (netspeed->qual_pix)((((GtkImage*) (void *) ((netspeed->qual_pix))))), netspeed->qual_surfaces[q]);
401}
402
403static void
404init_quality_surfaces (NetspeedApplet *netspeed)
405{
406 int i;
407 cairo_surface_t *surface;
408 gint icon_scale;
409
410 /* FIXME: Add larger icon files. */
411 gint icon_size = 24;
412
413 icon_scale = gtk_widget_get_scale_factor (GTK_WIDGET (netspeed)((((GtkWidget*) (void *) ((netspeed))))));
414
415 for (i = 0; i < 4; i++) {
416 if (netspeed->qual_surfaces[i])
417 cairo_surface_destroy (netspeed->qual_surfaces[i]);
418
419 surface = gtk_icon_theme_load_surface (netspeed->icon_theme,
420 wireless_quality_icon[i],
421 icon_size, icon_scale, NULL((void*)0), 0, NULL((void*)0));
422
423 if (surface) {
424 cairo_t *cr;
425
426 netspeed->qual_surfaces[i] = cairo_surface_create_similar (surface,
427 cairo_surface_get_content (surface),
428 cairo_image_surface_get_width (surface) / icon_scale,
429 cairo_image_surface_get_height (surface) / icon_scale);
430
431 cr = cairo_create (netspeed->qual_surfaces[i]);
432 cairo_set_source_surface (cr, surface, 0, 0);
433 cairo_paint (cr);
434 cairo_surface_destroy (surface);
435 }
436 else {
437 netspeed->qual_surfaces[i] = NULL((void*)0);
438 }
439 }
440}
441
442static void
443icon_theme_changed_cb (GtkIconTheme *icon_theme,
444 NetspeedApplet *netspeed)
445{
446 init_quality_surfaces (netspeed);
447 if (netspeed->devinfo->type == DEV_WIRELESS && netspeed->devinfo->up)
448 update_quality_icon (netspeed);
449 change_icons (netspeed);
450}
451
452#define IEC_KIBI_DBL1024.0 1024.0
453#define IEC_MEBI_DBL1024.0*1024.0 1024.0*1024.0
454#define IEC_GIBI_DBL1024.0*1024.0*1024.0 1024.0*1024.0*1024.0
455
456static void
457format_transfer_rate (gchar *out,
458 double bytes,
459 gboolean bits)
460{
461 const char *format;
462 const char *unit;
463
464 if (bits)
465 bytes *= 8.0;
466
467 if (bytes < IEC_KIBI_DBL1024.0) {
468 format = "%.0f %s";
469 unit = bits ? /* translators: bits (short) */ N_("bit/s")("bit/s"): /* translators: Bytes (short) */ N_("B/s")("B/s");
470 } else if (bytes < IEC_MEBI_DBL1024.0*1024.0) {
471 format = (bytes < (100.0 * IEC_KIBI_DBL1024.0)) ? "%.1f %s" : "%.0f %s";
472 bytes /= IEC_KIBI_DBL1024.0;
473 unit = bits ? /* translators: kibibits (short) */ N_("Kibit/s")("Kibit/s") : /* translators: Kibibytes (short) */ N_("KiB/s")("KiB/s");
474 } else if (bytes < IEC_GIBI_DBL1024.0*1024.0*1024.0) {
475 format = "%.1f %s";
476 bytes /= IEC_MEBI_DBL1024.0*1024.0;
477 unit = bits ? /* translators: Mebibit (short) */ N_("Mibit/s")("Mibit/s") : /* translators: Mebibyte (short) */ N_("MiB/s")("MiB/s");
478 } else {
479 format = "%.1f %s";
480 bytes /= IEC_GIBI_DBL1024.0*1024.0*1024.0;
481 unit = bits ? /* translators: Gibibit (short) */ N_("Gibit/s")("Gibit/s") : /* translators: Gibibyte (short) */ N_("GiB/s")("GiB/s");
482 }
483
484 g_snprintf (out, MAX_FORMAT_SIZE15, format, bytes, gettext (unit)dcgettext (((void*)0), unit, 5));
485}
486
487/* Converts a number of bytes into a human
488 * readable string - in [M/k]bytes[/s]
489 * The string has to be freed
490 */
491static char*
492bps_to_string (double bytes,
493 gboolean bits)
494{
495 char res[MAX_FORMAT_SIZE15];
496 format_transfer_rate (res, bytes, bits);
497 return g_strdup (res)g_strdup_inline (res);
498}
499
500/* Redraws the graph drawingarea
501 * Some really black magic is going on in here ;-)
502 */
503static void
504redraw_graph (NetspeedApplet *netspeed,
505 cairo_t *cr)
506{
507 GtkWidget *da = GTK_WIDGET (netspeed->drawingarea)((((GtkWidget*) (void *) ((netspeed->drawingarea)))));
508 GtkStyleContext *stylecontext = gtk_widget_get_style_context (da);
509 GdkWindow *real_window = gtk_widget_get_window (da);
510 GdkPoint in_points[GRAPH_VALUES180], out_points[GRAPH_VALUES180];
511 PangoLayout *layout;
512 PangoRectangle logical_rect;
513 char *text;
514 int i, offset, w, h;
515 double max_val;
516 double dash[2] = { 1.0, 2.0 };
517
518 w = gdk_window_get_width (real_window);
519 h = gdk_window_get_height (real_window);
520
521 /* the graph hight should be: hight/2 <= netspeed->max_graph < hight */
522 for (max_val = 1; max_val < netspeed->max_graph; max_val *= 2) ;
523
524 /* calculate the polygons (GdkPoint[]) for the graphs */
525 offset = 0;
526 for (i = (netspeed->index_graph + 1) % GRAPH_VALUES180; netspeed->in_graph[i] < 0; i = (i + 1) % GRAPH_VALUES180)
527 offset++;
528 for (i = offset + 1; i < GRAPH_VALUES180; i++)
529 {
530 int index = (netspeed->index_graph + i) % GRAPH_VALUES180;
531 out_points[i].x = in_points[i].x = ((w - 6) * i) / GRAPH_VALUES180 + 4;
532 in_points[i].y = h - 6 - (int)((h - 8) * netspeed->in_graph[index] / max_val);
533 out_points[i].y = h - 6 - (int)((h - 8) * netspeed->out_graph[index] / max_val);
534 }
535 in_points[offset].x = out_points[offset].x = ((w - 6) * offset) / GRAPH_VALUES180 + 4;
536 in_points[offset].y = in_points[(offset + 1) % GRAPH_VALUES180].y;
537 out_points[offset].y = out_points[(offset + 1) % GRAPH_VALUES180].y;
538
539 /* draw the background */
540 cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
541 cairo_rectangle (cr, 02, 2, w - 6, h - 6);
542 cairo_fill (cr);
543
544 cairo_set_line_width (cr, 1.0);
545 cairo_set_dash (cr, dash, 2, 0);
546
547 cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
548 cairo_rectangle (cr, 2, 2, w - 6, h - 6);
549 cairo_stroke (cr);
550
551 for (i = 0; i < GRAPH_LINES4; i++) {
552 int y = 2 + ((h - 6) * i) / GRAPH_LINES4;
553 cairo_move_to (cr, 2, y);
554 cairo_line_to (cr, w - 4, y);
555 }
556 cairo_stroke (cr);
557
558 /* draw the polygons */
559 cairo_set_dash (cr, dash, 0, 1);
560 cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
561 cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
562
563 gdk_cairo_set_source_rgba (cr, &netspeed->in_color);
564 for (i = offset; i < GRAPH_VALUES180; i++) {
565 cairo_line_to (cr, in_points[i].x, in_points[i].y);
566 }
567 cairo_stroke (cr);
568
569 gdk_cairo_set_source_rgba (cr, &netspeed->out_color);
570 for (i = offset; i < GRAPH_VALUES180; i++) {
571 cairo_line_to (cr, out_points[i].x, out_points[i].y);
572 }
573 cairo_stroke (cr);
574
575 text = bps_to_string (max_val, netspeed->show_bits);
576 add_markup_fgcolor (&text, "black");
577 layout = gtk_widget_create_pango_layout (da, NULL((void*)0));
578 pango_layout_set_markup (layout, text, -1);
579 g_free (text);
580 gtk_render_layout (stylecontext, cr, 3, 2, layout);
581 g_object_unref (G_OBJECT (layout)((((GObject*) (void *) ((layout))))));
582
583 text = bps_to_string (0.0, netspeed->show_bits);
584 add_markup_fgcolor (&text, "black");
585 layout = gtk_widget_create_pango_layout (da, NULL((void*)0));
586 pango_layout_set_markup (layout, text, -1);
587 pango_layout_get_pixel_extents (layout, NULL((void*)0), &logical_rect);
588 g_free (text);
589 gtk_render_layout (stylecontext, cr, 3, h - 4 - logical_rect.height, layout);
590 g_object_unref (G_OBJECT (layout)((((GObject*) (void *) ((layout))))));
591}
592
593static gboolean
594set_applet_devinfo (NetspeedApplet *netspeed,
595 const char *iface)
596{
597 DevInfo *info;
598
599 get_device_info (iface, &info);
600
601 if (info->running) {
602 free_device_info (netspeed->devinfo);
603 netspeed->devinfo = info;
604 netspeed->device_has_changed = TRUE(!(0));
605 return TRUE(!(0));
606 }
607
608 free_device_info (info);
609 return FALSE(0);
610}
611
612/* Find the first available device, that is running and != lo */
613static void
614search_for_up_if (NetspeedApplet *netspeed)
615{
616 const gchar *default_route;
617 GList *devices, *tmp;
618
619 default_route = get_default_route ();
620
621 if (default_route != NULL((void*)0)) {
622 if (set_applet_devinfo (netspeed, default_route))
623 return;
624 }
625
626 devices = get_available_devices ();
627 for (tmp = devices; tmp; tmp = g_list_next (tmp)((tmp) ? (((GList *)(tmp))->next) : ((void*)0))) {
628 if (is_dummy_device (tmp->data))
629 continue;
630 if (set_applet_devinfo (netspeed, tmp->data))
631 break;
632 }
633 g_list_free_full (devices, g_free);
634}
635
636static char *
637format_time (guint32 sec)
638{
639 char *res;
640 char *m, *s;
641 int seconds;
642 int minutes;
643 int hours;
644
645 if (sec < 60)
646 return g_strdup_printf (ngettext ("%'" G_GUINT32_FORMAT " second","%'" G_GUINT32_FORMAT " seconds", sec)dcngettext (((void*)0), "%'" "u" " second", "%'" "u" " seconds"
, sec, 5)
, sec);
647
648 hours = (sec/3600);
649 minutes = (sec -(3600*hours))/60;
650 seconds = (sec -(3600*hours)-(minutes*60));
651
652 m = g_strdup_printf (ngettext ("%'d minute", "%'d minutes", minutes)dcngettext (((void*)0), "%'d minute", "%'d minutes", minutes,
5)
, minutes);
653 s = g_strdup_printf (ngettext ("%'d secon", "%'d seconds", seconds)dcngettext (((void*)0), "%'d secon", "%'d seconds", seconds, 5
)
, seconds);
654 if (sec < 60*60) {
655 res = g_strconcat (m, ", ", s, NULL((void*)0));
656 } else {
657 char *h;
658 h = g_strdup_printf (ngettext ("%'d hour", "%'d hours", hours)dcngettext (((void*)0), "%'d hour", "%'d hours", hours, 5), hours);
659 res = g_strconcat (h, ", ", m, ", ", s, NULL((void*)0));
660 g_free (h);
661 }
662 g_free (m);
663 g_free (s);
664
665 return res;
666}
667
668static char *
669mac_addr_n2a (const unsigned char *hw)
670{
671 if (hw[6] || hw[7]) {
25
Out of bound memory access (access exceeds upper limit of memory block)
672 return g_strdup_printf ("%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
673 hw[0], hw[1], hw[2], hw[3],
674 hw[4], hw[5], hw[6], hw[7]);
675 } else {
676 return g_strdup_printf ("%02x:%02x:%02x:%02x:%02x:%02x",
677 hw[0], hw[1], hw[2],
678 hw[3], hw[4], hw[5]);
679 }
680}
681
682static void
683format_ipv4 (guint32 ip,
684 char *dest)
685{
686 inet_ntop (AF_INET2, &ip, dest, INET_ADDRSTRLEN16);
687}
688
689static void
690fill_details_dialog (NetspeedApplet *netspeed)
691{
692 char *text;
693 char ipv4_text [INET_ADDRSTRLEN16];
694
695 if (netspeed->devinfo->ip) {
8
Assuming field 'ip' is 0
9
Taking false branch
696 format_ipv4 (netspeed->devinfo->ip, ipv4_text);
697 text = ipv4_text;
698 } else {
699 text = _("none")dcgettext (((void*)0), "none", 5);
700 }
701 gtk_label_set_text (GTK_LABEL (netspeed->ip_text)((((GtkLabel*) (void *) ((netspeed->ip_text))))), text);
702
703 if (netspeed->devinfo->netmask) {
10
Assuming field 'netmask' is 0
11
Taking false branch
704 format_ipv4 (netspeed->devinfo->netmask, ipv4_text);
705 text = ipv4_text;
706 } else {
707 text = _("none")dcgettext (((void*)0), "none", 5);
708 }
709 gtk_label_set_text (GTK_LABEL (netspeed->netmask_text)((((GtkLabel*) (void *) ((netspeed->netmask_text))))), text);
710
711 if (netspeed->devinfo->type != DEV_LO) {
12
Assuming field 'type' is not equal to DEV_LO
13
Taking true branch
712 text = mac_addr_n2a (netspeed->devinfo->hwaddr);
713 gtk_label_set_text (GTK_LABEL (netspeed->hwaddr_text)((((GtkLabel*) (void *) ((netspeed->hwaddr_text))))), text);
714 g_free (text);
715 } else {
716 gtk_label_set_text (GTK_LABEL (netspeed->hwaddr_text)((((GtkLabel*) (void *) ((netspeed->hwaddr_text))))), _("none")dcgettext (((void*)0), "none", 5));
717 }
718
719 if (netspeed->devinfo->ptpip) {
14
Assuming field 'ptpip' is 0
15
Taking false branch
720 format_ipv4 (netspeed->devinfo->ptpip, ipv4_text);
721 text = ipv4_text;
722 } else {
723 text = _("none")dcgettext (((void*)0), "none", 5);
724 }
725 gtk_label_set_text (GTK_LABEL (netspeed->ptpip_text)((((GtkLabel*) (void *) ((netspeed->ptpip_text))))), text);
726
727 /* check if we got an ipv6 address */
728 GSList *ipv6_address_list = get_ip_address_list (netspeed->devinfo->name, FALSE(0));
729 if (ipv6_address_list != NULL((void*)0)) {
16
Assuming 'ipv6_address_list' is equal to NULL
17
Taking false branch
730 GSList *iterator;
731 GString *string = NULL((void*)0);
732
733 for (iterator = ipv6_address_list; iterator; iterator = iterator->next) {
734 if (string == NULL((void*)0))
735 string = g_string_new ((char*) iterator->data);
736 else
737 g_string_append_printf (string, "\n%s", (char*) iterator->data);
738 }
739 if (string != NULL((void*)0)) {
740 gtk_label_set_text (GTK_LABEL (netspeed->ipv6_text)((((GtkLabel*) (void *) ((netspeed->ipv6_text))))), string->str);
741 gtk_widget_show (netspeed->ipv6_box);
742 }
743 g_string_free (string, TRUE)(__builtin_constant_p ((!(0))) ? (((!(0))) ? (g_string_free) (
(string), ((!(0)))) : g_string_free_and_steal (string)) : (g_string_free
) ((string), ((!(0)))))
;
744 g_slist_free_full (ipv6_address_list, g_free);
745 } else {
746 gtk_widget_hide (netspeed->ipv6_box);
747 }
748
749 if (netspeed->devinfo->type == DEV_WIRELESS) {
18
Assuming field 'type' is equal to DEV_WIRELESS
19
Taking true branch
750 float quality;
751
752 /* _maybe_ we can add the encrypted icon between the essid and the signal bar. */
753
754 quality = netspeed->devinfo->qual / 100.0f;
755 if (quality > 1.0)
20
Assuming the condition is false
21
Taking false branch
756 quality = 1.0;
757
758 text = g_strdup_printf ("%d %%", netspeed->devinfo->qual);
759 gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (netspeed->signalbar)((((GtkProgressBar*) (void *) ((netspeed->signalbar))))), quality);
760 gtk_progress_bar_set_text (GTK_PROGRESS_BAR (netspeed->signalbar)((((GtkProgressBar*) (void *) ((netspeed->signalbar))))), text);
761 g_free (text);
762
763 gtk_label_set_text (GTK_LABEL (netspeed->essid_text)((((GtkLabel*) (void *) ((netspeed->essid_text))))),
764 netspeed->devinfo->essid);
765
766#ifdef HAVE_NL1
767 if (netspeed->devinfo->running) {
22
Assuming field 'running' is not equal to 0
23
Taking true branch
768 text = mac_addr_n2a (netspeed->devinfo->station_mac_addr);
24
Calling 'mac_addr_n2a'
769 gtk_label_set_text (GTK_LABEL (netspeed->station_text)((((GtkLabel*) (void *) ((netspeed->station_text))))), text);
770 g_free (text);
771 } else {
772 gtk_label_set_text (GTK_LABEL (netspeed->station_text)((((GtkLabel*) (void *) ((netspeed->station_text))))), _("unknown")dcgettext (((void*)0), "unknown", 5));
773 }
774
775 gtk_label_set_text (GTK_LABEL (netspeed->channel_text)((((GtkLabel*) (void *) ((netspeed->channel_text))))),
776 netspeed->devinfo->channel ? netspeed->devinfo->channel : _("unknown")dcgettext (((void*)0), "unknown", 5));
777
778 text = format_time (netspeed->devinfo->connected_time);
779 gtk_label_set_text (GTK_LABEL (netspeed->connected_time_text)((((GtkLabel*) (void *) ((netspeed->connected_time_text)))
))
,
780 netspeed->devinfo->connected_time > 0 ? text : _("na")dcgettext (((void*)0), "na", 5));
781 g_free (text);
782
783 gtk_widget_show (netspeed->netlink_box);
784#else
785 gtk_widget_hide (netspeed->netlink_box);
786#endif /* HAVE_NL */
787 gtk_widget_show (netspeed->wireless_box);
788 } else {
789 gtk_widget_hide (netspeed->wireless_box);
790 }
791}
792
793/* Here happens the really interesting stuff */
794static void
795update_applet (NetspeedApplet *netspeed)
796{
797 guint64 indiff, outdiff;
798 double inrate, outrate;
799 char *inbytes, *outbytes;
800 int i;
801 DevInfo *oldinfo;
802
803 if (!netspeed) return;
804
805 /* First we try to figure out if the device has changed */
806 oldinfo = netspeed->devinfo;
807 get_device_info (oldinfo->name, &netspeed->devinfo);
808 if (compare_device_info (netspeed->devinfo, oldinfo))
809 netspeed->device_has_changed = TRUE(!(0));
810 free_device_info (oldinfo);
811
812 /* If the device has changed, reintialize stuff */
813 if (netspeed->device_has_changed) {
814 change_icons (netspeed);
815 change_quality_icon (netspeed);
816
817 for (i = 0; i < OLD_VALUES5; i++) {
818 netspeed->in_old[i] = netspeed->devinfo->rx;
819 netspeed->out_old[i] = netspeed->devinfo->tx;
820 }
821
822 for (i = 0; i < GRAPH_VALUES180; i++) {
823 netspeed->in_graph[i] = -1;
824 netspeed->out_graph[i] = -1;
825 }
826
827 netspeed->max_graph = 0;
828 netspeed->index_graph = 0;
829
830 if (netspeed->details) {
831 fill_details_dialog (netspeed);
832 }
833
834 netspeed->device_has_changed = FALSE(0);
835 }
836
837 /* create the strings for the labels and tooltips */
838 if (netspeed->devinfo->running) {
839 if (netspeed->devinfo->rx < netspeed->in_old[netspeed->index_old])
840 indiff = 0;
841 else
842 indiff = netspeed->devinfo->rx - netspeed->in_old[netspeed->index_old];
843
844 if (netspeed->devinfo->tx < netspeed->out_old[netspeed->index_old])
845 outdiff = 0;
846 else
847 outdiff = netspeed->devinfo->tx - netspeed->out_old[netspeed->index_old];
848
849 inrate = (double)indiff / OLD_VALUES_DBL5.0;
850 outrate = (double)outdiff / OLD_VALUES_DBL5.0;
851
852 netspeed->in_graph[netspeed->index_graph] = inrate;
853 netspeed->out_graph[netspeed->index_graph] = outrate;
854 netspeed->max_graph = MAX (inrate, netspeed->max_graph)(((inrate) > (netspeed->max_graph)) ? (inrate) : (netspeed
->max_graph))
;
855 netspeed->max_graph = MAX (outrate, netspeed->max_graph)(((outrate) > (netspeed->max_graph)) ? (outrate) : (netspeed
->max_graph))
;
856
857 format_transfer_rate (netspeed->devinfo->rx_rate, inrate, netspeed->show_bits);
858 format_transfer_rate (netspeed->devinfo->tx_rate, outrate, netspeed->show_bits);
859 format_transfer_rate (netspeed->devinfo->sum_rate, inrate + outrate, netspeed->show_bits);
860 } else {
861 netspeed->devinfo->rx_rate[0] = '\0';
862 netspeed->devinfo->tx_rate[0] = '\0';
863 netspeed->devinfo->sum_rate[0] = '\0';
864 netspeed->in_graph[netspeed->index_graph] = 0;
865 netspeed->out_graph[netspeed->index_graph] = 0;
866 }
867
868 if (netspeed->devinfo->type == DEV_WIRELESS) {
869 if (netspeed->devinfo->up)
870 update_quality_icon (netspeed);
871
872 if (netspeed->signalbar) {
873 float quality;
874 char *text;
875
876 quality = netspeed->devinfo->qual / 100.0f;
877 if (quality > 1.0)
878 quality = 1.0;
879
880 text = g_strdup_printf ("%d %%", netspeed->devinfo->qual);
881 gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (netspeed->signalbar)((((GtkProgressBar*) (void *) ((netspeed->signalbar))))), quality);
882 gtk_progress_bar_set_text (GTK_PROGRESS_BAR (netspeed->signalbar)((((GtkProgressBar*) (void *) ((netspeed->signalbar))))), text);
883 g_free (text);
884 }
885#ifdef HAVE_NL1
886 /* Refresh the value of Connected Time */
887 if (netspeed->connected_time_text) {
888 char *text;
889
890 text = format_time (netspeed->devinfo->connected_time);
891 gtk_label_set_text (GTK_LABEL (netspeed->connected_time_text)((((GtkLabel*) (void *) ((netspeed->connected_time_text)))
))
,
892 netspeed->devinfo->connected_time > 0 ? text : _("na")dcgettext (((void*)0), "na", 5));
893 g_free (text);
894 }
895#endif
896 }
897
898 update_tooltip (netspeed);
899
900 /* Refresh the text of the labels */
901 if (netspeed->show_sum) {
902 gtk_label_set_text (GTK_LABEL (netspeed->sum_label)((((GtkLabel*) (void *) ((netspeed->sum_label))))),
903 netspeed->devinfo->sum_rate);
904 } else {
905 gtk_label_set_text (GTK_LABEL (netspeed->in_label)((((GtkLabel*) (void *) ((netspeed->in_label))))),
906 netspeed->devinfo->rx_rate);
907 gtk_label_set_text (GTK_LABEL (netspeed->out_label)((((GtkLabel*) (void *) ((netspeed->out_label))))),
908 netspeed->devinfo->tx_rate);
909 }
910
911 /* Refresh the values of the Infodialog */
912 if (netspeed->inbytes_text) {
913 if (netspeed->show_bits)
914 inbytes = g_format_size_full (netspeed->devinfo->rx*8,
915 G_FORMAT_SIZE_IEC_UNITS | G_FORMAT_SIZE_BITS);
916 else
917 inbytes = g_format_size_full (netspeed->devinfo->rx,
918 G_FORMAT_SIZE_IEC_UNITS);
919
920 gtk_label_set_text (GTK_LABEL (netspeed->inbytes_text)((((GtkLabel*) (void *) ((netspeed->inbytes_text))))), inbytes);
921 g_free (inbytes);
922 }
923 if (netspeed->outbytes_text) {
924 if (netspeed->show_bits)
925 outbytes = g_format_size_full (netspeed->devinfo->tx*8,
926 G_FORMAT_SIZE_IEC_UNITS | G_FORMAT_SIZE_BITS);
927 else
928 outbytes = g_format_size_full (netspeed->devinfo->tx,
929 G_FORMAT_SIZE_IEC_UNITS);
930
931 gtk_label_set_text (GTK_LABEL (netspeed->outbytes_text)((((GtkLabel*) (void *) ((netspeed->outbytes_text))))), outbytes);
932 g_free (outbytes);
933 }
934
935 /* Redraw the graph of the Infodialog */
936 if (netspeed->drawingarea)
937 gtk_widget_queue_draw (GTK_WIDGET (netspeed->drawingarea)((((GtkWidget*) (void *) ((netspeed->drawingarea))))));
938
939 /* Save old values... */
940 netspeed->in_old [netspeed->index_old] = netspeed->devinfo->rx;
941 netspeed->out_old [netspeed->index_old] = netspeed->devinfo->tx;
942 netspeed->index_old = (netspeed->index_old + 1) % OLD_VALUES5;
943
944 /* Move the graphindex. Check if we can scale down again */
945 netspeed->index_graph = (netspeed->index_graph + 1) % GRAPH_VALUES180;
946 if (netspeed->index_graph % 20 == 0) {
947 double max = 0;
948
949 for (i = 0; i < GRAPH_VALUES180; i++) {
950 max = MAX (max, netspeed->in_graph[i])(((max) > (netspeed->in_graph[i])) ? (max) : (netspeed->
in_graph[i]))
;
951 max = MAX (max, netspeed->out_graph[i])(((max) > (netspeed->out_graph[i])) ? (max) : (netspeed
->out_graph[i]))
;
952 }
953 netspeed->max_graph = max;
954 }
955
956 /* Always follow the default route */
957 if (netspeed->auto_change_device) {
958 gboolean change_device_now = !netspeed->devinfo->running;
959
960 if (!change_device_now) {
961 const gchar *default_route;
962
963 default_route = get_default_route ();
964 change_device_now = (default_route != NULL((void*)0) &&
965 strcmp (default_route, netspeed->devinfo->name));
966 }
967 if (change_device_now) {
968 search_for_up_if (netspeed);
969 }
970 }
971}
972
973static gboolean
974timeout_function (NetspeedApplet *netspeed)
975{
976 if (!netspeed)
977 return FALSE(0);
978 if (!netspeed->timeout_id)
979 return FALSE(0);
980
981 update_applet (netspeed);
982 return TRUE(!(0));
983}
984
985/* Display a section of netspeed help
986 */
987void
988netspeed_applet_display_help (GtkWidget *dialog,
989 const gchar *section)
990{
991 GError *error = NULL((void*)0);
992 gboolean ret;
993 char *uri;
994
995 if (section)
996 uri = g_strdup_printf ("help:mate-netspeed-applet/%s", section);
997 else
998 uri = g_strdup ("help:mate-netspeed-applet")g_strdup_inline ("help:mate-netspeed-applet");
999
1000 ret = gtk_show_uri_on_window (NULL((void*)0),
1001 uri,
1002 gtk_get_current_event_time (),
1003 &error);
1004 g_free (uri);
1005
1006 if (ret == FALSE(0)) {
1007 GtkWidget *error_dialog = gtk_message_dialog_new (NULL((void*)0),
1008 GTK_DIALOG_MODAL,
1009 GTK_MESSAGE_ERROR,
1010 GTK_BUTTONS_OK,
1011 _("There was an error displaying help:\n%s")dcgettext (((void*)0), "There was an error displaying help:\n%s"
, 5)
,
1012 error->message);
1013 g_signal_connect (error_dialog, "response",g_signal_connect_data ((error_dialog), ("response"), (((GCallback
) (gtk_widget_destroy))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
1014 G_CALLBACK (gtk_widget_destroy), NULL)g_signal_connect_data ((error_dialog), ("response"), (((GCallback
) (gtk_widget_destroy))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
1015
1016 gtk_window_set_resizable (GTK_WINDOW (error_dialog)((((GtkWindow*) (void *) ((error_dialog))))), FALSE(0));
1017 gtk_window_set_screen (GTK_WINDOW (error_dialog)((((GtkWindow*) (void *) ((error_dialog))))), gtk_widget_get_screen (dialog));
1018 gtk_widget_show (error_dialog);
1019 g_error_free (error);
1020 }
1021}
1022
1023/* Opens gnome help application
1024 */
1025static void
1026help_cb (GtkAction *action,
1027 NetspeedApplet *netspeed)
1028{
1029 netspeed_applet_display_help (GTK_WIDGET (netspeed)((((GtkWidget*) (void *) ((netspeed))))), NULL((void*)0));
1030}
1031
1032/* Just the about window... If it's already open, just fokus it
1033 */
1034static void
1035about_cb (GtkAction *action,
1036 gpointer data)
1037{
1038 const char *authors[] =
1039 {
1040 "Jörgen Scheibengruber <mfcn@gmx.de>",
1041 "Dennis Cranston <dennis_cranston@yahoo.com>",
1042 "Pedro Villavicencio Garrido <pvillavi@gnome.org>",
1043 "Benoît Dejean <benoit@placenet.org>",
1044 "Stefano Karapetsas <stefano@karapetsas.com>",
1045 "Perberos <perberos@gmail.com>",
1046 NULL((void*)0)
1047 };
1048
1049 gtk_show_about_dialog (NULL((void*)0),
1050 "title", _("About MATE Netspeed")dcgettext (((void*)0), "About MATE Netspeed", 5),
1051 "version", VERSION"1.27.1",
1052 "copyright", _("Copyright \xc2\xa9 2002-2003 Jörgen Scheibengruber\n"dcgettext (((void*)0), "Copyright \xc2\xa9 2002-2003 Jörgen Scheibengruber\n"
"Copyright \xc2\xa9 2011-2014 Stefano Karapetsas\n" "Copyright \xc2\xa9 2015-2021 MATE developers"
, 5)
1053 "Copyright \xc2\xa9 2011-2014 Stefano Karapetsas\n"dcgettext (((void*)0), "Copyright \xc2\xa9 2002-2003 Jörgen Scheibengruber\n"
"Copyright \xc2\xa9 2011-2014 Stefano Karapetsas\n" "Copyright \xc2\xa9 2015-2021 MATE developers"
, 5)
1054 "Copyright \xc2\xa9 2015-2021 MATE developers")dcgettext (((void*)0), "Copyright \xc2\xa9 2002-2003 Jörgen Scheibengruber\n"
"Copyright \xc2\xa9 2011-2014 Stefano Karapetsas\n" "Copyright \xc2\xa9 2015-2021 MATE developers"
, 5)
,
1055 "comments", _("A little applet that displays some information on the traffic on the specified network device")dcgettext (((void*)0), "A little applet that displays some information on the traffic on the specified network device"
, 5)
,
1056 "authors", authors,
1057 "documenters", NULL((void*)0),
1058 "translator-credits", _("translator-credits")dcgettext (((void*)0), "translator-credits", 5),
1059 "website", PACKAGE_URL"https://mate-desktop.org",
1060 "logo-icon-name", LOGO_ICON,
1061 NULL((void*)0));
1062}
1063
1064static void
1065netspeed_applet_destroy_preferences (GtkWidget *widget,
1066 gpointer user_data)
1067{
1068 NetspeedApplet *netspeed;
1069 (void) widget;
1070
1071 netspeed = NETSPEED_APPLET (user_data);
1072 netspeed->preferences = NULL((void*)0);
1073}
1074
1075/* Creates the settings dialog
1076 * After its been closed, take the new values and store
1077 * them in the gsettings database
1078 */
1079static void
1080settings_cb (GtkAction *action,
1081 NetspeedApplet *netspeed)
1082{
1083 g_assert (netspeed)do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_16
; if (netspeed) _g_boolean_var_16 = 1; else _g_boolean_var_16
= 0; _g_boolean_var_16; }), 1)) ; else g_assertion_message_expr
(((gchar*) 0), "netspeed.c", 1083, ((const char*) (__func__)
), "netspeed"); } while (0)
;
1084
1085 if (netspeed->preferences)
1086 {
1087 gtk_window_present (GTK_WINDOW (netspeed->preferences)((((GtkWindow*) (void *) ((netspeed->preferences))))));
1088 return;
1089 }
1090
1091 netspeed->preferences = netspeed_preferences_new (netspeed);
1092 g_signal_connect (netspeed->preferences, "destroy",g_signal_connect_data ((netspeed->preferences), ("destroy"
), (((GCallback) (netspeed_applet_destroy_preferences))), (netspeed
), ((void*)0), (GConnectFlags) 0)
1093 G_CALLBACK (netspeed_applet_destroy_preferences), netspeed)g_signal_connect_data ((netspeed->preferences), ("destroy"
), (((GCallback) (netspeed_applet_destroy_preferences))), (netspeed
), ((void*)0), (GConnectFlags) 0)
;
1094 gtk_widget_show_all (netspeed->preferences);
1095}
1096
1097static gboolean
1098da_draw (GtkWidget *widget,
1099 cairo_t *cr,
1100 NetspeedApplet *netspeed)
1101{
1102 redraw_graph (netspeed, cr);
1103
1104 return FALSE(0);
1105}
1106
1107static void
1108incolor_changed_cb (GtkColorChooser *button,
1109 NetspeedApplet *netspeed)
1110{
1111 GdkRGBA color;
1112 gchar *string;
1113
1114 gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (button)((((GtkColorChooser*) (void *) ((button))))), &color);
1115 netspeed->in_color = color;
1116
1117 string = gdk_rgba_to_string (&color);
1118 g_settings_set_string (netspeed->settings, "in-color", string);
1119 g_free (string);
1120}
1121
1122static void
1123outcolor_changed_cb (GtkColorChooser *button,
1124 NetspeedApplet *netspeed)
1125{
1126 GdkRGBA color;
1127 gchar *string;
1128
1129 gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (button)((((GtkColorChooser*) (void *) ((button))))), &color);
1130 netspeed->out_color = color;
1131
1132 string = gdk_rgba_to_string (&color);
1133 g_settings_set_string (netspeed->settings, "out-color", string);
1134 g_free (string);
1135}
1136
1137/* Handle info dialog response event
1138 */
1139static void
1140info_response_cb (GtkDialog *dialog,
1141 gint id,
1142 NetspeedApplet *netspeed)
1143{
1144
1145 if (id == GTK_RESPONSE_HELP) {
1146 netspeed_applet_display_help (GTK_WIDGET (dialog)((((GtkWidget*) (void *) ((dialog))))), "netspeed_applet-details");
1147 return;
1148 }
1149
1150 gtk_widget_destroy (netspeed->details);
1151
1152 netspeed->details = NULL((void*)0);
1153 netspeed->drawingarea = NULL((void*)0);
1154 netspeed->ip_text = NULL((void*)0);
1155 netspeed->netmask_text = NULL((void*)0);
1156 netspeed->ptpip_text = NULL((void*)0);
1157 netspeed->ipv6_text = NULL((void*)0);
1158 netspeed->hwaddr_text = NULL((void*)0);
1159 netspeed->inbytes_text = NULL((void*)0);
1160 netspeed->outbytes_text = NULL((void*)0);
1161 netspeed->essid_text = NULL((void*)0);
1162 netspeed->signalbar = NULL((void*)0);
1163#ifdef HAVE_NL1
1164 netspeed->station_text = NULL((void*)0);
1165 netspeed->channel_text = NULL((void*)0);
1166 netspeed->connected_time_text = NULL((void*)0);
1167#endif /* HAVE_NL */
1168 netspeed->ipv6_box = NULL((void*)0);
1169 netspeed->netlink_box = NULL((void*)0);
1170 netspeed->wireless_box = NULL((void*)0);
1171}
1172
1173/* Creates the details dialog
1174 */
1175static void
1176showinfo_cb (GtkAction *action,
1177 NetspeedApplet *netspeed)
1178{
1179 GtkBuilder *builder;
1180
1181 g_assert (netspeed)do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_17
; if (netspeed) _g_boolean_var_17 = 1; else _g_boolean_var_17
= 0; _g_boolean_var_17; }), 1)) ; else g_assertion_message_expr
(((gchar*) 0), "netspeed.c", 1181, ((const char*) (__func__)
), "netspeed"); } while (0)
;
1
Assuming 'netspeed' is non-null
2
Taking true branch
3
Taking true branch
4
Loop condition is false. Exiting loop
1182
1183 if (netspeed->details) {
5
Assuming field 'details' is null
6
Taking false branch
1184 gtk_window_present (GTK_WINDOW (netspeed->details)((((GtkWindow*) (void *) ((netspeed->details))))));
1185 return;
1186 }
1187
1188 builder = gtk_builder_new_from_resource (NETSPEED_RESOURCE_PATH"/org/mate/mate-applets/netspeed/" "netspeed-details.ui");
1189
1190 netspeed->details = GET_WIDGET ("dialog")(((((GtkWidget*) (void *) ((gtk_builder_get_object (builder, (
"dialog"))))))))
;
1191 netspeed->drawingarea = GET_DRAWING_AREA ("drawingarea")(((((GtkDrawingArea*) (void *) ((gtk_builder_get_object (builder
, ("drawingarea"))))))))
;
1192
1193 netspeed->ip_text = GET_WIDGET ("ip_text")(((((GtkWidget*) (void *) ((gtk_builder_get_object (builder, (
"ip_text"))))))))
;
1194 netspeed->netmask_text = GET_WIDGET ("netmask_text")(((((GtkWidget*) (void *) ((gtk_builder_get_object (builder, (
"netmask_text"))))))))
;
1195 netspeed->ptpip_text = GET_WIDGET ("ptpip_text")(((((GtkWidget*) (void *) ((gtk_builder_get_object (builder, (
"ptpip_text"))))))))
;
1196 netspeed->ipv6_text = GET_WIDGET ("ipv6_text")(((((GtkWidget*) (void *) ((gtk_builder_get_object (builder, (
"ipv6_text"))))))))
;
1197 netspeed->hwaddr_text = GET_WIDGET ("hwaddr_text")(((((GtkWidget*) (void *) ((gtk_builder_get_object (builder, (
"hwaddr_text"))))))))
;
1198 netspeed->inbytes_text = GET_WIDGET ("inbytes_text")(((((GtkWidget*) (void *) ((gtk_builder_get_object (builder, (
"inbytes_text"))))))))
;
1199 netspeed->outbytes_text = GET_WIDGET ("outbytes_text")(((((GtkWidget*) (void *) ((gtk_builder_get_object (builder, (
"outbytes_text"))))))))
;
1200 netspeed->essid_text = GET_WIDGET ("essid_text")(((((GtkWidget*) (void *) ((gtk_builder_get_object (builder, (
"essid_text"))))))))
;
1201 netspeed->signalbar = GET_WIDGET ("signalbar")(((((GtkWidget*) (void *) ((gtk_builder_get_object (builder, (
"signalbar"))))))))
;
1202#ifdef HAVE_NL1
1203 netspeed->station_text = GET_WIDGET ("station_text")(((((GtkWidget*) (void *) ((gtk_builder_get_object (builder, (
"station_text"))))))))
;
1204 netspeed->channel_text = GET_WIDGET ("channel_text")(((((GtkWidget*) (void *) ((gtk_builder_get_object (builder, (
"channel_text"))))))))
;
1205
1206 netspeed->connected_time_text = GET_WIDGET ("connected_time_text")(((((GtkWidget*) (void *) ((gtk_builder_get_object (builder, (
"connected_time_text"))))))))
;
1207#endif /* HAVE_NL */
1208 netspeed->ipv6_box = GET_WIDGET ("ipv6_box")(((((GtkWidget*) (void *) ((gtk_builder_get_object (builder, (
"ipv6_box"))))))))
;
1209 netspeed->netlink_box = GET_WIDGET ("netlink_box")(((((GtkWidget*) (void *) ((gtk_builder_get_object (builder, (
"netlink_box"))))))))
;
1210 netspeed->wireless_box = GET_WIDGET ("wireless_box")(((((GtkWidget*) (void *) ((gtk_builder_get_object (builder, (
"wireless_box"))))))))
;
1211
1212 gtk_color_chooser_set_rgba (GET_COLOR_CHOOSER ("incolor_sel")(((((GtkColorChooser*) (void *) ((gtk_builder_get_object (builder
, ("incolor_sel"))))))))
, &netspeed->in_color);
1213 gtk_color_chooser_set_rgba (GET_COLOR_CHOOSER ("outcolor_sel")(((((GtkColorChooser*) (void *) ((gtk_builder_get_object (builder
, ("outcolor_sel"))))))))
, &netspeed->out_color);
1214
1215 fill_details_dialog (netspeed);
7
Calling 'fill_details_dialog'
1216
1217 gtk_builder_add_callback_symbols (builder,
1218 "on_drawingarea_draw", G_CALLBACK (da_draw)((GCallback) (da_draw)),
1219 "on_incolor_sel_color_set", G_CALLBACK (incolor_changed_cb)((GCallback) (incolor_changed_cb)),
1220 "on_outcolor_sel_color_set", G_CALLBACK (outcolor_changed_cb)((GCallback) (outcolor_changed_cb)),
1221 "on_dialog_response", G_CALLBACK (info_response_cb)((GCallback) (info_response_cb)),
1222 NULL((void*)0));
1223 gtk_builder_connect_signals (builder, netspeed);
1224
1225 g_object_unref (builder);
1226
1227 gtk_window_present (GTK_WINDOW (netspeed->details)((((GtkWindow*) (void *) ((netspeed->details))))));
1228}
1229
1230static const GtkActionEntry netspeed_applet_menu_actions [] = {
1231 { "NetspeedAppletDetails", "dialog-information", N_("Device _Details")("Device _Details"),
1232 NULL((void*)0), NULL((void*)0), G_CALLBACK (showinfo_cb)((GCallback) (showinfo_cb)) },
1233 { "NetspeedAppletProperties", "document-properties", N_("Preferences...")("Preferences..."),
1234 NULL((void*)0), NULL((void*)0), G_CALLBACK (settings_cb)((GCallback) (settings_cb)) },
1235 { "NetspeedAppletHelp", "help-browser", N_("Help")("Help"),
1236 NULL((void*)0), NULL((void*)0), G_CALLBACK (help_cb)((GCallback) (help_cb)) },
1237 { "NetspeedAppletAbout", "help-about", N_("About...")("About..."),
1238 NULL((void*)0), NULL((void*)0), G_CALLBACK (about_cb)((GCallback) (about_cb)) }
1239};
1240
1241/* Block the size_request signal emit by the label if the
1242 * text changes. Only if the label wants to grow, we give
1243 * permission. This will eventually result in the maximal
1244 * size of the applet and prevents the icons and labels from
1245 * "jumping around" in the mate_panel which looks uggly
1246 */
1247static void
1248label_size_allocate_cb (GtkWidget *widget,
1249 GtkAllocation *allocation,
1250 NetspeedApplet *netspeed)
1251{
1252 if (netspeed->labels_dont_shrink) {
1253 if (allocation->width <= netspeed->width)
1254 allocation->width = netspeed->width;
1255 else
1256 netspeed->width = allocation->width;
1257 }
1258}
1259
1260static gboolean
1261netspeed_applet_button_press_event (GtkWidget *widget,
1262 GdkEventButton *event)
1263{
1264 if (event->button == 1) {
1265 NetspeedApplet *netspeed = NETSPEED_APPLET (widget);
1266 GError *error = NULL((void*)0);
1267
1268 if (netspeed->connect_dialog) {
1269 gtk_window_present (GTK_WINDOW (netspeed->connect_dialog)((((GtkWindow*) (void *) ((netspeed->connect_dialog))))));
1270 return FALSE(0);
1271 }
1272
1273 if (netspeed->up_cmd && netspeed->down_cmd) {
1274 char *question;
1275 int response;
1276
1277 if (netspeed->devinfo->up)
1278 question = g_strdup_printf (_("Do you want to disconnect %s now?")dcgettext (((void*)0), "Do you want to disconnect %s now?", 5
)
,
1279 netspeed->devinfo->name);
1280 else
1281 question = g_strdup_printf (_("Do you want to connect %s now?")dcgettext (((void*)0), "Do you want to connect %s now?", 5),
1282 netspeed->devinfo->name);
1283
1284 netspeed->connect_dialog =
1285 gtk_message_dialog_new (NULL((void*)0),
1286 GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
1287 GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO,
1288 "%s", question);
1289
1290 response = gtk_dialog_run (GTK_DIALOG (netspeed->connect_dialog)((((GtkDialog*) (void *) ((netspeed->connect_dialog))))));
1291 gtk_widget_destroy (netspeed->connect_dialog);
1292 netspeed->connect_dialog = NULL((void*)0);
1293 g_free (question);
1294
1295 if (response == GTK_RESPONSE_YES) {
1296 GtkWidget *dialog;
1297 char *command;
1298
1299 command = g_strdup_printf ("%s %s",
1300 netspeed->devinfo->up ? netspeed->down_cmd : netspeed->up_cmd,
1301 netspeed->devinfo->name);
1302
1303 if (!g_spawn_command_line_async (command, &error)) {
1304 dialog = gtk_message_dialog_new_with_markup (NULL((void*)0),
1305 GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
1306 GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
1307 _("<b>Running command %s failed</b>\n%s")dcgettext (((void*)0), "<b>Running command %s failed</b>\n%s"
, 5)
, command, error->message);
1308 gtk_dialog_run (GTK_DIALOG (dialog)((((GtkDialog*) (void *) ((dialog))))));
1309 gtk_widget_destroy (dialog);
1310
1311 g_error_free (error);
1312 }
1313
1314 g_free (command);
1315 }
1316 }
1317 }
1318
1319 return GTK_WIDGET_CLASS (netspeed_applet_parent_class)((((GtkWidgetClass*) (void *) ((netspeed_applet_parent_class)
))))
->button_press_event (widget, event);
1320}
1321
1322/* Frees the applet and all the data it contains
1323 * Removes the timeout_cb
1324 */
1325static void
1326netspeed_applet_finalize (GObject *object)
1327{
1328 NetspeedApplet *netspeed = NETSPEED_APPLET (object);
1329
1330 if (netspeed->icon_theme != NULL((void*)0)) {
1331 g_signal_handlers_disconnect_by_func (netspeed->icon_theme,g_signal_handlers_disconnect_matched ((netspeed->icon_theme
), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (icon_theme_changed_cb), (netspeed))
1332 icon_theme_changed_cb,g_signal_handlers_disconnect_matched ((netspeed->icon_theme
), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (icon_theme_changed_cb), (netspeed))
1333 netspeed)g_signal_handlers_disconnect_matched ((netspeed->icon_theme
), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (icon_theme_changed_cb), (netspeed))
;
1334 netspeed->icon_theme = NULL((void*)0);
1335 }
1336
1337 if (netspeed->timeout_id > 0) {
1338 g_source_remove (netspeed->timeout_id);
1339 netspeed->timeout_id = 0;
1340 }
1341
1342 g_clear_object (&netspeed->settings)do { _Static_assert (sizeof *((&netspeed->settings)) ==
sizeof (gpointer), "Expression evaluates to false"); __typeof__
(((&netspeed->settings))) _pp = ((&netspeed->settings
)); __typeof__ (*((&netspeed->settings))) _ptr = *_pp;
*_pp = ((void*)0); if (_ptr) (g_object_unref) (_ptr); } while
(0)
;
1343
1344 g_clear_pointer (&netspeed->details, gtk_widget_destroy)do { _Static_assert (sizeof *(&netspeed->details) == sizeof
(gpointer), "Expression evaluates to false"); __typeof__ ((&
netspeed->details)) _pp = (&netspeed->details); __typeof__
(*(&netspeed->details)) _ptr = *_pp; *_pp = ((void*)0
); if (_ptr) (gtk_widget_destroy) (_ptr); } while (0)
;
1345 g_clear_pointer (&netspeed->preferences, gtk_widget_destroy)do { _Static_assert (sizeof *(&netspeed->preferences) ==
sizeof (gpointer), "Expression evaluates to false"); __typeof__
((&netspeed->preferences)) _pp = (&netspeed->preferences
); __typeof__ (*(&netspeed->preferences)) _ptr = *_pp;
*_pp = ((void*)0); if (_ptr) (gtk_widget_destroy) (_ptr); } while
(0)
;
1346
1347 g_free (netspeed->up_cmd);
1348 g_free (netspeed->down_cmd);
1349
1350 /* Should never be NULL */
1351 free_device_info (netspeed->devinfo);
1352}
1353
1354static void
1355update_tooltip (NetspeedApplet *netspeed)
1356{
1357 GString* tooltip;
1358
1359 if (!netspeed->show_tooltip)
1360 return;
1361
1362 tooltip = g_string_new ("");
1363
1364 if (!netspeed->devinfo->running)
1365 g_string_printf (tooltip, _("%s is down")dcgettext (((void*)0), "%s is down", 5), netspeed->devinfo->name);
1366 else {
1367 GSList *iterator;
1368 GString *string = NULL((void*)0);
1369 char ipv4_text [INET_ADDRSTRLEN16];
1370
1371 g_string_printf (tooltip, "%s: ", netspeed->devinfo->name);
1372
1373 if (netspeed->show_all_addresses || !netspeed->devinfo->ip) {
1374 GSList *ip6_address_list = get_ip6_address_list (netspeed->devinfo->name);
1375
1376 /* check if we got IPv6 addresses */
1377 if (ip6_address_list != NULL((void*)0)) {
1378 for (iterator = ip6_address_list; iterator; iterator = iterator->next) {
1379 if (string == NULL((void*)0))
1380 string = g_string_new ((char*) iterator->data);
1381 else
1382 g_string_append_printf (string,
1383 _("\n%s")dcgettext (((void*)0), "\n%s", 5),
1384 (char*) iterator->data);
1385 }
1386 }
1387
1388 g_slist_free_full (ip6_address_list, g_free);
1389 }
1390
1391 if (!netspeed->devinfo->ip && !string) {
1392 g_string_append (tooltip, "has no ip")(__builtin_constant_p ("has no ip") ? __extension__ ({ const char
* const __val = ("has no ip"); g_string_append_len_inline (tooltip
, __val, (__builtin_expect (__extension__ ({ int _g_boolean_var_18
; if (__val != ((void*)0)) _g_boolean_var_18 = 1; else _g_boolean_var_18
= 0; _g_boolean_var_18; }), 1)) ? (gssize) strlen (((__val) +
!(__val))) : (gssize) -1); }) : g_string_append_len_inline (
tooltip, "has no ip", (gssize) -1))
;
1393 }
1394
1395 if (netspeed->devinfo->ip) {
1396 format_ipv4 (netspeed->devinfo->ip, ipv4_text);
1397 g_string_append (tooltip, ipv4_text)(__builtin_constant_p (ipv4_text) ? __extension__ ({ const char
* const __val = (ipv4_text); g_string_append_len_inline (tooltip
, __val, (__builtin_expect (__extension__ ({ int _g_boolean_var_19
; if (__val != ((void*)0)) _g_boolean_var_19 = 1; else _g_boolean_var_19
= 0; _g_boolean_var_19; }), 1)) ? (gssize) strlen (((__val) +
!(__val))) : (gssize) -1); }) : g_string_append_len_inline (
tooltip, ipv4_text, (gssize) -1))
;
1398 }
1399
1400 if (string != NULL((void*)0)) {
1401 g_string_append_printf (tooltip,
1402 _("\n%s")dcgettext (((void*)0), "\n%s", 5),
1403 string->str);
1404 g_string_free (string, TRUE)(__builtin_constant_p ((!(0))) ? (((!(0))) ? (g_string_free) (
(string), ((!(0)))) : g_string_free_and_steal (string)) : (g_string_free
) ((string), ((!(0)))))
;
1405 }
1406
1407 if (netspeed->show_sum) {
1408 g_string_append_printf (tooltip,
1409 _("\nin: %s out: %s")dcgettext (((void*)0), "\nin: %s out: %s", 5),
1410 netspeed->devinfo->rx_rate,
1411 netspeed->devinfo->tx_rate);
1412 } else {
1413 g_string_append_printf (tooltip,
1414 _("\nsum: %s")dcgettext (((void*)0), "\nsum: %s", 5),
1415 netspeed->devinfo->sum_rate);
1416 }
1417
1418#ifdef HAVE_NL1
1419 if (netspeed->devinfo->type == DEV_WIRELESS)
1420 g_string_append_printf (tooltip,
1421 _("\nESSID: %s\nRSSI: %d dBm\nRX Bitrate: %s\nTX Bitrate: %s")dcgettext (((void*)0), "\nESSID: %s\nRSSI: %d dBm\nRX Bitrate: %s\nTX Bitrate: %s"
, 5)
,
1422 netspeed->devinfo->essid ? netspeed->devinfo->essid : _("unknown")dcgettext (((void*)0), "unknown", 5),
1423 netspeed->devinfo->rssi,
1424 netspeed->devinfo->rx_bitrate,
1425 netspeed->devinfo->tx_bitrate);
1426#endif /* HAVE_NL */
1427#ifdef HAVE_IW
1428 if (netspeed->devinfo->type == DEV_WIRELESS)
1429 g_string_append_printf (tooltip,
1430 _("\nESSID: %s\nStrength: %d %%")dcgettext (((void*)0), "\nESSID: %s\nStrength: %d %%", 5),
1431 netspeed->devinfo->essid ? netspeed->devinfo->essid : _("unknown")dcgettext (((void*)0), "unknown", 5),
1432 netspeed->devinfo->qual);
1433#endif /* HAVE_IW */
1434 }
1435
1436 gtk_widget_set_tooltip_text (GTK_WIDGET (netspeed)((((GtkWidget*) (void *) ((netspeed))))), tooltip->str);
1437 gtk_widget_trigger_tooltip_query (GTK_WIDGET (netspeed)((((GtkWidget*) (void *) ((netspeed))))));
1438 g_string_free (tooltip, TRUE)(__builtin_constant_p ((!(0))) ? (((!(0))) ? (g_string_free) (
(tooltip), ((!(0)))) : g_string_free_and_steal (tooltip)) : (
g_string_free) ((tooltip), ((!(0)))))
;
1439}
1440
1441static gboolean
1442netspeed_applet_enter_notify_event (GtkWidget *widget,
1443 GdkEventCrossing *event)
1444{
1445 NetspeedApplet *netspeed = NETSPEED_APPLET (widget);
1446
1447 netspeed->show_tooltip = TRUE(!(0));
1448 update_tooltip (netspeed);
1449 return TRUE(!(0));
1450}
1451
1452static gboolean
1453netspeed_applet_leave_notify_event (GtkWidget *widget,
1454 GdkEventCrossing *event)
1455{
1456 NetspeedApplet *netspeed = NETSPEED_APPLET (widget);
1457
1458 netspeed->show_tooltip = FALSE(0);
1459 return TRUE(!(0));
1460}
1461
1462static void
1463netspeed_applet_class_init (NetspeedAppletClass *klass)
1464{
1465 GObjectClass *object_class = G_OBJECT_CLASS (klass)((((GObjectClass*) (void *) ((klass)))));
1466 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass)((((GtkWidgetClass*) (void *) ((klass)))));
1467
1468 object_class->finalize = netspeed_applet_finalize;
1469
1470 widget_class->button_press_event = netspeed_applet_button_press_event;
1471 widget_class->leave_notify_event = netspeed_applet_leave_notify_event;
1472 widget_class->enter_notify_event = netspeed_applet_enter_notify_event;
1473}
1474
1475static void
1476netspeed_applet_init (NetspeedApplet *netspeed)
1477{
1478}
1479
1480static void
1481changeicon_settings_changed (GSettings *settings,
1482 const gchar *key,
1483 NetspeedApplet *netspeed)
1484{
1485 netspeed->change_icon = g_settings_get_boolean (settings, key);
1486 change_icons (netspeed);
1487}
1488
1489static void
1490showalladdresses_settings_changed (GSettings *settings,
1491 const gchar *key,
1492 NetspeedApplet *netspeed)
1493{
1494 netspeed->show_all_addresses = g_settings_get_boolean (settings, key);
1495}
1496
1497static void
1498showsum_settings_changed (GSettings *settings,
1499 const gchar *key,
1500 NetspeedApplet *netspeed)
1501{
1502 netspeed->show_sum = g_settings_get_boolean (settings, key);
1503 applet_change_size_or_orient (MATE_PANEL_APPLET (netspeed), -1, netspeed);
1504 change_icons (netspeed);
1505}
1506
1507static void
1508showbits_settings_changed (GSettings *settings,
1509 const gchar *key,
1510 NetspeedApplet *netspeed)
1511{
1512 netspeed->show_bits = g_settings_get_boolean (settings, key);
1513}
1514
1515static void
1516showicon_settings_changed (GSettings *settings,
1517 const gchar *key,
1518 NetspeedApplet *netspeed)
1519{
1520 netspeed->show_icon = g_settings_get_boolean (settings, key);
1521 change_icons (netspeed);
1522}
1523
1524static void
1525showqualityicon_settings_changed (GSettings *settings,
1526 const gchar *key,
1527 NetspeedApplet *netspeed)
1528{
1529 netspeed->show_quality_icon = g_settings_get_boolean (settings, key);
1530 change_quality_icon (netspeed);
1531}
1532
1533static void
1534auto_change_device_settings_changed (GSettings *settings,
1535 const gchar *key,
1536 NetspeedApplet *netspeed)
1537{
1538 netspeed->auto_change_device = g_settings_get_boolean (settings, key);
1539 netspeed->device_has_changed = TRUE(!(0));
1540 update_applet (netspeed);
1541}
1542
1543static void
1544device_settings_changed (GSettings *settings,
1545 const gchar *key,
1546 NetspeedApplet *netspeed)
1547{
1548 char *device;
1549
1550 device = g_settings_get_string (settings, key);
1551 if (device && *device != '\0') {
1552 free_device_info (netspeed->devinfo);
1553 get_device_info (device, &netspeed->devinfo);
1554 netspeed->device_has_changed = TRUE(!(0));
1555 }
1556 g_free (device);
1557}
1558
1559/* The "main" function of the applet
1560 */
1561static gboolean
1562netspeed_applet_factory (MatePanelApplet *applet,
1563 const gchar *iid,
1564 gpointer data)
1565{
1566 NetspeedApplet *netspeed;
1567 int i;
1568 GtkWidget *spacer, *spacer_box;
1569 GtkActionGroup *action_group;
1570 AtkObject *atk_obj;
1571 char *tmp;
1572
1573 if (strcmp (iid, "NetspeedApplet"))
1574 return FALSE(0);
1575
1576 glibtop_init ();
1577
1578#ifndef ENABLE_IN_PROCESS
1579 g_set_application_name (_("MATE Netspeed")dcgettext (((void*)0), "MATE Netspeed", 5));
1580#endif
1581
1582 netspeed = NETSPEED_APPLET (applet);
1583 netspeed->icon_theme = gtk_icon_theme_get_default ();
1584
1585 for (i = 0; i < GRAPH_VALUES180; i++)
1586 {
1587 netspeed->in_graph[i] = -1;
1588 netspeed->out_graph[i] = -1;
1589 }
1590
1591 netspeed->settings = mate_panel_applet_settings_new (applet, "org.mate.panel.applet.netspeed");
1592
1593 /* Get stored settings from gsettings
1594 */
1595 netspeed->show_all_addresses = g_settings_get_boolean (netspeed->settings, "show-all-addresses");
1596 netspeed->show_sum = g_settings_get_boolean (netspeed->settings, "show-sum");
1597 netspeed->show_bits = g_settings_get_boolean (netspeed->settings, "show-bits");
1598 netspeed->show_icon = g_settings_get_boolean (netspeed->settings, "show-icon");
1599 netspeed->show_quality_icon = g_settings_get_boolean (netspeed->settings, "show-quality-icon");
1600 netspeed->change_icon = g_settings_get_boolean (netspeed->settings, "change-icon");
1601 netspeed->auto_change_device = g_settings_get_boolean (netspeed->settings, "auto-change-device");
1602
1603 tmp = g_settings_get_string (netspeed->settings, "device");
1604 if (tmp && *tmp != '\0')
1605 get_device_info (tmp, &netspeed->devinfo);
1606 else
1607 netspeed->devinfo = NULL((void*)0);
1608 g_free (tmp);
1609
1610 tmp = g_settings_get_string (netspeed->settings, "up-command");
1611 if (tmp && *tmp != '\0')
1612 netspeed->up_cmd = g_strdup (tmp)g_strdup_inline (tmp);
1613 else
1614 netspeed->up_cmd = NULL((void*)0);
1615 g_free (tmp);
1616
1617 tmp = g_settings_get_string (netspeed->settings, "down-command");
1618 if (tmp && *tmp != '\0')
1619 netspeed->down_cmd = g_strdup (tmp)g_strdup_inline (tmp);
1620 else
1621 netspeed->down_cmd = NULL((void*)0);
1622 g_free (tmp);
1623
1624 tmp = g_settings_get_string (netspeed->settings, "in-color");
1625 if (tmp && *tmp != '\0')
1626 gdk_rgba_parse (&netspeed->in_color, tmp);
1627 else
1628 gdk_rgba_parse (&netspeed->in_color, "#df0028004700");
1629 g_free (tmp);
1630
1631 tmp = g_settings_get_string (netspeed->settings, "out-color");
1632 if (tmp && *tmp != '\0')
1633 gdk_rgba_parse (&netspeed->out_color, tmp);
1634 else
1635 gdk_rgba_parse (&netspeed->out_color, "#37002800df00");
1636 g_free (tmp);
1637
1638 if (!netspeed->devinfo) {
1639 GList *ptr, *devices = get_available_devices ();
1640 ptr = devices;
1641 while (ptr) {
1642 if (!g_str_equal (ptr->data, "lo")(strcmp ((const char *) (ptr->data), (const char *) ("lo")
) == 0)
) {
1643 get_device_info (ptr->data, &netspeed->devinfo);
1644 break;
1645 }
1646 ptr = g_list_next (ptr)((ptr) ? (((GList *)(ptr))->next) : ((void*)0));
1647 }
1648 g_list_free_full (devices, g_free);
1649 }
1650 if (!netspeed->devinfo)
1651 get_device_info ("lo", &netspeed->devinfo);
1652
1653 netspeed->device_has_changed = TRUE(!(0));
1654
1655 netspeed->in_label = gtk_label_new ("");
1656 netspeed->out_label = gtk_label_new ("");
1657 netspeed->sum_label = gtk_label_new ("");
1658
1659 netspeed->in_pix = gtk_image_new ();
1660 netspeed->out_pix = gtk_image_new ();
1661 netspeed->dev_pix = gtk_image_new ();
1662 netspeed->qual_pix = gtk_image_new ();
1663
1664 netspeed->pix_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
1665 spacer = gtk_label_new ("");
1666 gtk_box_pack_start (GTK_BOX (netspeed->pix_box)((((GtkBox*) (void *) ((netspeed->pix_box))))), spacer, TRUE(!(0)), TRUE(!(0)), 0);
1667 spacer = gtk_label_new ("");
1668 gtk_box_pack_end (GTK_BOX (netspeed->pix_box)((((GtkBox*) (void *) ((netspeed->pix_box))))), spacer, TRUE(!(0)), TRUE(!(0)), 0);
1669
1670 spacer_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
1671 gtk_box_pack_start (GTK_BOX (netspeed->pix_box)((((GtkBox*) (void *) ((netspeed->pix_box))))), spacer_box, FALSE(0), FALSE(0), 0);
1672 gtk_box_pack_start (GTK_BOX (spacer_box)((((GtkBox*) (void *) ((spacer_box))))), netspeed->qual_pix, FALSE(0), FALSE(0), 0);
1673 gtk_box_pack_start (GTK_BOX (spacer_box)((((GtkBox*) (void *) ((spacer_box))))), netspeed->dev_pix, FALSE(0), FALSE(0), 0);
1674
1675 init_quality_surfaces (netspeed);
1676
1677 applet_change_size_or_orient (applet, -1, netspeed);
1678 gtk_widget_show_all (GTK_WIDGET (applet)((((GtkWidget*) (void *) ((applet))))));
1679 update_applet (netspeed);
1680
1681 mate_panel_applet_set_flags (applet, MATE_PANEL_APPLET_EXPAND_MINOR);
1682
1683 netspeed->timeout_id = g_timeout_add (REFRESH_TIME1000,
1684 (GSourceFunc)timeout_function,
1685 netspeed);
1686 g_signal_connect_object (applet, "change-size",
1687 G_CALLBACK (applet_change_size_or_orient)((GCallback) (applet_change_size_or_orient)),
1688 netspeed, 0);
1689
1690 g_signal_connect_object (netspeed->icon_theme, "changed",
1691 G_CALLBACK (icon_theme_changed_cb)((GCallback) (icon_theme_changed_cb)),
1692 netspeed, 0);
1693
1694 g_signal_connect_object (applet, "change-orient",
1695 G_CALLBACK (applet_change_size_or_orient)((GCallback) (applet_change_size_or_orient)),
1696 netspeed, 0);
1697
1698 g_signal_connect_object (netspeed->in_label, "size-allocate",
1699 G_CALLBACK (label_size_allocate_cb)((GCallback) (label_size_allocate_cb)),
1700 netspeed, 0);
1701
1702 g_signal_connect_object (netspeed->out_label, "size-allocate",
1703 G_CALLBACK (label_size_allocate_cb)((GCallback) (label_size_allocate_cb)),
1704 netspeed, 0);
1705
1706 g_signal_connect_object (netspeed->sum_label, "size-allocate",
1707 G_CALLBACK (label_size_allocate_cb)((GCallback) (label_size_allocate_cb)),
1708 netspeed, 0);
1709
1710 g_signal_connect_object (netspeed->settings, "changed::auto-change-device",
1711 G_CALLBACK (auto_change_device_settings_changed)((GCallback) (auto_change_device_settings_changed)),
1712 netspeed, 0);
1713
1714 g_signal_connect_object (netspeed->settings, "changed::device",
1715 G_CALLBACK (device_settings_changed)((GCallback) (device_settings_changed)),
1716 netspeed, 0);
1717
1718 g_signal_connect_object (netspeed->settings, "changed::show-all-addresses",
1719 G_CALLBACK (showalladdresses_settings_changed)((GCallback) (showalladdresses_settings_changed)),
1720 netspeed, 0);
1721
1722 g_signal_connect_object (netspeed->settings, "changed::show-sum",
1723 G_CALLBACK (showsum_settings_changed)((GCallback) (showsum_settings_changed)),
1724 netspeed, 0);
1725
1726 g_signal_connect_object (netspeed->settings, "changed::show-bits",
1727 G_CALLBACK (showbits_settings_changed)((GCallback) (showbits_settings_changed)),
1728 netspeed, 0);
1729
1730 g_signal_connect_object (netspeed->settings, "changed::change-icon",
1731 G_CALLBACK (changeicon_settings_changed)((GCallback) (changeicon_settings_changed)),
1732 netspeed, 0);
1733
1734 g_signal_connect_object (netspeed->settings, "changed::show-icon",
1735 G_CALLBACK (showicon_settings_changed)((GCallback) (showicon_settings_changed)),
1736 netspeed, 0);
1737
1738 g_signal_connect_object (netspeed->settings, "changed::show-quality-icon",
1739 G_CALLBACK (showqualityicon_settings_changed)((GCallback) (showqualityicon_settings_changed)),
1740 netspeed, 0);
1741
1742 action_group = gtk_action_group_new ("Netspeed Applet Actions");
1743 gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE"mate-applets");
1744 gtk_action_group_add_actions (action_group,
1745 netspeed_applet_menu_actions,
1746 G_N_ELEMENTS (netspeed_applet_menu_actions)(sizeof (netspeed_applet_menu_actions) / sizeof ((netspeed_applet_menu_actions
)[0]))
,
1747 netspeed);
1748
1749 mate_panel_applet_setup_menu_from_resource (applet,
1750 NETSPEED_RESOURCE_PATH"/org/mate/mate-applets/netspeed/" "netspeed-menu.xml",
1751 action_group);
1752
1753 atk_obj = gtk_widget_get_accessible (GTK_WIDGET (applet)((((GtkWidget*) (void *) ((applet))))));
1754
1755 if (GTK_IS_ACCESSIBLE (atk_obj)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(atk_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; }))))
) {
1756 atk_object_set_name (atk_obj, _("MATE Netspeed")dcgettext (((void*)0), "MATE Netspeed", 5));
1757 atk_object_set_description (atk_obj,
1758 _("A little applet that displays some information on the traffic on the specified network device")dcgettext (((void*)0), "A little applet that displays some information on the traffic on the specified network device"
, 5)
);
1759 }
1760
1761 g_object_unref (action_group);
1762
1763 return TRUE(!(0));
1764}
1765
1766PANEL_APPLET_FACTORY ("NetspeedAppletFactory",int main(int argc, char *argv[]) { GOptionContext *context; GError
*error; int retval; do { bindtextdomain ("mate-applets", "/usr/local/share/locale"
); bind_textdomain_codeset ("mate-applets", "UTF-8"); if ((!(
0))) textdomain ("mate-applets"); } 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 ("NetspeedAppletFactory"
,(!(0)), netspeed_applet_get_type (), netspeed_applet_factory
, ((void*)0)); g_option_context_free (context); return retval
; }
1767 NETSPEED_TYPE_APPLET,int main(int argc, char *argv[]) { GOptionContext *context; GError
*error; int retval; do { bindtextdomain ("mate-applets", "/usr/local/share/locale"
); bind_textdomain_codeset ("mate-applets", "UTF-8"); if ((!(
0))) textdomain ("mate-applets"); } 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 ("NetspeedAppletFactory"
,(!(0)), netspeed_applet_get_type (), netspeed_applet_factory
, ((void*)0)); g_option_context_free (context); return retval
; }
1768 "NetspeedApplet",int main(int argc, char *argv[]) { GOptionContext *context; GError
*error; int retval; do { bindtextdomain ("mate-applets", "/usr/local/share/locale"
); bind_textdomain_codeset ("mate-applets", "UTF-8"); if ((!(
0))) textdomain ("mate-applets"); } 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 ("NetspeedAppletFactory"
,(!(0)), netspeed_applet_get_type (), netspeed_applet_factory
, ((void*)0)); g_option_context_free (context); return retval
; }
1769 netspeed_applet_factory,int main(int argc, char *argv[]) { GOptionContext *context; GError
*error; int retval; do { bindtextdomain ("mate-applets", "/usr/local/share/locale"
); bind_textdomain_codeset ("mate-applets", "UTF-8"); if ((!(
0))) textdomain ("mate-applets"); } 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 ("NetspeedAppletFactory"
,(!(0)), netspeed_applet_get_type (), netspeed_applet_factory
, ((void*)0)); g_option_context_free (context); return retval
; }
1770 NULL)int main(int argc, char *argv[]) { GOptionContext *context; GError
*error; int retval; do { bindtextdomain ("mate-applets", "/usr/local/share/locale"
); bind_textdomain_codeset ("mate-applets", "UTF-8"); if ((!(
0))) textdomain ("mate-applets"); } 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 ("NetspeedAppletFactory"
,(!(0)), netspeed_applet_get_type (), netspeed_applet_factory
, ((void*)0)); g_option_context_free (context); return retval
; }
diff --git a/2023-10-06-143029-14295-1@5e7148e14497_gtk-image-menu-item/report-ad73bf.html b/2023-10-06-143029-14295-1@5e7148e14497_gtk-image-menu-item/report-ad73bf.html new file mode 100644 index 00000000..12b3c30a --- /dev/null +++ b/2023-10-06-143029-14295-1@5e7148e14497_gtk-image-menu-item/report-ad73bf.html @@ -0,0 +1,1232 @@ + + + +load-graph.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:multiload/src/load-graph.c
Warning:line 106, column 20
Division by zero
+ +

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 load-graph.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=none -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/multiload/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I ../.. -I . -D MULTILOAD_RESOURCE_PATH="/org/mate/mate-applets/multiload/" -I /usr/include/mate-panel-4.0/libmate-panel-applet -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -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/lib64/dbus-1.0/include -I /usr/include/libgtop-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gio-unix-2.0 -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-unused-parameter -fdebug-compilation-dir=/rootdir/multiload/src -ferror-limit 19 -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-10-06-143029-14295-1 -x c load-graph.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2#include <stdio.h>
3#include <sys/stat.h>
4#include <unistd.h>
5#include <signal.h>
6#include <dirent.h>
7#include <string.h>
8#include <time.h>
9#include <glib.h>
10#include <gdk/gdkx.h>
11#include <gtk/gtk.h>
12#include <gio/gio.h>
13#include <mate-panel-applet.h>
14#include <mate-panel-applet-gsettings.h>
15#include <math.h>
16
17#include "global.h"
18
19/*
20 Shifts data right
21
22 data[i+1] = data[i]
23
24 data[i] are int*, so we just move the pointer, not the data.
25 But moving data loses data[n-1], so we save data[n-1] and reuse
26 it as new data[0]. In fact, we rotate data[].
27
28*/
29
30static void
31shift_right(LoadGraph *g)
32{
33 guint64 *last_data;
34 gsize i;
35
36 /* data[g->draw_width - 1] becomes data[0] */
37 last_data = g->data[g->draw_width - 1];
38
39 /* data[i+1] = data[i] */
40 for (i = g->draw_width - 1; i != 0; --i)
41 g->data[i] = g->data[i - 1];
42
43 g->data[0] = last_data;
44}
45
46/* Redraws the backing pixmap for the load graph and updates the window */
47static void
48load_graph_draw (LoadGraph *g)
49{
50 guint i, j, k;
51 cairo_t *cr;
52 MultiloadApplet *multiload;
53
54 multiload = g->multiload;
55
56 /* we might get called before the configure event so that
57 * g->disp->allocation may not have the correct size
58 * (after the user resized the applet in the prop dialog). */
59
60 if (!g->surface)
6
Assuming field 'surface' is non-null
7
Taking false branch
61 g->surface = gdk_window_create_similar_surface (gtk_widget_get_window (g->disp),
62 CAIRO_CONTENT_COLOR,
63 (int) g->draw_width,
64 (int) g->draw_height);
65
66 cr = cairo_create (g->surface);
67 cairo_set_line_width (cr, 1.0);
68 cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
69 cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
70
71 /* all graphs except Load and Net go this path */
72 switch (g->id) {
8
Control jumps to 'case graph_netload2:' at line 75
73
74 /* This is for network graph */
75 case graph_netload2: {
76 guint64 maxnet = 1;
77 guint64 segments = 1;
78 guint64 net_threshold;
79 guint level = 0;
80 double ratio;
81 double spacing;
82
83 for (i = 0; i < g->draw_width; i++)
9
Assuming 'i' is >= field 'draw_width'
10
Loop condition is false. Execution continues on line 90
84 {
85 g->pos [i] = g->draw_height - 1;
86 if (g->data[i][3] > maxnet)
87 maxnet = g->data[i][3];
88 }
89 //printf("max = %d ", maxnet);
90 if (maxnet > multiload->net_threshold3) {
11
Assuming 'maxnet' is > field 'net_threshold3'
12
Taking true branch
91 net_threshold = multiload->net_threshold3;
13
The value 0 is assigned to 'net_threshold'
92 level = 3;
93 }
94 else
95 if (maxnet > multiload->net_threshold2) {
96 net_threshold = multiload->net_threshold2;
97 level = 2;
98 }
99 else {
100 net_threshold = multiload->net_threshold1;
101 if (maxnet >= multiload->net_threshold1)
102 level = 1;
103 }
104
105 //printf("level %d maxnet = %d ", level, maxnet);
106 maxnet = maxnet/net_threshold;
14
Division by zero
107 segments = MAX (maxnet+1,1)(((maxnet+1) > (1)) ? (maxnet+1) : (1));
108 ratio = (double) g->draw_height / (double) (net_threshold*segments);
109 //printf("segments %d ratio = %f t1=%ld t2=%ld t3=%ld t=%ld\n", segments, ratio, multiload->net_threshold1, multiload->net_threshold2, multiload->net_threshold3, multiload->net_threshold);
110
111 for (j = 0; j < g->n-1; j++)
112 {
113 gdk_cairo_set_source_rgba (cr, &(g->colors [j]));
114
115 for (i = 0; i < g->draw_width; i++)
116 {
117 double x = (double) (g->draw_width - i) - 0.5;
118 cairo_move_to (cr, x, (double) g->pos[i] + 0.5);
119 cairo_line_to (cr, x, (double) g->pos[i] - 0.5 - (((double) g->data [i][j] * ratio)));
120 g->pos [i] -= (guint64) ((double) g->data [i][j] * ratio);
121 }
122 cairo_stroke (cr);
123 }
124
125 for (j = g->n-1; j < g->n; j++)
126 {
127 gdk_cairo_set_source_rgba (cr, &(g->colors [j]));
128 for (i = 0; i < g->draw_width; i++)
129 {
130 double x = (double) (g->draw_width - i) - 0.5;
131 cairo_move_to (cr, x, (double) g->pos[i] + 0.5);
132 cairo_line_to (cr, x, 0.5);
133 }
134 cairo_stroke (cr);
135 }
136
137 /* draw grid lines if needed */
138 gdk_cairo_set_source_rgba (cr, &(g->colors [4]));
139 for (k = 0; k < segments -1; k++)
140 {
141 spacing = ((double) g->draw_height / (double) segments) * (k+1);
142 cairo_move_to (cr, 0.5, spacing);
143 cairo_line_to (cr, (double) g->draw_width - 0.5, spacing);
144 }
145 cairo_stroke (cr);
146 /* draw indicator if needed */
147 if (level > 0)
148 {
149 gdk_cairo_set_source_rgba (cr, &(g->colors [5]));
150 for (k = 0; k< level; k++ )
151 cairo_rectangle (cr,
152 0.5, (double) k * 2.0 * (double) g->draw_height / 5.0,
153 5.0, (double) g->draw_height / 5.0);
154 cairo_fill(cr);
155 }
156 cairo_stroke (cr);
157 break;
158 }
159
160 /* this is Load graph */
161 case graph_loadavg: {
162 double load;
163 guint64 maxload = 1;
164 for (i = 0; i < g->draw_width; i++)
165 {
166 g->pos [i] = g->draw_height - 1;
167 /* find maximum value */
168 if (g->data[i][0] > maxload)
169 maxload = g->data[i][0];
170 }
171 load = ceil ((double) maxload / (double) g->draw_height) + 1.0;
172
173 for (j = 0; j < g->n; j++)
174 {
175 gdk_cairo_set_source_rgba (cr, &(g->colors [j]));
176
177 for (i = 0; i < g->draw_width; i++)
178 {
179 double x = (double) (g->draw_width - i) - 0.5;
180 cairo_move_to (cr, x, (double) g->pos[i] + 0.5);
181 if (j == 0)
182 {
183 cairo_line_to (cr, x, (double) g->pos[i] - (((double) g->data [i][j] - 0.5)/load));
184 }
185 else
186 {
187 cairo_line_to (cr, x, 0.5);
188 }
189 g->pos [i] -= (guint64) ((double) g->data [i][j] / load);
190 }
191 cairo_stroke (cr);
192 }
193
194 /* draw grid lines in Load graph if needed */
195 gdk_cairo_set_source_rgba (cr, &(g->colors [2]));
196
197 double spacing;
198 for (k = 0; k < load - 1; k++)
199 {
200 spacing = ((double) g->draw_height/load) * (k+1);
201 cairo_move_to (cr, 0.5, spacing);
202 cairo_line_to (cr, (double) g->draw_width - 0.5, spacing);
203 }
204
205 cairo_stroke (cr);
206 break;
207 }
208
209 default:
210 for (i = 0; i < g->draw_width; i++)
211 g->pos [i] = g->draw_height - 1;
212
213 for (j = 0; j < g->n; j++)
214 {
215 gdk_cairo_set_source_rgba (cr, &(g->colors [j]));
216
217 for (i = 0; i < g->draw_width; i++)
218 {
219 if (g->data [i][j] != 0)
220 {
221 double x = (double) (g->draw_width - i) - 0.5;
222 cairo_move_to (cr, x, (double) g->pos[i] + 0.5);
223 cairo_line_to (cr, x, (double) g->pos[i] - (double) g->data [i][j] - 0.5);
224 }
225 g->pos [i] -= g->data [i][j];
226 }
227 cairo_stroke (cr);
228 }
229 }
230
231 gtk_widget_queue_draw (g->disp);
232
233 cairo_destroy (cr);
234}
235
236/* Updates the load graph when the timeout expires */
237static gboolean
238load_graph_update (LoadGraph *g)
239{
240 if (g->data == NULL((void*)0))
1
Assuming field 'data' is not equal to NULL
2
Taking false branch
241 return TRUE(!(0));
242
243 shift_right(g);
244
245 if (g->tooltip_update)
3
Assuming field 'tooltip_update' is 0
4
Taking false branch
246 multiload_applet_tooltip_update (g);
247
248 g->get_data (g->draw_height, g->data [0], g);
249
250 load_graph_draw (g);
5
Calling 'load_graph_draw'
251 return TRUE(!(0));
252}
253
254void
255load_graph_unalloc (LoadGraph *g)
256{
257 gsize i;
258
259 if (!g->allocated)
260 return;
261
262 for (i = 0; i < g->draw_width; i++)
263 {
264 g_free (g->data [i]);
265 }
266
267 g_free (g->data);
268 g_free (g->pos);
269
270 g->pos = NULL((void*)0);
271 g->data = NULL((void*)0);
272
273 g->size = CLAMP (g_settings_get_uint (g->multiload->settings, GRAPH_SIZE_KEY),(((g_settings_get_uint (g->multiload->settings, "size")
) > (1000)) ? (1000) : (((g_settings_get_uint (g->multiload
->settings, "size")) < (10)) ? (10) : (g_settings_get_uint
(g->multiload->settings, "size"))))
274 GRAPH_SIZE_MIN,(((g_settings_get_uint (g->multiload->settings, "size")
) > (1000)) ? (1000) : (((g_settings_get_uint (g->multiload
->settings, "size")) < (10)) ? (10) : (g_settings_get_uint
(g->multiload->settings, "size"))))
275 GRAPH_SIZE_MAX)(((g_settings_get_uint (g->multiload->settings, "size")
) > (1000)) ? (1000) : (((g_settings_get_uint (g->multiload
->settings, "size")) < (10)) ? (10) : (g_settings_get_uint
(g->multiload->settings, "size"))))
;
276
277 if (g->surface) {
278 cairo_surface_destroy (g->surface);
279 g->surface = NULL((void*)0);
280 }
281
282 g->allocated = FALSE(0);
283}
284
285static void
286load_graph_alloc (LoadGraph *g)
287{
288 gsize i;
289 gsize data_size;
290
291 if (g->allocated)
292 return;
293
294 g->data = g_new0 (guint64 *, g->draw_width)(guint64 * *) (__extension__ ({ gsize __n = (gsize) (g->draw_width
); gsize __s = sizeof (guint64 *); gpointer __p; if (__s == 1
) __p = g_malloc0 (__n); else if (__builtin_constant_p (__n) &&
(__s == 0 || __n <= (9223372036854775807L *2UL+1UL) / __s
)) __p = g_malloc0 (__n * __s); else __p = g_malloc0_n (__n, __s
); __p; }))
;
295 g->pos = g_new0 (guint64, g->draw_width)(guint64 *) (__extension__ ({ gsize __n = (gsize) (g->draw_width
); gsize __s = sizeof (guint64); gpointer __p; if (__s == 1) __p
= g_malloc0 (__n); else if (__builtin_constant_p (__n) &&
(__s == 0 || __n <= (9223372036854775807L *2UL+1UL) / __s
)) __p = g_malloc0 (__n * __s); else __p = g_malloc0_n (__n, __s
); __p; }))
;
296
297 data_size = sizeof (guint64) * g->n;
298
299 for (i = 0; i < g->draw_width; i++) {
300 g->data [i] = g_malloc0 (data_size);
301 }
302
303 g->allocated = TRUE(!(0));
304}
305
306static gint
307load_graph_configure (GtkWidget *widget, GdkEventConfigure *event,
308 gpointer data_ptr)
309{
310 GtkAllocation allocation;
311 LoadGraph *c = (LoadGraph *) data_ptr;
312
313 load_graph_unalloc (c);
314
315 gtk_widget_get_allocation (c->disp, &allocation);
316
317 c->draw_width = (gsize) allocation.width;
318 c->draw_height = (guint64) allocation.height;
319 c->draw_width = MAX (c->draw_width, 1)(((c->draw_width) > (1)) ? (c->draw_width) : (1));
320 c->draw_height = MAX (c->draw_height, 1)(((c->draw_height) > (1)) ? (c->draw_height) : (1));
321
322 load_graph_alloc (c);
323
324 if (!c->surface)
325 c->surface = gdk_window_create_similar_surface (gtk_widget_get_window (c->disp),
326 CAIRO_CONTENT_COLOR,
327 (int) c->draw_width,
328 (int) c->draw_height);
329 gtk_widget_queue_draw (widget);
330
331 return TRUE(!(0));
332}
333
334static gint
335load_graph_expose (GtkWidget *widget,
336 cairo_t *cr,
337 gpointer data_ptr)
338{
339 LoadGraph *g = (LoadGraph *) data_ptr;
340
341 cairo_set_source_surface (cr, g->surface, 0, 0);
342 cairo_paint (cr);
343
344 return FALSE(0);
345}
346
347static void
348load_graph_destroy (GtkWidget *widget, gpointer data_ptr)
349{
350 LoadGraph *g = (LoadGraph *) data_ptr;
351
352 load_graph_stop (g);
353
354 gtk_widget_destroy(widget);
355}
356
357static gboolean
358load_graph_clicked (GtkWidget *widget, GdkEventButton *event, LoadGraph *load)
359{
360 load->multiload->last_clicked = load->id;
361
362 return FALSE(0);
363}
364
365static gboolean
366load_graph_enter_cb(GtkWidget *widget, GdkEventCrossing *event, gpointer data)
367{
368 LoadGraph *graph;
369 graph = (LoadGraph *)data;
370
371 graph->tooltip_update = TRUE(!(0));
372 multiload_applet_tooltip_update(graph);
373
374 return TRUE(!(0));
375}
376
377static gboolean
378load_graph_leave_cb(GtkWidget *widget, GdkEventCrossing *event, gpointer data)
379{
380 LoadGraph *graph;
381 graph = (LoadGraph *)data;
382
383 graph->tooltip_update = FALSE(0);
384
385 return TRUE(!(0));
386}
387
388static void
389load_graph_load_config (LoadGraph *g)
390{
391 gchar *name, *temp;
392 guint i;
393
394 if (!g->colors)
395 g->colors = g_new0(GdkRGBA, g->n)(GdkRGBA *) (__extension__ ({ gsize __n = (gsize) (g->n); gsize
__s = sizeof (GdkRGBA); gpointer __p; if (__s == 1) __p = g_malloc0
(__n); else if (__builtin_constant_p (__n) && (__s ==
0 || __n <= (9223372036854775807L *2UL+1UL) / __s)) __p =
g_malloc0 (__n * __s); else __p = g_malloc0_n (__n, __s); __p
; }))
;
396
397 for (i = 0; i < g->n; i++)
398 {
399 name = g_strdup_printf ("%s-color%u", g->name, i);
400 temp = g_settings_get_string(g->multiload->settings, name);
401 if (!temp)
402 temp = g_strdup ("#000000")g_strdup_inline ("#000000");
403 gdk_rgba_parse(&(g->colors[i]), temp);
404 g_free(temp);
405 g_free(name);
406 }
407}
408
409LoadGraph *
410load_graph_new (MultiloadApplet *ma, guint n, const gchar *label,
411 gint id, guint speed, guint size, gboolean visible,
412 const gchar *name, LoadGraphDataFunc get_data)
413{
414 LoadGraph *g;
415 MatePanelAppletOrient orient;
416
417 g = g_new0 (LoadGraph, 1)(LoadGraph *) (__extension__ ({ gsize __n = (gsize) (1); gsize
__s = sizeof (LoadGraph); gpointer __p; if (__s == 1) __p = g_malloc0
(__n); else if (__builtin_constant_p (__n) && (__s ==
0 || __n <= (9223372036854775807L *2UL+1UL) / __s)) __p =
g_malloc0 (__n * __s); else __p = g_malloc0_n (__n, __s); __p
; }))
;
418 g->visible = visible;
419 g->name = name;
420 g->n = n;
421 g->id = id;
422 g->speed = speed;
423 g->size = size;
424 g->pixel_size = mate_panel_applet_get_size (ma->applet);
425 g->tooltip_update = FALSE(0);
426 g->multiload = ma;
427
428 g->main_widget = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
429
430 g->box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
431
432 orient = mate_panel_applet_get_orient (g->multiload->applet);
433 switch (orient)
434 {
435 case MATE_PANEL_APPLET_ORIENT_UP:
436 case MATE_PANEL_APPLET_ORIENT_DOWN:
437 {
438 g->orient = FALSE(0);
439 break;
440 }
441 case MATE_PANEL_APPLET_ORIENT_LEFT:
442 case MATE_PANEL_APPLET_ORIENT_RIGHT:
443 {
444 g->orient = TRUE(!(0));
445 break;
446 }
447 default:
448 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "load-graph.c", 448
, ((const char*) (__func__)), ((void*)0)); } while (0)
;
449 }
450
451 g->frame = gtk_frame_new (NULL((void*)0));
452 gtk_frame_set_shadow_type (GTK_FRAME (g->frame)((((GtkFrame*) (void *) ((g->frame))))), GTK_SHADOW_IN);
453 gtk_container_add (GTK_CONTAINER (g->frame)((((GtkContainer*) (void *) ((g->frame))))), g->box);
454 gtk_box_pack_start (GTK_BOX (g->main_widget)((((GtkBox*) (void *) ((g->main_widget))))), g->frame, TRUE(!(0)), TRUE(!(0)), 0);
455
456 load_graph_load_config (g);
457
458 g->get_data = get_data;
459
460 g->timer_index = -1;
461
462 if (g->orient)
463 gtk_widget_set_size_request (g->main_widget, -1, (gint) g->size);
464 else
465 gtk_widget_set_size_request (g->main_widget, (gint) g->size, -1);
466
467 g->disp = gtk_drawing_area_new ();
468 gtk_widget_set_events (g->disp, GDK_EXPOSURE_MASK |
469 GDK_ENTER_NOTIFY_MASK |
470 GDK_LEAVE_NOTIFY_MASK |
471 GDK_BUTTON_PRESS_MASK);
472
473 g_signal_connect (g->disp, "draw",g_signal_connect_data ((g->disp), ("draw"), (((GCallback) (
load_graph_expose))), (g), ((void*)0), (GConnectFlags) 0)
474 G_CALLBACK (load_graph_expose), g)g_signal_connect_data ((g->disp), ("draw"), (((GCallback) (
load_graph_expose))), (g), ((void*)0), (GConnectFlags) 0)
;
475 g_signal_connect (g->disp, "configure-event",g_signal_connect_data ((g->disp), ("configure-event"), (((
GCallback) (load_graph_configure))), (g), ((void*)0), (GConnectFlags
) 0)
476 G_CALLBACK (load_graph_configure), g)g_signal_connect_data ((g->disp), ("configure-event"), (((
GCallback) (load_graph_configure))), (g), ((void*)0), (GConnectFlags
) 0)
;
477 g_signal_connect (g->disp, "destroy",g_signal_connect_data ((g->disp), ("destroy"), (((GCallback
) (load_graph_destroy))), (g), ((void*)0), (GConnectFlags) 0)
478 G_CALLBACK (load_graph_destroy), g)g_signal_connect_data ((g->disp), ("destroy"), (((GCallback
) (load_graph_destroy))), (g), ((void*)0), (GConnectFlags) 0)
;
479 g_signal_connect (g->disp, "button-press-event",g_signal_connect_data ((g->disp), ("button-press-event"), (
((GCallback) (load_graph_clicked))), (g), ((void*)0), (GConnectFlags
) 0)
480 G_CALLBACK (load_graph_clicked), g)g_signal_connect_data ((g->disp), ("button-press-event"), (
((GCallback) (load_graph_clicked))), (g), ((void*)0), (GConnectFlags
) 0)
;
481 g_signal_connect (g->disp, "enter-notify-event",g_signal_connect_data ((g->disp), ("enter-notify-event"), (
((GCallback) (load_graph_enter_cb))), (g), ((void*)0), (GConnectFlags
) 0)
482 G_CALLBACK(load_graph_enter_cb), g)g_signal_connect_data ((g->disp), ("enter-notify-event"), (
((GCallback) (load_graph_enter_cb))), (g), ((void*)0), (GConnectFlags
) 0)
;
483 g_signal_connect (g->disp, "leave-notify-event",g_signal_connect_data ((g->disp), ("leave-notify-event"), (
((GCallback) (load_graph_leave_cb))), (g), ((void*)0), (GConnectFlags
) 0)
484 G_CALLBACK(load_graph_leave_cb), g)g_signal_connect_data ((g->disp), ("leave-notify-event"), (
((GCallback) (load_graph_leave_cb))), (g), ((void*)0), (GConnectFlags
) 0)
;
485
486 gtk_box_pack_start (GTK_BOX (g->box)((((GtkBox*) (void *) ((g->box))))), g->disp, TRUE(!(0)), TRUE(!(0)), 0);
487 gtk_widget_show_all(g->box);
488
489 return g;
490}
491
492void
493load_graph_start (LoadGraph *g)
494{
495 guint event_source_id;
496
497 if (g->timer_index != -1)
498 g_source_remove ((guint) g->timer_index);
499
500 event_source_id = g_timeout_add (g->speed,
501 (GSourceFunc) load_graph_update, g);
502
503 g->timer_index = (gint) event_source_id;
504}
505
506void
507load_graph_stop (LoadGraph *g)
508{
509 if (g->timer_index != -1)
510 g_source_remove ((guint) g->timer_index);
511
512 g->timer_index = -1;
513}
diff --git a/2023-10-06-143029-14295-1@5e7148e14497_gtk-image-menu-item/scanview.css b/2023-10-06-143029-14295-1@5e7148e14497_gtk-image-menu-item/scanview.css new file mode 100644 index 00000000..cf8a5a6a --- /dev/null +++ b/2023-10-06-143029-14295-1@5e7148e14497_gtk-image-menu-item/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/2023-10-06-143029-14295-1@5e7148e14497_gtk-image-menu-item/sorttable.js b/2023-10-06-143029-14295-1@5e7148e14497_gtk-image-menu-item/sorttable.js new file mode 100644 index 00000000..32faa078 --- /dev/null +++ b/2023-10-06-143029-14295-1@5e7148e14497_gtk-image-menu-item/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("