[gnome-control-center] power: port to GtkLevelBar



commit b05591b1654c391f6d4aa113525b70ca736f68a0
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Mon Jun 11 09:56:49 2012 -0400

    power: port to GtkLevelBar
    
    https://bugzilla.gnome.org/show_bug.cgi?id=679984

 panels/power/cc-power-panel.c |   32 ++++++++++----------------------
 panels/power/power.ui         |    4 ++--
 2 files changed, 12 insertions(+), 24 deletions(-)
---
diff --git a/panels/power/cc-power-panel.c b/panels/power/cc-power-panel.c
index ec0eb16..e69f812 100644
--- a/panels/power/cc-power-panel.c
+++ b/panels/power/cc-power-panel.c
@@ -27,7 +27,6 @@
 #include <gnome-settings-daemon/gsd-enums.h>
 
 #include "cc-power-panel.h"
-#include "cc-strength-bar.h"
 
 #define WID(b, w) (GtkWidget *) gtk_builder_get_object (b, w)
 
@@ -44,7 +43,7 @@ struct _CcPowerPanelPrivate
   GtkBuilder    *builder;
   GDBusProxy    *proxy;
   UpClient      *up_client;
-  CcStrengthBar *progressbar_primary;
+  GtkWidget     *levelbar_primary;
 };
 
 enum
@@ -222,8 +221,8 @@ set_device_battery_primary (CcPowerPanel *panel, GVariant *device)
                  &time);
 
   /* set the percentage */
-  cc_strength_bar_set_fraction (priv->progressbar_primary,
-                                percentage / 100.0f);
+  gtk_level_bar_set_value (GTK_LEVEL_BAR (priv->levelbar_primary),
+                           percentage / 100.0f);
 
   /* clear the warning */
   widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
@@ -335,8 +334,8 @@ set_device_ups_primary (CcPowerPanel *panel, GVariant *device)
                  &time);
 
   /* set the percentage */
-  cc_strength_bar_set_fraction (priv->progressbar_primary,
-                                percentage / 100.0f);
+  gtk_level_bar_set_value (GTK_LEVEL_BAR (priv->levelbar_primary),
+                           percentage / 100.0f);
 
   /* always show the warning */
   widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
@@ -615,10 +614,10 @@ add_device_secondary (CcPowerPanel *panel,
   gtk_misc_set_alignment (GTK_MISC (widget), 0.0f, 0.5f);
   gtk_label_set_markup (GTK_LABEL (widget), status->str);
   gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);
-  widget = cc_strength_bar_new ();
+  widget = gtk_level_bar_new ();
   gtk_widget_set_margin_right (widget, 32);
   gtk_widget_set_margin_top (widget, 3);
-  cc_strength_bar_set_fraction (CC_STRENGTH_BAR (widget), percentage / 100.0f);
+  gtk_level_bar_set_value (GTK_LEVEL_BAR (widget), percentage / 100.0f);
   gtk_box_pack_start (GTK_BOX (vbox), widget, TRUE, TRUE, 0);
   gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
 
@@ -1009,20 +1008,9 @@ cc_power_panel_init (CcPowerPanel *self)
       return;
     }
 
-  /* add custom progressbar */
-  widget = GTK_WIDGET (gtk_builder_get_object (self->priv->builder,
-                                               "progressbar_primary"));
-  gtk_widget_hide (widget);
-  self->priv->progressbar_primary = CC_STRENGTH_BAR (cc_strength_bar_new ());
-  widget = GTK_WIDGET (gtk_builder_get_object (self->priv->builder,
-                                               "box_primary"));
-  gtk_box_pack_end (GTK_BOX (widget),
-                    GTK_WIDGET (self->priv->progressbar_primary),
-                    FALSE,
-                    TRUE,
-                    0);
-  gtk_widget_set_visible (GTK_WIDGET (self->priv->progressbar_primary), TRUE);
-
+  /* add levelbar */
+  self->priv->levelbar_primary = GTK_WIDGET
+    (gtk_builder_get_object (self->priv->builder, "levelbar_primary"));
   self->priv->cancellable = g_cancellable_new ();
 
   /* get initial icon state */
diff --git a/panels/power/power.ui b/panels/power/power.ui
index 97413d1..3e7b269 100644
--- a/panels/power/power.ui
+++ b/panels/power/power.ui
@@ -263,9 +263,9 @@
               </packing>
             </child>
             <child>
-              <object class="GtkProgressBar" id="progressbar_primary">
+              <object class="GtkLevelBar" id="levelbar_primary">
                 <property name="can_focus">False</property>
-                <property name="fraction">0.5</property>
+                <property name="visible">True</property>
               </object>
               <packing>
                 <property name="expand">False</property>



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