+
+ wxString label(lbl);
+
+ if (label.empty() && wxIsStockID(m_windowId))
+ label = wxGetStockLabel(m_windowId);
+
+ wxAnyButton::SetLabel(label);
+
+ // don't use label if it was explicitly disabled
+ if ( HasFlag(wxBU_NOTEXT) )
+ return;
+
+ if (wxIsStockID(m_windowId) && wxIsStockLabel(m_windowId, label))
+ {
+ const char *stock = wxGetStockGtkID(m_windowId);
+ if (stock)
+ {
+ gtk_button_set_label(GTK_BUTTON(m_widget), stock);
+ gtk_button_set_use_stock(GTK_BUTTON(m_widget), TRUE);
+ return;
+ }
+ }
+
+ // this call is necessary if the button had been initially created without
+ // a (text) label -- then we didn't use gtk_button_new_with_mnemonic() and
+ // so "use-underline" GtkButton property remained unset
+ gtk_button_set_use_underline(GTK_BUTTON(m_widget), TRUE);
+ const wxString labelGTK = GTKConvertMnemonics(label);
+ gtk_button_set_label(GTK_BUTTON(m_widget), wxGTK_CONV(labelGTK));
+ gtk_button_set_use_stock(GTK_BUTTON(m_widget), FALSE);
+
+ GTKApplyWidgetStyle( false );
+}
+
+#if wxUSE_MARKUP
+bool wxButton::DoSetLabelMarkup(const wxString& markup)
+{
+ wxCHECK_MSG( m_widget != NULL, false, "invalid button" );
+
+ const wxString stripped = RemoveMarkup(markup);
+ if ( stripped.empty() && !markup.empty() )
+ return false;
+
+ wxControl::SetLabel(stripped);
+
+ GtkLabel * const label = GTKGetLabel();
+ wxCHECK_MSG( label, false, "no label in this button?" );
+
+ GTKSetLabelWithMarkupForLabel(label, markup);
+
+ return true;
+}
+
+GtkLabel *wxButton::GTKGetLabel() const
+{
+ GtkWidget* child = gtk_bin_get_child(GTK_BIN(m_widget));
+ if ( GTK_IS_ALIGNMENT(child) )
+ {
+ GtkWidget* box = gtk_bin_get_child(GTK_BIN(child));
+ GtkLabel* label = NULL;
+ wxGtkList list(gtk_container_get_children(GTK_CONTAINER(box)));
+ for (GList* item = list; item; item = item->next)
+ {
+ if (GTK_IS_LABEL(item->data))
+ label = GTK_LABEL(item->data);
+ }
+
+ return label;
+ }
+
+ return GTK_LABEL(child);