From: Leandro Lucarella Date: Mon, 30 Jul 2012 15:59:30 +0000 (+0200) Subject: Show a status icon when inhibition is enabled X-Git-Tag: v0.9~12 X-Git-Url: https://git.llucax.com/software/sadba.git/commitdiff_plain/b1400db36231485bef300245dcc9947b971595aa Show a status icon when inhibition is enabled --- diff --git a/data/display-blanking-status.png b/data/display-blanking-status.png new file mode 100644 index 0000000..252b352 Binary files /dev/null and b/data/display-blanking-status.png differ diff --git a/debian/install b/debian/install index 8494d44..eba36c4 100644 --- a/debian/install +++ b/debian/install @@ -5,5 +5,6 @@ data/display-blanking-icon.3.png usr/share/icons/hicolor/48x48/hildon data/display-blanking-icon.4.png usr/share/icons/hicolor/48x48/hildon data/display-blanking-inhibit-icon.png usr/share/icons/hicolor/48x48/hildon data/display-blanking-inhibit-icon.timed.png usr/share/icons/hicolor/48x48/hildon +data/display-blanking-status.png usr/share/icons/hicolor/18x18/hildon src/lib-displayblanking-status-menu.so usr/lib/hildon-desktop data/status-area-displayblanking-applet.desktop usr/share/applications/hildon-status-menu diff --git a/src/lib-display-blanking-status-menu-widget.c b/src/lib-display-blanking-status-menu-widget.c index e4f521b..fc02eb2 100644 --- a/src/lib-display-blanking-status-menu-widget.c +++ b/src/lib-display-blanking-status-menu-widget.c @@ -105,9 +105,11 @@ static const char *mode_icon_name[BLANKING_MODES] = }; #define INHIBIT_ICON_NAME "display-blanking-inhibit-icon" #define TIMED_INHIBIT_ICON_NAME "display-blanking-inhibit-icon.timed" +#define INHIBIT_STATUS_ICON_NAME "display-blanking-status" struct _DisplayBlankingStatusPluginPrivate { + DisplayBlankingStatusPlugin* plugin; GConfClient *gconf_client; DBusConnection* dbus_conn; DBusMessage* dbus_msg; @@ -158,6 +160,14 @@ disable_timer (gint *timer_id) *timer_id = 0; } +static void +disable_inhibition (DisplayBlankingStatusPluginPrivate *priv) +{ + disable_timer (&(priv->inhibit_timer_id)); + hd_status_plugin_item_set_status_area_icon ( + HD_STATUS_PLUGIN_ITEM (priv->plugin), NULL); +} + static gboolean on_inhibit_timeout (DisplayBlankingStatusPluginPrivate *priv) { @@ -171,7 +181,7 @@ on_inhibit_timeout (DisplayBlankingStatusPluginPrivate *priv) static gboolean on_timed_inhibit_timeout (DisplayBlankingStatusPluginPrivate *priv) { - disable_timer (&(priv->inhibit_timer_id)); + disable_inhibition (priv); disable_timer (&(priv->timed_inhibit_timer_id)); priv->inhibit_in_signal = TRUE; @@ -188,12 +198,18 @@ on_timed_inhibit_timeout (DisplayBlankingStatusPluginPrivate *priv) } static void -enable_inhibit_timer (DisplayBlankingStatusPluginPrivate *priv) +enable_inhibition (DisplayBlankingStatusPluginPrivate *priv) { g_assert (priv->inhibit_timer_id == 0); priv->inhibit_timer_id = g_timeout_add_seconds (INHIBIT_MSG_INTERVAL, (GSourceFunc) on_inhibit_timeout, priv); g_assert (priv->inhibit_timer_id > 0); + + GtkIconTheme *icon_theme = gtk_icon_theme_get_default (); + GdkPixbuf *pixbuf = gtk_icon_theme_load_icon (icon_theme, + INHIBIT_STATUS_ICON_NAME, 18, GTK_ICON_LOOKUP_NO_SVG, NULL); + hd_status_plugin_item_set_status_area_icon ( + HD_STATUS_PLUGIN_ITEM (priv->plugin), pixbuf); } static void @@ -224,13 +240,13 @@ on_inhibit_button_clicked (GtkWidget *button, else if (self_pressed && !other_pressed) { g_assert (priv->timed_inhibit_timer_id == 0); - enable_inhibit_timer (priv); + enable_inhibition (priv); } else if (!self_pressed) { g_assert (!other_pressed); g_assert (priv->timed_inhibit_timer_id == 0); - disable_timer (&(priv->inhibit_timer_id)); + disable_inhibition (priv); } else g_assert (FALSE); @@ -362,7 +378,7 @@ on_timed_inhibit_button_clicked (GtkWidget *button, priv->inhibit_in_signal = FALSE; } else - enable_inhibit_timer (priv); + enable_inhibition (priv); priv->timed_inhibit_timer_id = g_timeout_add_seconds (timeout, (GSourceFunc) on_timed_inhibit_timeout, priv); @@ -378,7 +394,7 @@ on_timed_inhibit_button_clicked (GtkWidget *button, else { // !self_pressed g_assert (!other_pressed); - disable_timer (&(priv->inhibit_timer_id)); + disable_inhibition (priv); disable_timer (&(priv->timed_inhibit_timer_id)); } } @@ -578,6 +594,7 @@ display_blanking_status_plugin_init (DisplayBlankingStatusPlugin *plugin) priv = DISPLAY_BLANKING_STATUS_PLUGIN_GET_PRIVATE (plugin); plugin->priv = priv; + priv->plugin = plugin; init_gconf (priv); init_dbus (priv);