[gnome-control-center/wip/power: 3/9] Make 'Screen Power Saving' just a switch



commit 4aa8454a7103488d47f14f5a91119ff465ccda51
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Dec 1 11:59:51 2012 -0500

    Make 'Screen Power Saving' just a switch
    
    The 'smart' behaviour still has to be implemented, for now this
    just sets idle-dim-battery.

 panels/power/cc-power-panel.c |   63 +++-------------
 panels/power/power.ui         |  162 -----------------------------------------
 2 files changed, 11 insertions(+), 214 deletions(-)
---
diff --git a/panels/power/cc-power-panel.c b/panels/power/cc-power-panel.c
index 2d13b8e..2849930 100644
--- a/panels/power/cc-power-panel.c
+++ b/panels/power/cc-power-panel.c
@@ -25,7 +25,7 @@
 #include <libupower-glib/upower.h>
 #include <glib/gi18n.h>
 #include <gnome-settings-daemon/gsd-enums.h>
-#include "egg-list-box.h"
+#include "egg-list-box/egg-list-box.h"
 
 #include "cc-power-panel.h"
 
@@ -1174,33 +1174,6 @@ activate_child (CcPowerPanel *self,
   gtk_window_present (GTK_WINDOW (w));
 }
 
-static gboolean
-on_off_label_mapping_get (GValue   *value,
-                          GVariant *variant,
-                          gpointer  user_data)
-{
-  g_value_set_string (value, g_variant_get_boolean (variant) ? _("On") : _("Off"));
-
-  return TRUE;
-}
-
-static GtkWidget *
-get_on_off_label (GSettings   *settings,
-                  const gchar *key)
-{
-  GtkWidget *w;
-
-  w = gtk_label_new ("");
-  g_settings_bind_with_mapping (settings, key,
-                                w, "label",
-                                G_SETTINGS_BIND_GET,
-                                on_off_label_mapping_get,
-                                NULL,
-                                NULL,
-                                NULL);
-  return w;
-}
-
 static void
 set_idle_delay_from_dpms (CcPowerPanel *self,
                           int           value)
@@ -1286,7 +1259,7 @@ add_power_saving_section (CcPowerPanel *self)
 {
   GtkWidget *vbox;
   GtkWidget *widget, *box, *label, *scale;
-  GtkWidget *dialog;
+  GtkWidget *sw;
   gchar *s;
 
   vbox = WID (self->priv->builder, "vbox_power");
@@ -1349,32 +1322,18 @@ add_power_saving_section (CcPowerPanel *self)
   gtk_widget_set_margin_bottom (label, 6);
   gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0);
 
-  label = get_on_off_label (self->priv->gsd_settings, "idle-dim-battery");
-  gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
-  gtk_widget_set_margin_left (label, 12);
-  gtk_widget_set_margin_right (label, 12);
-  gtk_box_pack_start (GTK_BOX (box), label, FALSE, TRUE, 0);
-
-  gtk_container_add (GTK_CONTAINER (widget), box);
-  self->priv->screen_power_saving = box;
-
-  gtk_widget_show_all (widget);
-
-  dialog = WID (self->priv->builder, "screen_power_saving_dialog");
-  widget = WID (self->priv->builder, "power_saving_done");
-  g_signal_connect_swapped (widget, "clicked",
-                            G_CALLBACK (gtk_widget_hide), dialog);
-
-  widget = WID (self->priv->builder, "dim_screen_check");
+  /* FIXME: implement and use a screen-power-saving setting */
+  sw = gtk_switch_new ();
   g_settings_bind (self->priv->gsd_settings, "idle-dim-battery",
-                   widget, "active",
+                   sw, "active",
                    G_SETTINGS_BIND_DEFAULT);
+  gtk_widget_set_margin_left (sw, 12);
+  gtk_widget_set_margin_right (sw, 12);
+  gtk_box_pack_start (GTK_BOX (box), sw, FALSE, TRUE, 0);
+  gtk_label_set_mnemonic_widget (GTK_LABEL (label), sw);
+  gtk_container_add (GTK_CONTAINER (widget), box);
 
-  widget = WID (self->priv->builder, "turn_off_combo");
-  set_dpms_value_for_combo (GTK_COMBO_BOX (widget), self);
-  g_signal_connect (widget, "changed",
-                    G_CALLBACK (dpms_combo_changed_cb),
-                    self);
+  gtk_widget_show_all (widget);
 }
 
 static void
diff --git a/panels/power/power.ui b/panels/power/power.ui
index 1554cdb..3e7b269 100644
--- a/panels/power/power.ui
+++ b/panels/power/power.ui
@@ -357,166 +357,4 @@
       <widget name="combobox_sleep_ac"/>
     </widgets>
   </object>
-  <object class="GtkListStore" id="screen_brightness_liststore">
-    <columns>
-      <!-- column-name name -->
-      <column type="gchararray"/>
-      <!-- column-name value -->
-      <column type="gint"/>
-    </columns>
-    <data>
-      <row>
-        <col id="0" translatable="yes">1 minute</col>
-        <col id="1">60</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">2 minutes</col>
-        <col id="1">120</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">3 minutes</col>
-        <col id="1">180</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">5 minutes</col>
-        <col id="1">300</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">10 minutes</col>
-        <col id="1">600</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">30 minutes</col>
-        <col id="1">1800</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">1 hour</col>
-        <col id="1">3600</col>
-      </row>
-    </data>
-  </object>
-  <object class="GtkDialog" id="screen_power_saving_dialog">
-    <property name="can_focus">False</property>
-    <property name="border_width">5</property>
-    <property name="type_hint">dialog</property>
-    <property name="title" translatable="yes">Screen Power Saving</property>
-    <child internal-child="vbox">
-      <object class="GtkBox" id="dialog-vbox1">
-        <property name="can_focus">False</property>
-        <property name="orientation">vertical</property>
-        <property name="spacing">2</property>
-        <child internal-child="action_area">
-          <object class="GtkButtonBox" id="dialog-action_area1">
-            <property name="can_focus">False</property>
-            <property name="layout_style">end</property>
-            <child>
-              <object class="GtkButton" id="power_saving_done">
-                <property name="label" translatable="yes">_Done</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="has_default">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_underline">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">True</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="pack_type">end</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkLabel" id="label22">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="margin_left">12</property>
-            <property name="margin_right">12</property>
-            <property name="margin_top">12</property>
-            <property name="margin_bottom">12</property>
-            <property name="xalign">0</property>
-            <property name="label" translatable="yes">Dimming the screen saves a lot of power.</property>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="position">1</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkGrid" id="grid1">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="margin_left">12</property>
-            <property name="margin_right">6</property>
-            <property name="margin_bottom">18</property>
-            <property name="row_spacing">12</property>
-            <property name="column_spacing">6</property>
-            <child>
-              <object class="GtkCheckButton" id="dim_screen_check">
-                <property name="label" translatable="yes">Dim screen to _save power</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">False</property>
-                <property name="use_underline">True</property>
-                <property name="xalign">0</property>
-                <property name="draw_indicator">True</property>
-              </object>
-              <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">0</property>
-                <property name="width">2</property>
-                <property name="height">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="turn_off_label">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="label" translatable="yes">_Turn screen off when inactive for</property>
-                <property name="use_underline">True</property>
-                <property name="mnemonic_widget">turn_off_combo</property>
-              </object>
-              <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">1</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkComboBoxText" id="turn_off_combo">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="hexpand">True</property>
-                <property name="entry_text_column">0</property>
-                <property name="model">screen_brightness_liststore</property>
-              </object>
-              <packing>
-                <property name="left_attach">1</property>
-                <property name="top_attach">1</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="position">2</property>
-          </packing>
-        </child>
-      </object>
-    </child>
-    <action-widgets>
-      <action-widget response="0">power_saving_done</action-widget>
-    </action-widgets>
-  </object>
 </interface>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]