From 1666631039bf57876797506a29093fcda0d651fa Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Tue, 24 Jul 2012 18:29:51 +0200 Subject: [PATCH] Simplify how the blanking mode icon is built --- src/lib-display-blanking-status-menu-widget.c | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/lib-display-blanking-status-menu-widget.c b/src/lib-display-blanking-status-menu-widget.c index 0f0f3f8..a1b5788 100644 --- a/src/lib-display-blanking-status-menu-widget.c +++ b/src/lib-display-blanking-status-menu-widget.c @@ -74,8 +74,7 @@ GType display_blanking_status_plugin_get_type (void); #define MODE_GCONF_ROOT "/system/osso/dsm/display" #define MODE_GCONF_KEY MODE_GCONF_ROOT "/inhibit_blank_mode" -// Shoud contain one, and only one "%d" -#define ICON_TEMPLATE "display-blanking-icon.%d" +#define INHIBIT_MSG_INTERVAL 30 // in seconds #define GETTEXT_DOM "status-area-displayblanking-applet" #define gettext_noop(str) (str) @@ -89,6 +88,14 @@ static const char *_DisplayBlankingDescription[BLANKING_MODES] = gettext_noop ("Both disabled"), gettext_noop ("Only dimming") }; +static const char *mode_icon_name[BLANKING_MODES] = +{ + "display-blanking-icon.0", + "display-blanking-icon.1", + "display-blanking-icon.2", + "display-blanking-icon.3", + "display-blanking-icon.4", +}; struct _DisplayBlankingStatusPluginPrivate { @@ -116,17 +123,10 @@ display_blanking_status_plugin_class_init (DisplayBlankingStatusPluginClass *c) static void update_gui (DisplayBlankingStatusPluginPrivate *priv) { - // Should be enough if BLANKING_MODES stays in 1 digit, "%d" - // provides space for that digit and '\0' - static char icon_name[sizeof (ICON_TEMPLATE)]; - - // Update button text and status bar icon gint mode = priv->blanking_mode; hildon_button_set_value (HILDON_BUTTON (priv->button), dgettext (GETTEXT_DOM, _DisplayBlankingDescription[mode])); - int r = snprintf (icon_name, sizeof (icon_name), ICON_TEMPLATE, mode); - g_assert (r < sizeof (icon_name)); // otherwise it was truncated - GtkWidget *icon = gtk_image_new_from_icon_name (icon_name, + GtkWidget *icon = gtk_image_new_from_icon_name (mode_icon_name[mode], GTK_ICON_SIZE_DIALOG); hildon_button_set_image (HILDON_BUTTON (priv->button), icon); } -- 2.43.0