Code

Use subdirectories with icon sizes.
[inkscape.git] / src / widgets / shrink-wrap-button.cpp
1 /*
2  * Inkscape::Widgets::shrink_wrap_button - shrink a button to minimum size
3  *
4  * Authors:
5  *   MenTaLguY <mental@rydia.net>
6  *
7  * Copyright (C) 2004 MenTaLguY
8  *
9  * Released under GNU GPL, read the file 'COPYING' for more information
10  */
12 #include <gtkmm/button.h>
13 #include <gtk/gtkbin.h>
15 namespace Inkscape {
16 namespace Widgets {
18 namespace {
20 void minimum_size(GtkWidget *widget, GtkRequisition *requisition, void *) {
21     GtkWidget *child(gtk_bin_get_child(GTK_BIN(widget)));
23     if (child) {
24         gtk_widget_size_request(child, requisition);
25     } else {
26         requisition->width = 0;
27         requisition->height = 0;
28     }
30     requisition->width += 2 + 2 * std::max(2, widget->style->xthickness);
31     requisition->height += 2 + 2 * std::max(2, widget->style->ythickness);
32 }
34 }
36 void shrink_wrap_button(Gtk::Button &button) {
37     button.set_border_width(0);
38     button.unset_flags(Gtk::CAN_FOCUS | Gtk::CAN_DEFAULT);
39     g_signal_connect_after(G_OBJECT(button.gobj()), "size_request",
40                            G_CALLBACK(minimum_size), NULL);
41 }
43 }
44 }
46 /*
47   Local Variables:
48   mode:c++
49   c-file-style:"stroustrup"
50   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
51   indent-tabs-mode:nil
52   fill-column:99
53   End:
54 */
55 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :