From b3892cf644c693fef44b5daf55a0b66a667ac147 Mon Sep 17 00:00:00 2001 From: rbuj Date: Mon, 13 Dec 2021 23:18:26 +0100 Subject: Fix some -Wfloat-conversion warnings --- battstat/battstat-preferences.c | 7 ++++--- battstat/battstat_applet.c | 7 +++++-- drivemount/src/drive-button.c | 11 +++++----- stickynotes/stickynotes_applet.c | 5 +++-- stickynotes/stickynotes_applet_callbacks.c | 32 +++++++++++++++++++----------- stickynotes/stickynotes_callbacks.c | 12 +++++++---- 6 files changed, 45 insertions(+), 29 deletions(-) diff --git a/battstat/battstat-preferences.c b/battstat/battstat-preferences.c index 40d38f42..88f93919 100644 --- a/battstat/battstat-preferences.c +++ b/battstat/battstat-preferences.c @@ -91,15 +91,16 @@ spin_ptr_cb (GtkWidget *spin_ptr, gpointer data) { BattstatPreferences *dialog = data; + gdouble red_val = gtk_spin_button_get_value (GTK_SPIN_BUTTON (spin_ptr)); - dialog->battstat->red_val = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (spin_ptr)); + dialog->battstat->red_val = (guint) red_val; /* automatically calculate orangle and yellow values from the * red value */ - dialog->battstat->orange_val = dialog->battstat->red_val * ORANGE_MULTIPLIER; + dialog->battstat->orange_val = (guint) (ORANGE_MULTIPLIER * red_val); dialog->battstat->orange_val = MIN (dialog->battstat->orange_val, 100); - dialog->battstat->yellow_val = dialog->battstat->red_val * YELLOW_MULTIPLIER; + dialog->battstat->yellow_val = (guint) (YELLOW_MULTIPLIER * red_val); dialog->battstat->yellow_val = MIN (dialog->battstat->yellow_val, 100); g_settings_set_int (dialog->battstat->settings, diff --git a/battstat/battstat_applet.c b/battstat/battstat_applet.c index 3382a540..99bdedfa 100644 --- a/battstat/battstat_applet.c +++ b/battstat/battstat_applet.c @@ -925,6 +925,7 @@ static void load_preferences (ProgressData *battstat) { GSettings *settings = battstat->settings; + gdouble red_val; if (DEBUG) g_print ("load_preferences ()\n"); @@ -933,10 +934,12 @@ load_preferences (ProgressData *battstat) battstat->red_value_is_time = g_settings_get_boolean (settings, "red-value-is-time"); /* automatically calculate orangle and yellow values from the red value */ - battstat->orange_val = battstat->red_val * ORANGE_MULTIPLIER; + red_val = (gdouble) battstat->red_val; + + battstat->orange_val = (guint) (ORANGE_MULTIPLIER * red_val); battstat->orange_val = MIN (battstat->orange_val, 100); - battstat->yellow_val = battstat->red_val * YELLOW_MULTIPLIER; + battstat->yellow_val = (guint) (YELLOW_MULTIPLIER * red_val); battstat->yellow_val = MIN (battstat->yellow_val, 100); battstat->lowbattnotification = g_settings_get_boolean (settings, "low-battery-notification"); diff --git a/drivemount/src/drive-button.c b/drivemount/src/drive-button.c index 95472c86..e0b86bf1 100644 --- a/drivemount/src/drive-button.c +++ b/drivemount/src/drive-button.c @@ -383,13 +383,12 @@ drive_button_update (gpointer user_data) g_free (color_string); g_object_unref (settings); - guchar red = color.red*255; - guchar green = color.green*255; - guchar blue = color.blue*255; + guchar red = (guchar) (color.red * 255.0); + guchar green = (guchar) (color.green * 255.0); + guchar blue = (guchar) (color.blue * 255.0); - const gdouble ratio = 0.65; - gdouble y_start = icon_height * ratio; - gdouble x_start = icon_height * (1 + ratio); + int y_start = (int) (0.65 * (gdouble) icon_height); + int x_start = (int) (1.65 * (gdouble) icon_height); for (y = y_start; y < icon_height; y++) for (x = x_start - y; x < icon_width; x++) diff --git a/stickynotes/stickynotes_applet.c b/stickynotes/stickynotes_applet.c index c697151e..fd903e1e 100644 --- a/stickynotes/stickynotes_applet.c +++ b/stickynotes/stickynotes_applet.c @@ -166,6 +166,7 @@ stickynotes_applet_init (MatePanelApplet *mate_panel_applet) { cairo_t *cr; gint size, scale; + int screen_height; stickynotes = g_new (StickyNotes, 1); @@ -208,8 +209,8 @@ stickynotes_applet_init (MatePanelApplet *mate_panel_applet) G_CALLBACK (preferences_apply_cb), NULL); /* Max height for large notes*/ - stickynotes->max_height = - 0.8 * HeightOfScreen (gdk_x11_screen_get_xscreen (gdk_screen_get_default ())); + screen_height = HeightOfScreen (gdk_x11_screen_get_xscreen (gdk_screen_get_default ())); + stickynotes->max_height = (int) (0.8 * (double) screen_height); /* Load sticky notes */ stickynotes_load (gtk_widget_get_screen (GTK_WIDGET (mate_panel_applet))); diff --git a/stickynotes/stickynotes_applet_callbacks.c b/stickynotes/stickynotes_applet_callbacks.c index c0889df2..6481bb82 100644 --- a/stickynotes/stickynotes_applet_callbacks.c +++ b/stickynotes/stickynotes_applet_callbacks.c @@ -444,18 +444,26 @@ menu_about_cb (GtkAction *action, void preferences_save_cb (gpointer data) { - gint width = gtk_adjustment_get_value (stickynotes->w_prefs_width); - gint height = gtk_adjustment_get_value (stickynotes->w_prefs_height); - gboolean sys_color = - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (stickynotes->w_prefs_sys_color)); - gboolean sys_font = - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (stickynotes->w_prefs_sys_font)); - gboolean sticky = - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (stickynotes->w_prefs_sticky)); - gboolean force_default = - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (stickynotes->w_prefs_force)); - gboolean desktop_hide = - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (stickynotes->w_prefs_desktop)); + gint width; + gint height; + gboolean sys_color; + gboolean sys_font; + gboolean sticky; + gboolean force_default; + gboolean desktop_hide; + gdouble adjustment_value; + + adjustment_value = gtk_adjustment_get_value (stickynotes->w_prefs_width); + width = (gint) adjustment_value; + + adjustment_value = gtk_adjustment_get_value (stickynotes->w_prefs_height); + height = (gint) adjustment_value; + + sys_color = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (stickynotes->w_prefs_sys_color)); + sys_font = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (stickynotes->w_prefs_sys_font)); + sticky = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (stickynotes->w_prefs_sticky)); + force_default = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (stickynotes->w_prefs_force)); + desktop_hide = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (stickynotes->w_prefs_desktop)); if (g_settings_is_writable (stickynotes->settings, "default-width")) diff --git a/stickynotes/stickynotes_callbacks.c b/stickynotes/stickynotes_callbacks.c index dac681a1..3f22dab7 100644 --- a/stickynotes/stickynotes_callbacks.c +++ b/stickynotes/stickynotes_callbacks.c @@ -49,13 +49,17 @@ gboolean stickynote_resize_cb (GtkWidget *widget, if (widget == note->w_resize_se) gtk_window_begin_resize_drag (GTK_WINDOW (note->w_window), GDK_WINDOW_EDGE_SOUTH_EAST, - event->button, event->x_root, - event->y_root, event->time); + event->button, + (gint) event->x_root, + (gint) event->y_root, + event->time); else /* if (widget == note->w_resize_sw) */ gtk_window_begin_resize_drag (GTK_WINDOW (note->w_window), GDK_WINDOW_EDGE_SOUTH_WEST, - event->button, event->x_root, - event->y_root, event->time); + event->button, + (gint) event->x_root, + (gint) event->y_root, + event->time); } else return FALSE; -- cgit v1.2.1