示例#1
0
static VALUE
rg_get_row_spacing(VALUE self, VALUE row)
{
    return UINT2NUM(gtk_table_get_row_spacing(_SELF(self), NUM2UINT(row)));
}
示例#2
0
/* Make the size of dialogs smaller by breaking GNOME HIG
 * http://library.gnome.org/devel/hig-book/stable/design-window.html.en
 * According to GNOME HIG, spacings are increased by the multiples of 6.
 * Change them to the multiples of 1 can greatly reduce the required size
 * while still keeping some degree of spacing.
 */
static void break_gnome_hig( GtkWidget* w, gpointer _factor )
{
    int factor = GPOINTER_TO_INT(_factor);

    /* g_debug( G_OBJECT_TYPE_NAME(w) ); */
    if( GTK_IS_CONTAINER(w) )
    {
        int val;
        val = gtk_container_get_border_width( (GtkContainer*)w );

        /* border of dialog defaults to 12 under gnome */
        if( GTK_IS_DIALOG(w) )
        {
            if( val > 0 )
                gtk_container_set_border_width( (GtkContainer*)w, val / factor );
        }
        else
        {
            if( GTK_IS_BOX(w) ) /* boxes, spacing defaults to 6, 12, 18 under gnome */
            {
                int spacing = gtk_box_get_spacing( (GtkBox*)w );
                gtk_box_set_spacing( (GtkBox*)w, spacing / factor );
            }
            else if( GTK_IS_TABLE(w) ) /* tables, spacing defaults to 6, 12, 18 under gnome */
            {
                int spacing;
                int col, row;
                g_object_get( w, "n-columns", &col, "n-rows", &row, NULL );
                if( col > 1 )
                {
                    --col;
                    while( --col >= 0 )
                    {
                        spacing = gtk_table_get_col_spacing( (GtkTable*)w, col );
                        if( spacing > 0 )
                            gtk_table_set_col_spacing( (GtkTable*)w, col, spacing / factor );
                    }
                }
                if( row > 1 )
                {
                    --row;
                    while( --row >= 0 )
                    {
                        spacing = gtk_table_get_row_spacing( (GtkTable*)w, row );
                        if( spacing > 0 )
                            gtk_table_set_row_spacing( (GtkTable*)w, row, spacing / factor );
                    }
                }
                /* FIXME: handle default spacings */
            }
            else if( GTK_IS_ALIGNMENT(w) ) /* groups, has 12 px indent by default */
            {
                int t, b, l, r;
                gtk_alignment_get_padding( (GtkAlignment*)w, &t, &b, &l, &r );
                if( l > 0 )
                {
                    l /= (factor / 2); /* groups still need proper indent not to hurt usability */
                    gtk_alignment_set_padding( (GtkAlignment*)w, t, b, l, r );
                }
            }
            if( val > 0 )
                gtk_container_set_border_width( (GtkContainer*)w, val * 2 / factor );
        }
        gtk_container_foreach( (GtkContainer*)w, break_gnome_hig, GINT_TO_POINTER(factor) );
    }
}