]> granicus.if.org Git - transmission/commitdiff
(trunk gtk) #3847 "GTK+ 3 transition: Use accessor functions instead direct access...
authorCharles Kerr <charles@transmissionbt.com>
Fri, 24 Dec 2010 09:04:52 +0000 (09:04 +0000)
committerCharles Kerr <charles@transmissionbt.com>
Fri, 24 Dec 2010 09:04:52 +0000 (09:04 +0000)
gtk/main.c
gtk/torrent-cell-renderer.c
gtk/tr-window.c
gtk/util.c
gtk/util.h

index 67e4210f704bce246f3a17460e03acf2384ff0f7..31542da33d65f596387be9bb243a63c93c225ab6 100644 (file)
@@ -400,21 +400,21 @@ registerMagnetLinkHandler( void )
 }
 
 static void
-onMainWindowSizeAllocated( GtkWidget *            window,
+onMainWindowSizeAllocated( GtkWidget      * gtk_window,
                            GtkAllocation  * alloc UNUSED,
                            gpointer         gdata UNUSED )
 {
-    const gboolean isMaximized = window->window
-                            && ( gdk_window_get_state( window->window )
-                                 & GDK_WINDOW_STATE_MAXIMIZED );
+    GdkWindow * gdk_window = gtr_widget_get_window( gtk_window );
+    const gboolean isMaximized = ( gdk_window != NULL )
+                              && ( gdk_window_get_state( gdk_window ) & GDK_WINDOW_STATE_MAXIMIZED );
 
     gtr_pref_int_set( PREF_KEY_MAIN_WINDOW_IS_MAXIMIZED, isMaximized );
 
     if( !isMaximized )
     {
         int x, y, w, h;
-        gtk_window_get_position( GTK_WINDOW( window ), &x, &y );
-        gtk_window_get_size( GTK_WINDOW( window ), &w, &h );
+        gtk_window_get_position( GTK_WINDOW( gtk_window ), &x, &y );
+        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_Y, y );
         gtr_pref_int_set( PREF_KEY_MAIN_WINDOW_WIDTH, w );
index 002bb1573e9bc1a9ae1d9bce285d315d9f4c30c3..94ef0064cfe37a353b383e9ed39be848f1870631 100644 (file)
@@ -383,6 +383,7 @@ get_size_compact( TorrentCellRenderer * cell,
                   gint                * height )
 {
     int w, h;
+    int xpad, ypad;
     GdkRectangle icon_area;
     GdkRectangle name_area;
     GdkRectangle stat_area;
@@ -398,6 +399,7 @@ get_size_compact( TorrentCellRenderer * cell,
     icon = get_icon( tor, COMPACT_ICON_SIZE, widget );
     name = tr_torrentInfo( tor )->name;
     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 */
     g_object_set( p->icon_renderer, "pixbuf", icon, NULL );
@@ -420,9 +422,9 @@ get_size_compact( TorrentCellRenderer * cell,
 
 #define BAR_WIDTH 50
     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 )
-        *height = cell->parent.ypad * 2 + MAX( name_area.height, p->bar_height );
+        *height = ypad * 2 + MAX( name_area.height, p->bar_height );
 
     /* cleanup */
     g_free( status );
@@ -438,6 +440,7 @@ get_size_full( TorrentCellRenderer * cell,
                gint                * height )
 {
     int w, h;
+    int xpad, ypad;
     GdkRectangle icon_area;
     GdkRectangle name_area;
     GdkRectangle stat_area;
@@ -457,6 +460,7 @@ get_size_full( TorrentCellRenderer * cell,
     name = inf->name;
     status = getStatusString( tor, st, p->upload_speed_KBps, p->download_speed_KBps );
     progress = getProgressString( tor, inf, st );
+    gtr_cell_renderer_get_padding( &cell->parent, &xpad, &ypad );
 
     /* get the idealized cell dimensions */
     g_object_set( p->icon_renderer, "pixbuf", icon, NULL );
@@ -482,9 +486,9 @@ get_size_full( TorrentCellRenderer * cell,
     **/
 
     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 )
-        *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 */
     g_free( status );
@@ -506,8 +510,8 @@ torrent_cell_renderer_get_size( GtkCellRenderer  * cell,
 
     if( self && self->priv->tor )
     {
-        struct TorrentCellRendererPrivate * p = self->priv;
         int w, h;
+        struct TorrentCellRendererPrivate * p = self->priv;
 
         if( p->compact )
             get_size_compact( TORRENT_CELL_RENDERER( cell ), widget, &w, &h );
@@ -523,8 +527,11 @@ torrent_cell_renderer_get_size( GtkCellRenderer  * cell,
         if( x_offset )
             *x_offset = cell_area ? cell_area->x : 0;
 
-        if( y_offset )
-            *y_offset = cell_area ? (int)((cell_area->height - (cell->ypad*2 +h)) / 2.0) : 0;
+        if( y_offset ) {
+            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,
                 GtkCellRendererState    flags )
 {
+    int xpad, ypad;
     GdkRectangle icon_area;
     GdkRectangle name_area;
     GdkRectangle stat_area;
@@ -557,12 +565,13 @@ render_compact( TorrentCellRenderer   * cell,
     icon = get_icon( tor, COMPACT_ICON_SIZE, widget );
     name = tr_torrentInfo( tor )->name;
     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.x += cell->parent.xpad;
-    fill_area.y += cell->parent.ypad;
-    fill_area.width -= cell->parent.xpad * 2;
-    fill_area.height -= cell->parent.ypad * 2;
+    fill_area.x += xpad;
+    fill_area.y += ypad;
+    fill_area.width -= xpad * 2;
+    fill_area.height -= ypad * 2;
     icon_area = name_area = stat_area = prog_area = fill_area;
 
     g_object_set( p->icon_renderer, "pixbuf", icon, NULL );
@@ -609,6 +618,7 @@ render_full( TorrentCellRenderer   * cell,
              GtkCellRendererState    flags )
 {
     int w, h;
+    int xpad, ypad;
     GdkRectangle fill_area;
     GdkRectangle icon_area;
     GdkRectangle name_area;
@@ -633,6 +643,7 @@ render_full( TorrentCellRenderer   * cell,
     name = inf->name;
     status = getStatusString( tor, st, p->upload_speed_KBps, p->download_speed_KBps );
     progress = getProgressString( tor, inf, st );
+    gtr_cell_renderer_get_padding( &cell->parent, &xpad, &ypad );
 
     /* get the idealized cell dimensions */
     g_object_set( p->icon_renderer, "pixbuf", icon, NULL );
@@ -658,10 +669,10 @@ render_full( TorrentCellRenderer   * cell,
     **/
 
     fill_area = *background_area;
-    fill_area.x += cell->parent.xpad;
-    fill_area.y += cell->parent.ypad;
-    fill_area.width -= cell->parent.xpad * 2;
-    fill_area.height -= cell->parent.ypad * 2;
+    fill_area.x += xpad;
+    fill_area.y += ypad;
+    fill_area.width -= xpad * 2;
+    fill_area.height -= ypad * 2;
 
     /* icon */
     icon_area.x = fill_area.x;
index a3a0a4e281c98de8cd67d09b37e50de93d83e275..289834dc8e1db5de004cae05f6e052c6b49cd9cc 100644 (file)
@@ -869,7 +869,7 @@ gtr_window_set_busy( TrWindow * w, gboolean isBusy )
         GdkDisplay * display = gtk_widget_get_display( GTK_WIDGET( w ) );
         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 );
 
         if( cursor )
index 62fdd8a40e1f3cefdbd15fefdfc6b7cb4acbccaa..bdc21d2eda221160bbad1aafc7d974a735eeb7f4 100644 (file)
@@ -715,6 +715,16 @@ gtr_widget_set_tooltip_text( GtkWidget * w, const char * tip )
 #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
 gtr_widget_get_realized( GtkWidget * w )
 {
@@ -753,6 +763,17 @@ gtr_widget_set_visible( GtkWidget * w, gboolean b )
 #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*
 gtr_dialog_get_content_area( GtkDialog * dialog )
 {
index 06ca86ff2c89b517db5f60ba3c60a1d7bc1182ec..33f89dcfe91a4512400d71c59fbbe343649c4db5 100644 (file)
@@ -136,12 +136,18 @@ guint gtr_idle_add( GSourceFunc  func, gpointer data );
 /* backwards-compatible wrapper around gtk_widget_set_tooltip_text() */
 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() */
 gboolean gtr_widget_get_realized( GtkWidget * w );
 
 /* backwards-compatible wrapper around gtk_widget_set_visible() */
 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() */
 gpointer gtr_object_ref_sink( gpointer object );