[pan2] improved gtkstyle handling for progressview



commit 9faef90100579859d6d896fe21ba65a176b47efa
Author: Heinrich MÃller <henmull src gnome org>
Date:   Sun Sep 30 09:14:34 2012 +0200

    improved gtkstyle handling for progressview

 pan/data-impl/download-meter.cc |    3 ++-
 pan/gui/progress-view.cc        |   16 +++++++++++-----
 pan/gui/progress-view.h         |    3 ++-
 3 files changed, 15 insertions(+), 7 deletions(-)
---
diff --git a/pan/data-impl/download-meter.cc b/pan/data-impl/download-meter.cc
index 7962e72..6e1dabf 100644
--- a/pan/data-impl/download-meter.cc
+++ b/pan/data-impl/download-meter.cc
@@ -21,6 +21,7 @@
 #include <pan/data-impl/download-meter.h>
 #include <pan/data-impl/data-impl.h>
 #include <iostream>
+#include <iomanip>
 #include <math.h>
 
 extern "C" {
@@ -102,7 +103,7 @@ namespace
     std::stringstream str;
 
     uint64_t ret = factor == 0ul ? ret : bytes / factor;
-    str << (ret+rest) << " " << mnemonic(cnt);
+    str << std::setprecision (2) << (ret+rest) << " " << mnemonic(cnt);
     return str.str();
   }
 
diff --git a/pan/gui/progress-view.cc b/pan/gui/progress-view.cc
index e6167c3..b7ae8f2 100644
--- a/pan/gui/progress-view.cc
+++ b/pan/gui/progress-view.cc
@@ -32,7 +32,8 @@ ProgressView :: ProgressView ():
   _progress_status_idle_tag (0),
   _root (gtk_event_box_new ()),
   _progressbar (gtk_progress_bar_new ()),
-  _progress (0)
+  _progress (0),
+  _style (gtk_widget_get_style (_progressbar))
 {
   gtk_progress_bar_set_ellipsize (GTK_PROGRESS_BAR(_progressbar), PANGO_ELLIPSIZE_MIDDLE);
   gtk_container_add (GTK_CONTAINER(_root), _progressbar);
@@ -42,6 +43,12 @@ ProgressView :: ProgressView ():
 #endif
 }
 
+ProgressView :: ~ProgressView ()
+{
+   set_progress(0);
+   g_object_unref (_style);
+}
+
 void
 ProgressView :: set_progress (Progress * progress)
 {
@@ -132,7 +139,8 @@ ProgressView :: update_text_soon ()
 
 void ProgressView :: set_color (const std::string& color)
 {
-  GtkStyle* style = gtk_style_new ();
+  GtkStyle* style = gtk_style_copy (_style);
+
   gdk_color_parse (color.c_str(), &style->bg[GTK_STATE_PRELIGHT]);
   gtk_widget_set_style (_progressbar, style);
   g_object_unref (style);
@@ -141,7 +149,5 @@ void ProgressView :: set_color (const std::string& color)
 
 void ProgressView :: reset_color ()
 {
-  GtkStyle* style = gtk_style_new ();
-  gtk_widget_set_style (_progressbar, style);
-  g_object_unref (style);
+    gtk_widget_set_style (_progressbar, NULL);
 }
diff --git a/pan/gui/progress-view.h b/pan/gui/progress-view.h
index e0debbb..be4cd38 100644
--- a/pan/gui/progress-view.h
+++ b/pan/gui/progress-view.h
@@ -38,7 +38,7 @@ namespace pan
   {
     public:
       ProgressView ();
-      virtual ~ProgressView () { set_progress(0); }
+      virtual ~ProgressView () ;
       GtkWidget* root () { return _root; }
       void set_progress (Progress *);
       Progress* get_progress () { return _progress; }
@@ -63,6 +63,7 @@ namespace pan
     private:
       GtkWidget * _root;
       GtkWidget * _progressbar;
+      GtkStyle * _style;
       std::string _last_status;
       Progress * _progress;
 



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