#define HOURS_GCONF_KEY "/apps/Maemo/sadba/timed_inhibit_hours"
#define MINUTES_GCONF_KEY "/apps/Maemo/sadba/timed_inhibit_minutes"
+#define BANNER_DURATION 5000 // in milliseconds
#define INHIBIT_MSG_INTERVAL 30 // in seconds
#define GETTEXT_DOM "status-area-displayblanking-applet"
+#define _(str) dgettext (GETTEXT_DOM, (str))
#define gettext_noop(str) (str)
+#define N_(str) gettext_noop(str)
// Undocumented blanking modes as reported by David Weinehall from Nokia:
// http://www.gossamer-threads.com/lists/maemo/developers/61201#61201
#define BLANKING_MODES 5
-static const char *_DisplayBlankingDescription[BLANKING_MODES] =
+static const char *mode_title[BLANKING_MODES] =
{
- gettext_noop ("Both enabled"),
- gettext_noop ("Both only on battery"),
- gettext_noop ("Blanking only on battery"),
- gettext_noop ("Both disabled"),
- gettext_noop ("Only dimming")
+ N_ ("Both enabled"),
+ N_ ("Both only on battery"),
+ N_ ("Blanking only on battery"),
+ N_ ("Both disabled"),
+ N_ ("Only dimming")
+};
+static const char *mode_desc[BLANKING_MODES] =
+{
+ N_ ("Blanking and dimming always enabled"),
+ N_ ("Blanking and dimming enabled only on battery"),
+ N_ ("Always dim, blank only on battery"),
+ N_ ("Blanking and dimming always disabled"),
+ N_ ("Blanking disabled, dimming enabled")
};
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;
*timer_id = 0;
}
-static gboolean
-on_inhibit_timeout (DisplayBlankingStatusPluginPrivate *priv)
+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 void
+inhibit_display_blanking (DisplayBlankingStatusPluginPrivate *priv)
{
dbus_bool_t ok = dbus_connection_send (priv->dbus_conn, priv->dbus_msg,
NULL);
g_assert (ok == TRUE);
+}
+
+static gboolean
+on_inhibit_timeout (DisplayBlankingStatusPluginPrivate *priv)
+{
+ inhibit_display_blanking (priv);
return TRUE;
}
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;
GtkWidget *banner = hildon_banner_show_information (
priv->timed_inhibit_button, NULL,
- dgettext (GETTEXT_DOM, "Display blanking inhibition disabled"));
- hildon_banner_set_timeout (HILDON_BANNER (banner), 5000);
+ _ ("Display blanking inhibition disabled"));
+ hildon_banner_set_timeout (HILDON_BANNER (banner), BANNER_DURATION);
return FALSE;
}
static void
-enable_inhibit_timer (DisplayBlankingStatusPluginPrivate *priv)
+enable_inhibition (DisplayBlankingStatusPluginPrivate *priv)
{
+ inhibit_display_blanking (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
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);
{
g_assert (priv->timed_inhibit_dialog == NULL);
priv->timed_inhibit_dialog = gtk_dialog_new_with_buttons (
- dgettext (GETTEXT_DOM, "Inhibit display blanking for..."), NULL,
- GTK_DIALOG_MODAL, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
+ _ ("Inhibit display blanking for..."), NULL, GTK_DIALOG_MODAL,
+ GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL);
- GtkWidget *h_picker = timed_inhibit_picker_new (
- dgettext (GETTEXT_DOM, "Hours"),
+ GtkWidget *h_picker = timed_inhibit_picker_new (_ ("Hours"),
gconf_client_get_int (priv->gconf_client, HOURS_GCONF_KEY, NULL),
24, 1);
- GtkWidget *m_picker = timed_inhibit_picker_new (
- dgettext (GETTEXT_DOM, "Minutes"),
+ GtkWidget *m_picker = timed_inhibit_picker_new (_ ("Minutes"),
gconf_client_get_int (priv->gconf_client, MINUTES_GCONF_KEY, NULL),
60, 10);
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);
else { // !self_pressed
g_assert (!other_pressed);
- disable_timer (&(priv->inhibit_timer_id));
+ disable_inhibition (priv);
disable_timer (&(priv->timed_inhibit_timer_id));
}
}
{
const gchar *title = hildon_button_get_title (HILDON_BUTTON (button));
- gint *mode = (gint *) g_object_get_data (G_OBJECT(dialog), "mode");
+ gint *mode = (gint *) g_object_get_data (G_OBJECT (dialog), "mode");
g_assert (mode != NULL);
for (*mode = 0; *mode < BLANKING_MODES; (*mode)++) {
- if (strcmp (title, _DisplayBlankingDescription[*mode]) == 0)
+ if (strcmp (title, mode_title[*mode]) == 0)
break;
}
g_assert (*mode < BLANKING_MODES);
priv->mode_dialog = gtk_dialog_new ();
gtk_window_set_modal (GTK_WINDOW (priv->mode_dialog), TRUE);
gtk_window_set_title (GTK_WINDOW (priv->mode_dialog),
- dgettext (GETTEXT_DOM, "Select display blanking mode"));
+ _ ("Select display blanking mode"));
GtkWidget *pan_area = hildon_pannable_area_new ();
g_assert (pan_area != NULL);
for (int i = 0; i < BLANKING_MODES; i++) {
GtkWidget *button =
hildon_button_new_with_text (HILDON_SIZE_FINGER_HEIGHT,
- HILDON_BUTTON_ARRANGEMENT_VERTICAL,
- dgettext (GETTEXT_DOM, (_DisplayBlankingDescription[i])),
- NULL);
+ HILDON_BUTTON_ARRANGEMENT_VERTICAL, _ (mode_title[i]),
+ _ (mode_desc[i]));
hildon_button_set_style (HILDON_BUTTON (button),
HILDON_BUTTON_STYLE_PICKER);
GtkWidget *icon = gtk_image_new_from_icon_name (mode_icon_name[i],
GtkWidget *b = hildon_gtk_toggle_button_new (HILDON_SIZE_FINGER_HEIGHT |
HILDON_SIZE_AUTO_WIDTH);
- gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON(b), FALSE);
+ gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (b), FALSE);
GtkWidget *icon = gtk_image_new_from_icon_name (icon_name,
GTK_ICON_SIZE_DIALOG);
gtk_button_set_image (GTK_BUTTON (b), icon);
priv = DISPLAY_BLANKING_STATUS_PLUGIN_GET_PRIVATE (plugin);
plugin->priv = priv;
+ priv->plugin = plugin;
init_gconf (priv);
init_dbus (priv);