]> git.saurik.com Git - wxWidgets.git/commitdiff
block signal handlers, instead of disconnecting, to temporarily disable them
authorPaul Cornett <paulcor@bullseye.com>
Wed, 27 Jun 2007 17:38:13 +0000 (17:38 +0000)
committerPaul Cornett <paulcor@bullseye.com>
Wed, 27 Jun 2007 17:38:13 +0000 (17:38 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@46982 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/gtk/combobox.cpp
src/gtk/notebook.cpp
src/gtk/radiobox.cpp
src/gtk/scrolbar.cpp
src/gtk/textctrl.cpp
src/gtk/window.cpp

index b1bed06a0136f122202a7945b68fd5bab34e3f40..56acb506408c11545cf31dde107ab14020a948ab 100644 (file)
@@ -132,12 +132,12 @@ gtkcombo_combo_select_child_callback( GtkList *WXUNUSED(list), GtkWidget *WXUNUS
     // Quickly set the value of the combo box
     // as GTK+ does that only AFTER the event
     // is sent.
-    g_signal_handlers_disconnect_by_func (GTK_COMBO (combo->GetHandle())->entry,
-                                          (gpointer) gtkcombo_text_changed_callback,
-                                          combo);
+    GtkWidget* entry = GTK_COMBO(combo->GetHandle())->entry;
+    g_signal_handlers_block_by_func(
+        entry, (gpointer)gtkcombo_text_changed_callback, combo);
     combo->SetValue( combo->GetStringSelection() );
-    g_signal_connect_after (GTK_COMBO (combo->GetHandle())->entry, "changed",
-                            G_CALLBACK (gtkcombo_text_changed_callback), combo);
+    g_signal_handlers_unblock_by_func(
+        entry, (gpointer)gtkcombo_text_changed_callback, combo);
 
     // throw a SELECTED event only if the combobox popup is hidden (wxID_NONE)
     // because when combobox popup is shown, gtkcombo_combo_select_child_callback is
@@ -1214,20 +1214,20 @@ void wxComboBox::DisableEvents()
 #ifdef __WXGTK24__
     if (!gtk_check_version(2,4,0))
     {
-        g_signal_handlers_disconnect_by_func (GTK_BIN(m_widget)->child,
-                (gpointer)gtkcombobox_text_changed_callback, this);
+        g_signal_handlers_block_by_func(GTK_BIN(m_widget)->child,
+            (gpointer)gtkcombobox_text_changed_callback, this);
 
-        g_signal_handlers_disconnect_by_func (m_widget,
-                (gpointer)gtkcombobox_changed_callback, this);
+        g_signal_handlers_block_by_func(m_widget,
+            (gpointer)gtkcombobox_changed_callback, this);
     }
     else
 #endif
     {
-        g_signal_handlers_disconnect_by_func (GTK_COMBO(m_widget)->list,
-                (gpointer) gtkcombo_combo_select_child_callback, this);
+        g_signal_handlers_block_by_func(GTK_COMBO(m_widget)->list,
+            (gpointer) gtkcombo_combo_select_child_callback, this);
 
-        g_signal_handlers_disconnect_by_func (GTK_COMBO(m_widget)->entry,
-                (gpointer) gtkcombo_text_changed_callback, this);
+        g_signal_handlers_block_by_func(GTK_COMBO(m_widget)->entry,
+            (gpointer) gtkcombo_text_changed_callback, this);
     }
 }
 
@@ -1236,21 +1236,20 @@ void wxComboBox::EnableEvents()
 #ifdef __WXGTK24__
     if (!gtk_check_version(2,4,0))
     {
-        g_signal_connect_after (GTK_BIN(m_widget)->child, "changed",
-                            G_CALLBACK (gtkcombobox_text_changed_callback), this);
+        g_signal_handlers_unblock_by_func(GTK_BIN(m_widget)->child,
+            (gpointer)gtkcombobox_text_changed_callback, this);
 
-        g_signal_connect_after (m_widget, "changed",
-                            G_CALLBACK (gtkcombobox_changed_callback), this);
+        g_signal_handlers_unblock_by_func(m_widget,
+            (gpointer)gtkcombobox_changed_callback, this);
     }
     else
 #endif
     {
-        g_signal_connect_after (GTK_COMBO(m_widget)->list, "select-child",
-                            G_CALLBACK (gtkcombo_combo_select_child_callback),
-                            this);
-        g_signal_connect_after (GTK_COMBO(m_widget)->entry, "changed",
-                            G_CALLBACK (gtkcombo_text_changed_callback),
-                            this );
+        g_signal_handlers_unblock_by_func(GTK_COMBO(m_widget)->list,
+            (gpointer) gtkcombo_combo_select_child_callback, this);
+
+        g_signal_handlers_unblock_by_func(GTK_COMBO(m_widget)->entry,
+            (gpointer) gtkcombo_text_changed_callback, this);
     }
 }
 
index be9cc04945a84553a0b6c2b4e66d6de0e9d1992c..c878f8728f9d9aadec9c02c66e10c6147c3d8f36 100644 (file)
@@ -294,26 +294,22 @@ int wxNotebook::DoSetSelection( size_t page, int flags )
 
     if ( !(flags & SetSelection_SendEvent) )
     {
-        g_signal_handlers_disconnect_by_func (m_widget,
-                                             (gpointer) gtk_notebook_page_changing_callback,
-                                             this);
+        g_signal_handlers_block_by_func(m_widget,
+            (gpointer)gtk_notebook_page_changing_callback, this);
 
-        g_signal_handlers_disconnect_by_func (m_widget,
-                                             (gpointer) gtk_notebook_page_changed_callback,
-                                             this);
+        g_signal_handlers_block_by_func(m_widget,
+            (gpointer)gtk_notebook_page_changed_callback, this);
     }
 
     gtk_notebook_set_current_page( GTK_NOTEBOOK(m_widget), page );
 
     if ( !(flags & SetSelection_SendEvent) )
     {
-        // reconnect to signals
+        g_signal_handlers_unblock_by_func(m_widget,
+            (gpointer)gtk_notebook_page_changing_callback, this);
 
-        g_signal_connect (m_widget, "switch_page",
-                          G_CALLBACK (gtk_notebook_page_changing_callback), this);
-
-        g_signal_connect_after (m_widget, "switch_page",
-                      G_CALLBACK (gtk_notebook_page_changed_callback), this);
+        g_signal_handlers_unblock_by_func(m_widget,
+            (gpointer)gtk_notebook_page_changed_callback, this);
     }
 
     wxNotebookPage *client = GetPage(page);
index 1dea75490ea353fe4b01ac1bd529f9f51ae240d9..b54b7ccbc0926ef4d737d7363e46de1d5e81ede8 100644 (file)
@@ -555,9 +555,8 @@ void wxRadioBox::GtkDisableEvents()
     wxRadioBoxButtonsInfoList::compatibility_iterator node = m_buttonsInfo.GetFirst();
     while (node)
     {
-        g_signal_handlers_disconnect_by_func (node->GetData()->button,
-                                              (gpointer) gtk_radiobutton_clicked_callback,
-                                              this);
+        g_signal_handlers_block_by_func(node->GetData()->button,
+            (gpointer)gtk_radiobutton_clicked_callback, this);
 
         node = node->GetNext();
     }
@@ -568,8 +567,8 @@ void wxRadioBox::GtkEnableEvents()
     wxRadioBoxButtonsInfoList::compatibility_iterator node = m_buttonsInfo.GetFirst();
     while (node)
     {
-        g_signal_connect (node->GetData()->button, "clicked",
-                          G_CALLBACK (gtk_radiobutton_clicked_callback), this);
+        g_signal_handlers_unblock_by_func(node->GetData()->button,
+            (gpointer)gtk_radiobutton_clicked_callback, this);
 
         node = node->GetNext();
     }
index 07716cf86a2b8df3d1f85d94eee3759aa967b9aa..dc05a81b0af74e547f3e2440eeb3a6a4fc0c2fea 100644 (file)
@@ -199,13 +199,13 @@ void wxScrollBar::SetThumbPosition( int viewStart )
         m_scrollPos[i] =
         adj->value = viewStart;
         
-        g_signal_handlers_disconnect_by_func( m_widget,
-                              (gpointer)gtk_value_changed, this);
+        g_signal_handlers_block_by_func(m_widget,
+            (gpointer)gtk_value_changed, this);
 
         gtk_adjustment_value_changed(adj);
-        
-        g_signal_connect_after(m_widget, "value_changed",
-                     G_CALLBACK(gtk_value_changed), this);
+
+        g_signal_handlers_unblock_by_func(m_widget,
+            (gpointer)gtk_value_changed, this);
     }
 }
 
index 26e65214afff677e047b6ca62c72d8b063d94d5e..f83398df445e1bb9dbf0b2beef46a246cbd382e2 100644 (file)
@@ -1016,11 +1016,11 @@ void wxTextCtrl::DoSetValue( const wxString &value, int flags )
         return;
     }
 
+    void* blockWidget = IsMultiLine() ? (void*)m_buffer : (void*)m_text;
+    g_signal_handlers_block_by_func(blockWidget,
+        (gpointer)gtk_text_changed_callback, this);
     if ( IsMultiLine() )
     {
-        g_signal_handlers_disconnect_by_func (m_buffer,
-                    (gpointer) gtk_text_changed_callback, this);
-                    
         gtk_text_buffer_set_text( m_buffer, buffer, strlen(buffer) );
                     
         if ( !m_defaultStyle.IsDefault() )
@@ -1030,20 +1030,13 @@ void wxTextCtrl::DoSetValue( const wxString &value, int flags )
             wxGtkTextApplyTagsFromAttr(m_widget, m_buffer, m_defaultStyle,
                                        &start, &end);
         }
-        
-        g_signal_connect (m_buffer, "changed",
-                          G_CALLBACK (gtk_text_changed_callback), this);
     }
     else
     {
-        g_signal_handlers_disconnect_by_func (m_text,
-                          (gpointer) gtk_text_changed_callback, this);
-                          
         gtk_entry_set_text( GTK_ENTRY(m_text), buffer );
-        
-        g_signal_connect (m_text, "changed",
-                          G_CALLBACK (gtk_text_changed_callback), this);
     }
+    g_signal_handlers_unblock_by_func(blockWidget,
+        (gpointer)gtk_text_changed_callback, this);
                     
     // This was added after discussion on the list
     SetInsertionPoint(0);
index 7af19166b5c622eafedb37eb8c958fa33ec9f372..9dcf7a83d85837d2a35fe484a1d15a85d2450662 100644 (file)
@@ -4159,13 +4159,13 @@ void wxWindowGTK::SetScrollPos(int orient, int pos, bool WXUNUSED(refresh))
             pos = 0;
         m_scrollPos[dir] = adj->value = pos;
 
-        g_signal_handlers_disconnect_by_func( m_scrollBar[dir],
-                              (gpointer)gtk_scrollbar_value_changed, this);
+        g_signal_handlers_block_by_func(m_scrollBar[dir],
+            (gpointer)gtk_scrollbar_value_changed, this);
 
         gtk_adjustment_value_changed(adj);
-        
-        g_signal_connect_after(m_scrollBar[dir], "value_changed",
-                               G_CALLBACK(gtk_scrollbar_value_changed), this);
+
+        g_signal_handlers_unblock_by_func(m_scrollBar[dir],
+            (gpointer)gtk_scrollbar_value_changed, this);
     }
 }