- m_needParent = TRUE;
- m_acceptsFocus = TRUE;
-
- PreCreation( parent, id, pos, size, style, name );
-
- SetValidator( validator );
-
- m_oldPos = 0.0;
-
- if (style & wxSB_VERTICAL == wxSB_VERTICAL)
- m_widget = gtk_hscrollbar_new( (GtkAdjustment *) NULL );
- else
- m_widget = gtk_vscrollbar_new( (GtkAdjustment *) NULL );
-
- m_adjust = gtk_range_get_adjustment( GTK_RANGE(m_widget) );
-
- gtk_signal_connect( GTK_OBJECT(m_adjust),
- "value_changed",
- (GtkSignalFunc) gtk_scrollbar_callback,
- (gpointer) this );
-
- gtk_signal_connect( GTK_OBJECT(m_widget),
- "button_press_event",
- (GtkSignalFunc)gtk_scrollbar_button_press_callback,
- (gpointer) this );
-
- gtk_signal_connect( GTK_OBJECT(m_widget),
- "button_release_event",
- (GtkSignalFunc)gtk_scrollbar_button_release_callback,
- (gpointer) this );
-
- m_parent->AddChild( this );
-
- (m_parent->m_insertCallback)( m_parent, this );
-
- PostCreation();
-
- SetBackgroundColour( parent->GetBackgroundColour() );
-
- Show( TRUE );
-
- return TRUE;
+ if (!PreCreation( parent, pos, size ) ||
+ !CreateBase( parent, id, pos, size, style, validator, name ))
+ {
+ wxFAIL_MSG( wxT("wxScrollBar creation failed") );
+ return false;
+ }
+
+ const bool isVertical = (style & wxSB_VERTICAL) != 0;
+ m_widget = gtk_scrollbar_new(GtkOrientation(isVertical), NULL);
+ g_object_ref(m_widget);
+
+ m_scrollBar[0] = (GtkRange*)m_widget;
+
+ g_signal_connect_after(m_widget, "value_changed",
+ G_CALLBACK(gtk_value_changed), this);
+ g_signal_connect(m_widget, "button_press_event",
+ G_CALLBACK(gtk_button_press_event), this);
+ g_signal_connect(m_widget, "button_release_event",
+ G_CALLBACK(gtk_button_release_event), this);
+
+ gulong handler_id;
+ handler_id = g_signal_connect(
+ m_widget, "event_after", G_CALLBACK(gtk_event_after), this);
+ g_signal_handler_block(m_widget, handler_id);
+
+ m_parent->DoAddChild( this );
+
+ PostCreation(size);
+
+ return true;