[ekiga] Fixed terrible bugs in the OptionalButtonsGtk code



commit 2f761b15900da5cfcd7565e2aab82194cf84e16c
Author: Julien Puydt <jpuydt gnome org>
Date:   Sun Jun 7 21:31:07 2009 +0200

    Fixed terrible bugs in the OptionalButtonsGtk code
    
    It wasn't setting nbr_elements correctly, its add_action
    method was populating the "buttons" variable with NULL
    pointer... and it was trying to work with the translated
    action name (not a good idea). It should work now!
---
 lib/engine/gui/gtk-core/optional-buttons-gtk.cpp |   17 +++++++++++------
 lib/engine/gui/gtk-core/optional-buttons-gtk.h   |    3 +--
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/lib/engine/gui/gtk-core/optional-buttons-gtk.cpp b/lib/engine/gui/gtk-core/optional-buttons-gtk.cpp
index 21b152d..8b8be3d 100644
--- a/lib/engine/gui/gtk-core/optional-buttons-gtk.cpp
+++ b/lib/engine/gui/gtk-core/optional-buttons-gtk.cpp
@@ -64,6 +64,10 @@ on_optional_buttons_gtk_clicked (gpointer object,
 
 // here comes the implementation of the public interface :
 
+OptionalButtonsGtk::OptionalButtonsGtk (): nbr_elements(0)
+{
+}
+
 OptionalButtonsGtk::~OptionalButtonsGtk ()
 {
   for (buttons_type::iterator iter = buttons.begin ();
@@ -104,22 +108,23 @@ OptionalButtonsGtk::reset ()
 							   "ekiga-optional-buttons-gtk-helper");
     helper->callback = sigc::slot0<void> ();
   }
+  nbr_elements = 0;
 }
 
 void
-OptionalButtonsGtk::add_action (G_GNUC_UNUSED const std::string icon,
-				const std::string label,
+OptionalButtonsGtk::add_action (const std::string icon,
+				G_GNUC_UNUSED const std::string label,
 				const sigc::slot0<void> callback)
 {
-  GtkButton* button = buttons[label];
+  buttons_type::iterator iter = buttons.find (icon);
 
-  if (button) {
+  if (iter != buttons.end ()) {
 
     struct OptionalButtonsGtkHelper* helper = 
-      (struct OptionalButtonsGtkHelper*)g_object_get_data (G_OBJECT (button),
+      (struct OptionalButtonsGtkHelper*)g_object_get_data (G_OBJECT (iter->second),
 							   "ekiga-optional-buttons-gtk-helper");
     helper->callback = callback;
-    gtk_widget_set_sensitive (GTK_WIDGET (button), TRUE);
+    gtk_widget_set_sensitive (GTK_WIDGET (iter->second), TRUE);
     nbr_elements++;
   }
 }
diff --git a/lib/engine/gui/gtk-core/optional-buttons-gtk.h b/lib/engine/gui/gtk-core/optional-buttons-gtk.h
index d815dfe..834b6a7 100644
--- a/lib/engine/gui/gtk-core/optional-buttons-gtk.h
+++ b/lib/engine/gui/gtk-core/optional-buttons-gtk.h
@@ -85,8 +85,7 @@ class OptionalButtonsGtk: public Ekiga::MenuBuilder
 {
 public:
 
-  OptionalButtonsGtk ()
-  {}
+  OptionalButtonsGtk ();
 
   ~OptionalButtonsGtk ();
 



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