- // Update display blanking mode
- priv->blanking_mode = (priv->blanking_mode + 1) % BLANKING_MODES;
- update_gui (priv);
- gconf_client_set_int (priv->gconf_client, MODE_GCONF_KEY,
- priv->blanking_mode, NULL);
-
- // Show a notification banner (only if updating)
- GtkWidget *banner = hildon_banner_show_informationf (priv->button, NULL,
- dgettext (GETTEXT_DOM, "Changed display blanking mode to: %s"),
- _DisplayBlankingDescription[priv->blanking_mode]);
- hildon_banner_set_timeout (HILDON_BANNER (banner), 5000);
+ const gchar *title = hildon_button_get_title (HILDON_BUTTON (button));
+
+ 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)
+ break;
+ }
+ g_assert (*mode < BLANKING_MODES);
+
+ gtk_dialog_response (dialog, GTK_RESPONSE_OK);
+}
+
+static void
+on_mode_button_clicked (GtkWidget *button,
+ DisplayBlankingStatusPluginPrivate *priv)
+{
+ GtkWidget *parent = gtk_widget_get_ancestor (GTK_WIDGET (priv->mode_button),
+ GTK_TYPE_WINDOW);
+ gtk_widget_hide (parent);
+
+ g_assert (priv->mode_dialog == NULL);
+ 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"));
+
+ GtkWidget *pan_area = hildon_pannable_area_new ();
+ g_assert (pan_area != NULL);
+
+ GtkWidget *vbox = gtk_vbox_new (FALSE, 0);
+ g_assert (vbox != NULL);
+
+ hildon_pannable_area_add_with_viewport (HILDON_PANNABLE_AREA (pan_area),
+ vbox);
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (priv->mode_dialog)->vbox),
+ pan_area, TRUE, TRUE, 0);
+
+ g_object_set (G_OBJECT (pan_area), "height-request",
+ MIN (350, BLANKING_MODES * 70), NULL);
+
+ gint mode = BLANKING_MODES;
+ for (int i = 0; i < BLANKING_MODES; i++) {
+ GtkWidget *button =
+ hildon_button_new_with_text (HILDON_SIZE_FINGER_HEIGHT,
+ HILDON_BUTTON_ARRANGEMENT_VERTICAL,
+ _DisplayBlankingDescription[i], NULL);
+ GtkWidget *icon = gtk_image_new_from_icon_name (mode_icon_name[i],
+ GTK_ICON_SIZE_DIALOG);
+ hildon_button_set_image (HILDON_BUTTON (button), icon);
+ gtk_button_set_alignment (GTK_BUTTON (button), 0.0f, 0.5f);
+ gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
+ g_signal_connect (button, "clicked",
+ G_CALLBACK (on_mode_dialog_button_clicked), priv->mode_dialog);
+ }
+
+ gtk_widget_show_all (priv->mode_dialog);
+
+ g_object_set_data (G_OBJECT (priv->mode_dialog), "mode", &mode);
+ gtk_dialog_run (GTK_DIALOG (priv->mode_dialog));
+
+ if (mode != BLANKING_MODES) {
+ // will trigger the gconf notify signal
+ GError *error = NULL;
+ gconf_client_set_int (priv->gconf_client, MODE_GCONF_KEY, mode, &error);
+ g_assert (error == NULL);
+ }
+
+ gtk_widget_destroy (priv->mode_dialog);
+ priv->mode_dialog = NULL;