diff options
| author | Alex Valavanis <valavanisalex@gmail.com> | 2012-06-11 01:15:14 +0000 |
|---|---|---|
| committer | Alex Valavanis <valavanisalex@gmail.com> | 2012-06-11 01:15:14 +0000 |
| commit | add9001e02f0ae7e917ad0f56532c42297fe555e (patch) | |
| tree | c0632f5784161e9aed5534e35f06a6ca445eed66 /src/widgets/shrink-wrap-button.cpp | |
| parent | Add missing Cairo header (diff) | |
| download | inkscape-add9001e02f0ae7e917ad0f56532c42297fe555e.tar.gz inkscape-add9001e02f0ae7e917ad0f56532c42297fe555e.zip | |
Fix some broken callbacks for Gtk+ 3
(bzr r11486)
Diffstat (limited to 'src/widgets/shrink-wrap-button.cpp')
| -rw-r--r-- | src/widgets/shrink-wrap-button.cpp | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/src/widgets/shrink-wrap-button.cpp b/src/widgets/shrink-wrap-button.cpp index 781e3ede3..fc844f5ec 100644 --- a/src/widgets/shrink-wrap-button.cpp +++ b/src/widgets/shrink-wrap-button.cpp @@ -9,42 +9,43 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#if HAVE_CONFIG_H +#include "config.h" +#endif + #include <gtkmm/button.h> #include <gtk/gtk.h> namespace Inkscape { namespace Widgets { -namespace { +void shrink_wrap_button(Gtk::Button &button) { + button.set_border_width(0); + button.set_can_focus(false); + button.set_can_default(false); -void minimum_size(GtkWidget *widget, GtkRequisition *requisition, void *) { - GtkWidget *child(gtk_bin_get_child(GTK_BIN(widget))); + Gtk::Widget* child = button.get_child(); + Gtk::Requisition req_min; if (child) { -#if GTK_CHECK_VERSION(3,0,0) - gtk_widget_get_preferred_size(child, requisition, NULL); +#if WITH_GTKMM_3_0 + Gtk::Requisition req_nat; + child->get_preferred_size(req_min, req_nat); #else - gtk_widget_size_request(child, requisition); + req_min = child->size_request(); #endif } else { - requisition->width = 0; - requisition->height = 0; + req_min.width = 0; + req_min.height = 0; } - GtkStyle* style = gtk_widget_get_style(widget); - - requisition->width += 2 + 2 * std::max(2, style->xthickness); - requisition->height += 2 + 2 * std::max(2, style->ythickness); -} - -} + // TODO: Use Gtk::StyleContext instead + GtkStyle* style = gtk_widget_get_style(GTK_WIDGET(button.gobj())); + + req_min.width += 2 + 2 * std::max(2, style->xthickness); + req_min.height += 2 + 2 * std::max(2, style->ythickness); -void shrink_wrap_button(Gtk::Button &button) { - button.set_border_width(0); - button.set_can_focus(false); - button.set_can_default(false); - g_signal_connect_after(G_OBJECT(button.gobj()), "size_request", - G_CALLBACK(minimum_size), NULL); + button.set_size_request(req_min.width, req_min.height); } } |
