コード例 #1
0
static void torrent_cell_renderer_get_size(GtkCellRenderer* cell, GtkWidget* widget, GdkRectangle const* cell_area,
    gint* x_offset, gint* y_offset, gint* width, gint* height)
{
    TorrentCellRenderer* self = TORRENT_CELL_RENDERER(cell);

    if (self != NULL && self->priv->tor != NULL)
    {
        int w;
        int h;
        struct TorrentCellRendererPrivate* p = self->priv;

        if (p->compact)
        {
            get_size_compact(TORRENT_CELL_RENDERER(cell), widget, &w, &h);
        }
        else
        {
            get_size_full(TORRENT_CELL_RENDERER(cell), widget, &w, &h);
        }

        if (width != NULL)
        {
            *width = w;
        }

        if (height != NULL)
        {
            *height = h;
        }

        if (x_offset != NULL)
        {
            *x_offset = cell_area ? cell_area->x : 0;
        }

        if (y_offset != NULL)
        {
            int xpad, ypad;
            gtk_cell_renderer_get_padding(cell, &xpad, &ypad);
            *y_offset = cell_area ? (int)((cell_area->height - (ypad * 2 + h)) / 2.0) : 0;
        }
    }
}
コード例 #2
0
static void
torrent_cell_renderer_get_size( GtkCellRenderer     * cell,
                                GtkWidget           * widget,
#if GTK_CHECK_VERSION( 3,0,0 )
                                const GdkRectangle  * cell_area,
#else
                                GdkRectangle        * cell_area,
#endif
                                gint                * x_offset,
                                gint                * y_offset,
                                gint                * width,
                                gint                * height )
{
    TorrentCellRenderer * self = TORRENT_CELL_RENDERER( cell );

    if( self && self->priv->tor )
    {
        int w, h;
        struct TorrentCellRendererPrivate * p = self->priv;

        if( p->compact )
            get_size_compact( TORRENT_CELL_RENDERER( cell ), widget, &w, &h );
        else
            get_size_full( TORRENT_CELL_RENDERER( cell ), widget, &w, &h );

        if( width )
            *width = w;

        if( height )
            *height = h;

        if( x_offset )
            *x_offset = cell_area ? cell_area->x : 0;

        if( y_offset ) {
            int xpad, ypad;
            gtk_cell_renderer_get_padding( cell, &xpad, &ypad );
            *y_offset = cell_area ? (int)((cell_area->height - (ypad*2 +h)) / 2.0) : 0;
        }
    }
}
コード例 #3
0
static void
torrent_cell_renderer_get_size( GtkCellRenderer  * cell,
                                GtkWidget        * widget,
                                GdkRectangle     * cell_area,
                                gint             * x_offset,
                                gint             * y_offset,
                                gint             * width,
                                gint             * height )
{
    TorrentCellRenderer * self = TORRENT_CELL_RENDERER( cell );

    if( self && self->priv->tor )
    {
        struct TorrentCellRendererPrivate * p = self->priv;
        int w, h;

        if( p->compact )
            get_size_compact( TORRENT_CELL_RENDERER( cell ), widget, &w, &h );
        else
            get_size_full( TORRENT_CELL_RENDERER( cell ), widget, &w, &h );

        if( width )
            *width = w;

        if( height )
            *height = h;

        if( cell_area ) {
            if( x_offset ) *x_offset = 0;
            if( y_offset ) {
                *y_offset = 0.5 * ( cell_area->height - ( h + ( 2 * cell->ypad ) ) );
                *y_offset = MAX( *y_offset, 0 );
            }
        }
    }
}