Commit 855f3f8f authored by Alberts Muktupāvels's avatar Alberts Muktupāvels

netspeed: fix -Wformat-nonliteral warnings

parent 5806f3fe
...@@ -336,7 +336,6 @@ icon_theme_changed_cb(GtkIconTheme *icon_theme, gpointer user_data) ...@@ -336,7 +336,6 @@ icon_theme_changed_cb(GtkIconTheme *icon_theme, gpointer user_data)
static char* static char*
bytes_to_string(double bytes, gboolean per_sec, gboolean bits) bytes_to_string(double bytes, gboolean per_sec, gboolean bits)
{ {
const char *format;
const char *unit; const char *unit;
guint kilo; /* no really a kilo : a kilo or kibi */ guint kilo; /* no really a kilo : a kilo or kibi */
...@@ -347,16 +346,13 @@ bytes_to_string(double bytes, gboolean per_sec, gboolean bits) ...@@ -347,16 +346,13 @@ bytes_to_string(double bytes, gboolean per_sec, gboolean bits)
kilo = 1024; kilo = 1024;
if (bytes < kilo) { if (bytes < kilo) {
format = "%.0f %s";
if (per_sec) if (per_sec)
unit = bits ? N_("b/s") : N_("B/s"); unit = bits ? N_("b/s") : N_("B/s");
else else
unit = bits ? N_("bits") : N_("bytes"); unit = bits ? N_("bits") : N_("bytes");
return g_strdup_printf ("%.0f %s", bytes, gettext (unit));
} else if (bytes < (kilo * kilo)) { } else if (bytes < (kilo * kilo)) {
format = (bytes < (100 * kilo)) ? "%.1f %s" : "%.0f %s";
bytes /= kilo; bytes /= kilo;
if (per_sec) if (per_sec)
...@@ -364,10 +360,9 @@ bytes_to_string(double bytes, gboolean per_sec, gboolean bits) ...@@ -364,10 +360,9 @@ bytes_to_string(double bytes, gboolean per_sec, gboolean bits)
else else
unit = bits ? N_("kb") : N_("KiB"); unit = bits ? N_("kb") : N_("KiB");
return g_strdup_printf (bytes < (100 * kilo) ? "%.1f %s" : "%.0f %s",
bytes, gettext (unit));
} else { } else {
format = "%.1f %s";
bytes /= kilo * kilo; bytes /= kilo * kilo;
if (per_sec) if (per_sec)
...@@ -376,7 +371,7 @@ bytes_to_string(double bytes, gboolean per_sec, gboolean bits) ...@@ -376,7 +371,7 @@ bytes_to_string(double bytes, gboolean per_sec, gboolean bits)
unit = bits ? N_("Mb") : N_("MiB"); unit = bits ? N_("Mb") : N_("MiB");
} }
return g_strdup_printf(format, bytes, gettext(unit)); return g_strdup_printf ("%.1f %s", bytes, gettext (unit));
} }
static gboolean static gboolean
...@@ -1120,19 +1115,23 @@ netspeed_applet_button_press_event (GtkWidget *widget, ...@@ -1120,19 +1115,23 @@ netspeed_applet_button_press_event (GtkWidget *widget,
} }
if (netspeed->up_cmd && netspeed->down_cmd) { if (netspeed->up_cmd && netspeed->down_cmd) {
const gchar *question; char *question;
gint response; gint response;
if (netspeed->devinfo.up) if (netspeed->devinfo.up)
question = _("Do you want to disconnect %s now?"); question = g_strdup_printf (_("Do you want to disconnect %s now?"),
netspeed->devinfo.name);
else else
question = _("Do you want to connect %s now?"); question = g_strdup_printf (_("Do you want to connect %s now?"),
netspeed->devinfo.name);
netspeed->connect_dialog = gtk_message_dialog_new (NULL, netspeed->connect_dialog = gtk_message_dialog_new (NULL,
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO,
question, "%s", question);
netspeed->devinfo.name);
g_free (question);
response = gtk_dialog_run (GTK_DIALOG (netspeed->connect_dialog)); response = gtk_dialog_run (GTK_DIALOG (netspeed->connect_dialog));
gtk_widget_destroy (netspeed->connect_dialog); gtk_widget_destroy (netspeed->connect_dialog);
netspeed->connect_dialog = NULL; netspeed->connect_dialog = NULL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment