Changeset 11589


Ignore:
Timestamp:
Dec 24, 2010, 9:04:52 AM (11 years ago)
Author:
charles
Message:

(trunk gtk) #3847 "GTK+ 3 transition: Use accessor functions instead direct access" -- don't directly access GtkCellRenderer?.xpad, GtkCellRenderer?.ypad, or GtkWidget?.window.

Location:
trunk/gtk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/main.c

    r11586 r11589  
    401401
    402402static void
    403 onMainWindowSizeAllocated( GtkWidget *            window,
     403onMainWindowSizeAllocated( GtkWidget      * gtk_window,
    404404                           GtkAllocation  * alloc UNUSED,
    405405                           gpointer         gdata UNUSED )
    406406{
    407     const gboolean isMaximized = window->window
    408                             && ( gdk_window_get_state( window->window )
    409                                 & GDK_WINDOW_STATE_MAXIMIZED );
     407    GdkWindow * gdk_window = gtr_widget_get_window( gtk_window );
     408    const gboolean isMaximized = ( gdk_window != NULL )
     409                              && ( gdk_window_get_state( gdk_window ) & GDK_WINDOW_STATE_MAXIMIZED );
    410410
    411411    gtr_pref_int_set( PREF_KEY_MAIN_WINDOW_IS_MAXIMIZED, isMaximized );
     
    414414    {
    415415        int x, y, w, h;
    416         gtk_window_get_position( GTK_WINDOW( window ), &x, &y );
    417         gtk_window_get_size( GTK_WINDOW( window ), &w, &h );
     416        gtk_window_get_position( GTK_WINDOW( gtk_window ), &x, &y );
     417        gtk_window_get_size( GTK_WINDOW( gtk_window ), &w, &h );
    418418        gtr_pref_int_set( PREF_KEY_MAIN_WINDOW_X, x );
    419419        gtr_pref_int_set( PREF_KEY_MAIN_WINDOW_Y, y );
  • trunk/gtk/torrent-cell-renderer.c

    r11563 r11589  
    384384{
    385385    int w, h;
     386    int xpad, ypad;
    386387    GdkRectangle icon_area;
    387388    GdkRectangle name_area;
     
    399400    name = tr_torrentInfo( tor )->name;
    400401    status = getShortStatusString( tor, st, p->upload_speed_KBps, p->download_speed_KBps );
     402    gtr_cell_renderer_get_padding( &cell->parent, &xpad, &ypad );
    401403
    402404    /* get the idealized cell dimensions */
     
    421423#define BAR_WIDTH 50
    422424    if( width != NULL )
    423         *width = cell->parent.xpad * 2 + icon_area.width + GUI_PAD + name_area.width + GUI_PAD + BAR_WIDTH + GUI_PAD + stat_area.width;
     425        *width = xpad * 2 + icon_area.width + GUI_PAD + name_area.width + GUI_PAD + BAR_WIDTH + GUI_PAD + stat_area.width;
    424426    if( height != NULL )
    425         *height = cell->parent.ypad * 2 + MAX( name_area.height, p->bar_height );
     427        *height = ypad * 2 + MAX( name_area.height, p->bar_height );
    426428
    427429    /* cleanup */
     
    439441{
    440442    int w, h;
     443    int xpad, ypad;
    441444    GdkRectangle icon_area;
    442445    GdkRectangle name_area;
     
    458461    status = getStatusString( tor, st, p->upload_speed_KBps, p->download_speed_KBps );
    459462    progress = getProgressString( tor, inf, st );
     463    gtr_cell_renderer_get_padding( &cell->parent, &xpad, &ypad );
    460464
    461465    /* get the idealized cell dimensions */
     
    483487
    484488    if( width != NULL )
    485         *width = cell->parent.xpad * 2 + icon_area.width + GUI_PAD + MAX3( name_area.width, prog_area.width, stat_area.width );
     489        *width = xpad * 2 + icon_area.width + GUI_PAD + MAX3( name_area.width, prog_area.width, stat_area.width );
    486490    if( height != NULL )
    487         *height = cell->parent.ypad * 2 + name_area.height + prog_area.height + GUI_PAD_SMALL + p->bar_height + GUI_PAD_SMALL + stat_area.height;
     491        *height = ypad * 2 + name_area.height + prog_area.height + GUI_PAD_SMALL + p->bar_height + GUI_PAD_SMALL + stat_area.height;
    488492
    489493    /* cleanup */
     
    507511    if( self && self->priv->tor )
    508512    {
     513        int w, h;
    509514        struct TorrentCellRendererPrivate * p = self->priv;
    510         int w, h;
    511515
    512516        if( p->compact )
     
    524528            *x_offset = cell_area ? cell_area->x : 0;
    525529
    526         if( y_offset )
    527             *y_offset = cell_area ? (int)((cell_area->height - (cell->ypad*2 +h)) / 2.0) : 0;
     530        if( y_offset ) {
     531            int xpad, ypad;
     532            gtr_cell_renderer_get_padding( cell, &xpad, &ypad );
     533            *y_offset = cell_area ? (int)((cell_area->height - (ypad*2 +h)) / 2.0) : 0;
     534        }
    528535    }
    529536}
     
    538545                GtkCellRendererState    flags )
    539546{
     547    int xpad, ypad;
    540548    GdkRectangle icon_area;
    541549    GdkRectangle name_area;
     
    558566    name = tr_torrentInfo( tor )->name;
    559567    status = getShortStatusString( tor, st, p->upload_speed_KBps, p->download_speed_KBps );
     568    gtr_cell_renderer_get_padding( &cell->parent, &xpad, &ypad );
    560569
    561570    fill_area = *background_area;
    562     fill_area.x += cell->parent.xpad;
    563     fill_area.y += cell->parent.ypad;
    564     fill_area.width -= cell->parent.xpad * 2;
    565     fill_area.height -= cell->parent.ypad * 2;
     571    fill_area.x += xpad;
     572    fill_area.y += ypad;
     573    fill_area.width -= xpad * 2;
     574    fill_area.height -= ypad * 2;
    566575    icon_area = name_area = stat_area = prog_area = fill_area;
    567576
     
    610619{
    611620    int w, h;
     621    int xpad, ypad;
    612622    GdkRectangle fill_area;
    613623    GdkRectangle icon_area;
     
    634644    status = getStatusString( tor, st, p->upload_speed_KBps, p->download_speed_KBps );
    635645    progress = getProgressString( tor, inf, st );
     646    gtr_cell_renderer_get_padding( &cell->parent, &xpad, &ypad );
    636647
    637648    /* get the idealized cell dimensions */
     
    659670
    660671    fill_area = *background_area;
    661     fill_area.x += cell->parent.xpad;
    662     fill_area.y += cell->parent.ypad;
    663     fill_area.width -= cell->parent.xpad * 2;
    664     fill_area.height -= cell->parent.ypad * 2;
     672    fill_area.x += xpad;
     673    fill_area.y += ypad;
     674    fill_area.width -= xpad * 2;
     675    fill_area.height -= ypad * 2;
    665676
    666677    /* icon */
  • trunk/gtk/tr-window.c

    r11572 r11589  
    870870        GdkCursor * cursor = isBusy ? gdk_cursor_new_for_display( display, GDK_WATCH ) : NULL;
    871871
    872         gdk_window_set_cursor( GTK_WIDGET(w)->window, cursor );
     872        gdk_window_set_cursor( gtr_widget_get_window( GTK_WIDGET( w ) ), cursor );
    873873        gdk_display_flush( display );
    874874
  • trunk/gtk/util.c

    r11586 r11589  
    716716}
    717717
     718GdkWindow*
     719gtr_widget_get_window( GtkWidget * w )
     720{
     721#if GTK_CHECK_VERSION( 2,14,0 )
     722    return gtk_widget_get_window( w );
     723#else
     724    return w->window;
     725#endif
     726}
     727
    718728gboolean
    719729gtr_widget_get_realized( GtkWidget * w )
     
    751761    else
    752762        gtk_widget_hide( w );
     763#endif
     764}
     765
     766void
     767gtr_cell_renderer_get_padding( GtkCellRenderer * cell, gint * xpad, gint * ypad )
     768{
     769#if GTK_CHECK_VERSION( 2,18,0 )
     770    gtk_cell_renderer_get_padding( cell, xpad, ypad );
     771#else
     772    if( xpad != NULL ) *xpad = cell->xpad;
     773    if( ypad != NULL ) *ypad = cell->ypad;
    753774#endif
    754775}
  • trunk/gtk/util.h

    r11586 r11589  
    137137void gtr_widget_set_tooltip_text( GtkWidget * w, const char * tip );
    138138
     139/* backwards-compatible wrapper around gtk_widget_get_window() */
     140GdkWindow* gtr_widget_get_window( GtkWidget * w );
     141
    139142/* backwards-compatible wrapper around gtk_widget_get_realized() */
    140143gboolean gtr_widget_get_realized( GtkWidget * w );
     
    142145/* backwards-compatible wrapper around gtk_widget_set_visible() */
    143146void gtr_widget_set_visible( GtkWidget *, gboolean );
     147
     148/* backwards-compatible wrapper around gtk_cell_renderer_get_padding() */
     149void gtr_cell_renderer_get_padding( GtkCellRenderer *, gint * xpad, gint * ypad );
    144150
    145151/* backwards-compatible wrapper around g_object_ref_sink() */
Note: See TracChangeset for help on using the changeset viewer.