~vaifrax/inkscape/bugfix170049

« back to all changes in this revision

Viewing changes to src/widgets/shrink-wrap-button.cpp

  • Committer: mental
  • Date: 2006-01-16 02:36:01 UTC
  • Revision ID: mental@users.sourceforge.net-20060116023601-wkr0h7edl5veyudq
moving trunk for module inkscape

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 */
 
11
 
 
12
#include <gtkmm/button.h>
 
13
#include <gtk/gtkbin.h>
 
14
 
 
15
namespace Inkscape {
 
16
namespace Widgets {
 
17
 
 
18
namespace {
 
19
 
 
20
void minimum_size(GtkWidget *widget, GtkRequisition *requisition, void *) {
 
21
    GtkWidget *child(gtk_bin_get_child(GTK_BIN(widget)));
 
22
 
 
23
    if (child) {
 
24
        gtk_widget_size_request(child, requisition);
 
25
    } else {
 
26
        requisition->width = 0;
 
27
        requisition->height = 0;
 
28
    }
 
29
 
 
30
    requisition->width += 2 + 2 * std::max(2, widget->style->xthickness);
 
31
    requisition->height += 2 + 2 * std::max(2, widget->style->ythickness);
 
32
}
 
33
 
 
34
}
 
35
 
 
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
}
 
42
 
 
43
}
 
44
}
 
45
 
 
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:encoding=utf-8:textwidth=99 :