(trunk gtk) #3847 "GTK+ 3 transition: Use accessor functions instead direct access" -- don't directly access GtkCellRenderer.xpad, GtkCellRenderer.ypad, or GtkWidget.window.
This commit is contained in:
parent
ae84dc70dd
commit
f5b13c46dc
12
gtk/main.c
12
gtk/main.c
|
@ -400,21 +400,21 @@ registerMagnetLinkHandler( void )
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
onMainWindowSizeAllocated( GtkWidget * window,
|
onMainWindowSizeAllocated( GtkWidget * gtk_window,
|
||||||
GtkAllocation * alloc UNUSED,
|
GtkAllocation * alloc UNUSED,
|
||||||
gpointer gdata UNUSED )
|
gpointer gdata UNUSED )
|
||||||
{
|
{
|
||||||
const gboolean isMaximized = window->window
|
GdkWindow * gdk_window = gtr_widget_get_window( gtk_window );
|
||||||
&& ( gdk_window_get_state( window->window )
|
const gboolean isMaximized = ( gdk_window != NULL )
|
||||||
& GDK_WINDOW_STATE_MAXIMIZED );
|
&& ( gdk_window_get_state( gdk_window ) & GDK_WINDOW_STATE_MAXIMIZED );
|
||||||
|
|
||||||
gtr_pref_int_set( PREF_KEY_MAIN_WINDOW_IS_MAXIMIZED, isMaximized );
|
gtr_pref_int_set( PREF_KEY_MAIN_WINDOW_IS_MAXIMIZED, isMaximized );
|
||||||
|
|
||||||
if( !isMaximized )
|
if( !isMaximized )
|
||||||
{
|
{
|
||||||
int x, y, w, h;
|
int x, y, w, h;
|
||||||
gtk_window_get_position( GTK_WINDOW( window ), &x, &y );
|
gtk_window_get_position( GTK_WINDOW( gtk_window ), &x, &y );
|
||||||
gtk_window_get_size( GTK_WINDOW( window ), &w, &h );
|
gtk_window_get_size( GTK_WINDOW( gtk_window ), &w, &h );
|
||||||
gtr_pref_int_set( PREF_KEY_MAIN_WINDOW_X, x );
|
gtr_pref_int_set( PREF_KEY_MAIN_WINDOW_X, x );
|
||||||
gtr_pref_int_set( PREF_KEY_MAIN_WINDOW_Y, y );
|
gtr_pref_int_set( PREF_KEY_MAIN_WINDOW_Y, y );
|
||||||
gtr_pref_int_set( PREF_KEY_MAIN_WINDOW_WIDTH, w );
|
gtr_pref_int_set( PREF_KEY_MAIN_WINDOW_WIDTH, w );
|
||||||
|
|
|
@ -383,6 +383,7 @@ get_size_compact( TorrentCellRenderer * cell,
|
||||||
gint * height )
|
gint * height )
|
||||||
{
|
{
|
||||||
int w, h;
|
int w, h;
|
||||||
|
int xpad, ypad;
|
||||||
GdkRectangle icon_area;
|
GdkRectangle icon_area;
|
||||||
GdkRectangle name_area;
|
GdkRectangle name_area;
|
||||||
GdkRectangle stat_area;
|
GdkRectangle stat_area;
|
||||||
|
@ -398,6 +399,7 @@ get_size_compact( TorrentCellRenderer * cell,
|
||||||
icon = get_icon( tor, COMPACT_ICON_SIZE, widget );
|
icon = get_icon( tor, COMPACT_ICON_SIZE, widget );
|
||||||
name = tr_torrentInfo( tor )->name;
|
name = tr_torrentInfo( tor )->name;
|
||||||
status = getShortStatusString( tor, st, p->upload_speed_KBps, p->download_speed_KBps );
|
status = getShortStatusString( tor, st, p->upload_speed_KBps, p->download_speed_KBps );
|
||||||
|
gtr_cell_renderer_get_padding( &cell->parent, &xpad, &ypad );
|
||||||
|
|
||||||
/* get the idealized cell dimensions */
|
/* get the idealized cell dimensions */
|
||||||
g_object_set( p->icon_renderer, "pixbuf", icon, NULL );
|
g_object_set( p->icon_renderer, "pixbuf", icon, NULL );
|
||||||
|
@ -420,9 +422,9 @@ get_size_compact( TorrentCellRenderer * cell,
|
||||||
|
|
||||||
#define BAR_WIDTH 50
|
#define BAR_WIDTH 50
|
||||||
if( width != NULL )
|
if( width != NULL )
|
||||||
*width = cell->parent.xpad * 2 + icon_area.width + GUI_PAD + name_area.width + GUI_PAD + BAR_WIDTH + GUI_PAD + stat_area.width;
|
*width = xpad * 2 + icon_area.width + GUI_PAD + name_area.width + GUI_PAD + BAR_WIDTH + GUI_PAD + stat_area.width;
|
||||||
if( height != NULL )
|
if( height != NULL )
|
||||||
*height = cell->parent.ypad * 2 + MAX( name_area.height, p->bar_height );
|
*height = ypad * 2 + MAX( name_area.height, p->bar_height );
|
||||||
|
|
||||||
/* cleanup */
|
/* cleanup */
|
||||||
g_free( status );
|
g_free( status );
|
||||||
|
@ -438,6 +440,7 @@ get_size_full( TorrentCellRenderer * cell,
|
||||||
gint * height )
|
gint * height )
|
||||||
{
|
{
|
||||||
int w, h;
|
int w, h;
|
||||||
|
int xpad, ypad;
|
||||||
GdkRectangle icon_area;
|
GdkRectangle icon_area;
|
||||||
GdkRectangle name_area;
|
GdkRectangle name_area;
|
||||||
GdkRectangle stat_area;
|
GdkRectangle stat_area;
|
||||||
|
@ -457,6 +460,7 @@ get_size_full( TorrentCellRenderer * cell,
|
||||||
name = inf->name;
|
name = inf->name;
|
||||||
status = getStatusString( tor, st, p->upload_speed_KBps, p->download_speed_KBps );
|
status = getStatusString( tor, st, p->upload_speed_KBps, p->download_speed_KBps );
|
||||||
progress = getProgressString( tor, inf, st );
|
progress = getProgressString( tor, inf, st );
|
||||||
|
gtr_cell_renderer_get_padding( &cell->parent, &xpad, &ypad );
|
||||||
|
|
||||||
/* get the idealized cell dimensions */
|
/* get the idealized cell dimensions */
|
||||||
g_object_set( p->icon_renderer, "pixbuf", icon, NULL );
|
g_object_set( p->icon_renderer, "pixbuf", icon, NULL );
|
||||||
|
@ -482,9 +486,9 @@ get_size_full( TorrentCellRenderer * cell,
|
||||||
**/
|
**/
|
||||||
|
|
||||||
if( width != NULL )
|
if( width != NULL )
|
||||||
*width = cell->parent.xpad * 2 + icon_area.width + GUI_PAD + MAX3( name_area.width, prog_area.width, stat_area.width );
|
*width = xpad * 2 + icon_area.width + GUI_PAD + MAX3( name_area.width, prog_area.width, stat_area.width );
|
||||||
if( height != NULL )
|
if( height != NULL )
|
||||||
*height = cell->parent.ypad * 2 + name_area.height + prog_area.height + GUI_PAD_SMALL + p->bar_height + GUI_PAD_SMALL + stat_area.height;
|
*height = ypad * 2 + name_area.height + prog_area.height + GUI_PAD_SMALL + p->bar_height + GUI_PAD_SMALL + stat_area.height;
|
||||||
|
|
||||||
/* cleanup */
|
/* cleanup */
|
||||||
g_free( status );
|
g_free( status );
|
||||||
|
@ -506,8 +510,8 @@ torrent_cell_renderer_get_size( GtkCellRenderer * cell,
|
||||||
|
|
||||||
if( self && self->priv->tor )
|
if( self && self->priv->tor )
|
||||||
{
|
{
|
||||||
struct TorrentCellRendererPrivate * p = self->priv;
|
|
||||||
int w, h;
|
int w, h;
|
||||||
|
struct TorrentCellRendererPrivate * p = self->priv;
|
||||||
|
|
||||||
if( p->compact )
|
if( p->compact )
|
||||||
get_size_compact( TORRENT_CELL_RENDERER( cell ), widget, &w, &h );
|
get_size_compact( TORRENT_CELL_RENDERER( cell ), widget, &w, &h );
|
||||||
|
@ -523,8 +527,11 @@ torrent_cell_renderer_get_size( GtkCellRenderer * cell,
|
||||||
if( x_offset )
|
if( x_offset )
|
||||||
*x_offset = cell_area ? cell_area->x : 0;
|
*x_offset = cell_area ? cell_area->x : 0;
|
||||||
|
|
||||||
if( y_offset )
|
if( y_offset ) {
|
||||||
*y_offset = cell_area ? (int)((cell_area->height - (cell->ypad*2 +h)) / 2.0) : 0;
|
int xpad, ypad;
|
||||||
|
gtr_cell_renderer_get_padding( cell, &xpad, &ypad );
|
||||||
|
*y_offset = cell_area ? (int)((cell_area->height - (ypad*2 +h)) / 2.0) : 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -537,6 +544,7 @@ render_compact( TorrentCellRenderer * cell,
|
||||||
GdkRectangle * expose_area UNUSED,
|
GdkRectangle * expose_area UNUSED,
|
||||||
GtkCellRendererState flags )
|
GtkCellRendererState flags )
|
||||||
{
|
{
|
||||||
|
int xpad, ypad;
|
||||||
GdkRectangle icon_area;
|
GdkRectangle icon_area;
|
||||||
GdkRectangle name_area;
|
GdkRectangle name_area;
|
||||||
GdkRectangle stat_area;
|
GdkRectangle stat_area;
|
||||||
|
@ -557,12 +565,13 @@ render_compact( TorrentCellRenderer * cell,
|
||||||
icon = get_icon( tor, COMPACT_ICON_SIZE, widget );
|
icon = get_icon( tor, COMPACT_ICON_SIZE, widget );
|
||||||
name = tr_torrentInfo( tor )->name;
|
name = tr_torrentInfo( tor )->name;
|
||||||
status = getShortStatusString( tor, st, p->upload_speed_KBps, p->download_speed_KBps );
|
status = getShortStatusString( tor, st, p->upload_speed_KBps, p->download_speed_KBps );
|
||||||
|
gtr_cell_renderer_get_padding( &cell->parent, &xpad, &ypad );
|
||||||
|
|
||||||
fill_area = *background_area;
|
fill_area = *background_area;
|
||||||
fill_area.x += cell->parent.xpad;
|
fill_area.x += xpad;
|
||||||
fill_area.y += cell->parent.ypad;
|
fill_area.y += ypad;
|
||||||
fill_area.width -= cell->parent.xpad * 2;
|
fill_area.width -= xpad * 2;
|
||||||
fill_area.height -= cell->parent.ypad * 2;
|
fill_area.height -= ypad * 2;
|
||||||
icon_area = name_area = stat_area = prog_area = fill_area;
|
icon_area = name_area = stat_area = prog_area = fill_area;
|
||||||
|
|
||||||
g_object_set( p->icon_renderer, "pixbuf", icon, NULL );
|
g_object_set( p->icon_renderer, "pixbuf", icon, NULL );
|
||||||
|
@ -609,6 +618,7 @@ render_full( TorrentCellRenderer * cell,
|
||||||
GtkCellRendererState flags )
|
GtkCellRendererState flags )
|
||||||
{
|
{
|
||||||
int w, h;
|
int w, h;
|
||||||
|
int xpad, ypad;
|
||||||
GdkRectangle fill_area;
|
GdkRectangle fill_area;
|
||||||
GdkRectangle icon_area;
|
GdkRectangle icon_area;
|
||||||
GdkRectangle name_area;
|
GdkRectangle name_area;
|
||||||
|
@ -633,6 +643,7 @@ render_full( TorrentCellRenderer * cell,
|
||||||
name = inf->name;
|
name = inf->name;
|
||||||
status = getStatusString( tor, st, p->upload_speed_KBps, p->download_speed_KBps );
|
status = getStatusString( tor, st, p->upload_speed_KBps, p->download_speed_KBps );
|
||||||
progress = getProgressString( tor, inf, st );
|
progress = getProgressString( tor, inf, st );
|
||||||
|
gtr_cell_renderer_get_padding( &cell->parent, &xpad, &ypad );
|
||||||
|
|
||||||
/* get the idealized cell dimensions */
|
/* get the idealized cell dimensions */
|
||||||
g_object_set( p->icon_renderer, "pixbuf", icon, NULL );
|
g_object_set( p->icon_renderer, "pixbuf", icon, NULL );
|
||||||
|
@ -658,10 +669,10 @@ render_full( TorrentCellRenderer * cell,
|
||||||
**/
|
**/
|
||||||
|
|
||||||
fill_area = *background_area;
|
fill_area = *background_area;
|
||||||
fill_area.x += cell->parent.xpad;
|
fill_area.x += xpad;
|
||||||
fill_area.y += cell->parent.ypad;
|
fill_area.y += ypad;
|
||||||
fill_area.width -= cell->parent.xpad * 2;
|
fill_area.width -= xpad * 2;
|
||||||
fill_area.height -= cell->parent.ypad * 2;
|
fill_area.height -= ypad * 2;
|
||||||
|
|
||||||
/* icon */
|
/* icon */
|
||||||
icon_area.x = fill_area.x;
|
icon_area.x = fill_area.x;
|
||||||
|
|
|
@ -869,7 +869,7 @@ gtr_window_set_busy( TrWindow * w, gboolean isBusy )
|
||||||
GdkDisplay * display = gtk_widget_get_display( GTK_WIDGET( w ) );
|
GdkDisplay * display = gtk_widget_get_display( GTK_WIDGET( w ) );
|
||||||
GdkCursor * cursor = isBusy ? gdk_cursor_new_for_display( display, GDK_WATCH ) : NULL;
|
GdkCursor * cursor = isBusy ? gdk_cursor_new_for_display( display, GDK_WATCH ) : NULL;
|
||||||
|
|
||||||
gdk_window_set_cursor( GTK_WIDGET(w)->window, cursor );
|
gdk_window_set_cursor( gtr_widget_get_window( GTK_WIDGET( w ) ), cursor );
|
||||||
gdk_display_flush( display );
|
gdk_display_flush( display );
|
||||||
|
|
||||||
if( cursor )
|
if( cursor )
|
||||||
|
|
21
gtk/util.c
21
gtk/util.c
|
@ -715,6 +715,16 @@ gtr_widget_set_tooltip_text( GtkWidget * w, const char * tip )
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GdkWindow*
|
||||||
|
gtr_widget_get_window( GtkWidget * w )
|
||||||
|
{
|
||||||
|
#if GTK_CHECK_VERSION( 2,14,0 )
|
||||||
|
return gtk_widget_get_window( w );
|
||||||
|
#else
|
||||||
|
return w->window;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
gtr_widget_get_realized( GtkWidget * w )
|
gtr_widget_get_realized( GtkWidget * w )
|
||||||
{
|
{
|
||||||
|
@ -753,6 +763,17 @@ gtr_widget_set_visible( GtkWidget * w, gboolean b )
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gtr_cell_renderer_get_padding( GtkCellRenderer * cell, gint * xpad, gint * ypad )
|
||||||
|
{
|
||||||
|
#if GTK_CHECK_VERSION( 2,18,0 )
|
||||||
|
gtk_cell_renderer_get_padding( cell, xpad, ypad );
|
||||||
|
#else
|
||||||
|
if( xpad != NULL ) *xpad = cell->xpad;
|
||||||
|
if( ypad != NULL ) *ypad = cell->ypad;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
static GtkWidget*
|
static GtkWidget*
|
||||||
gtr_dialog_get_content_area( GtkDialog * dialog )
|
gtr_dialog_get_content_area( GtkDialog * dialog )
|
||||||
{
|
{
|
||||||
|
|
|
@ -136,12 +136,18 @@ guint gtr_idle_add( GSourceFunc func, gpointer data );
|
||||||
/* backwards-compatible wrapper around gtk_widget_set_tooltip_text() */
|
/* backwards-compatible wrapper around gtk_widget_set_tooltip_text() */
|
||||||
void gtr_widget_set_tooltip_text( GtkWidget * w, const char * tip );
|
void gtr_widget_set_tooltip_text( GtkWidget * w, const char * tip );
|
||||||
|
|
||||||
|
/* backwards-compatible wrapper around gtk_widget_get_window() */
|
||||||
|
GdkWindow* gtr_widget_get_window( GtkWidget * w );
|
||||||
|
|
||||||
/* backwards-compatible wrapper around gtk_widget_get_realized() */
|
/* backwards-compatible wrapper around gtk_widget_get_realized() */
|
||||||
gboolean gtr_widget_get_realized( GtkWidget * w );
|
gboolean gtr_widget_get_realized( GtkWidget * w );
|
||||||
|
|
||||||
/* backwards-compatible wrapper around gtk_widget_set_visible() */
|
/* backwards-compatible wrapper around gtk_widget_set_visible() */
|
||||||
void gtr_widget_set_visible( GtkWidget *, gboolean );
|
void gtr_widget_set_visible( GtkWidget *, gboolean );
|
||||||
|
|
||||||
|
/* backwards-compatible wrapper around gtk_cell_renderer_get_padding() */
|
||||||
|
void gtr_cell_renderer_get_padding( GtkCellRenderer *, gint * xpad, gint * ypad );
|
||||||
|
|
||||||
/* backwards-compatible wrapper around g_object_ref_sink() */
|
/* backwards-compatible wrapper around g_object_ref_sink() */
|
||||||
gpointer gtr_object_ref_sink( gpointer object );
|
gpointer gtr_object_ref_sink( gpointer object );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue