(gtk) #703: fix right-to-left locale issues in the details dialog

This commit is contained in:
Charles Kerr 2008-02-16 19:36:07 +00:00
parent 7ab59f951f
commit c3e87bc4ea
2 changed files with 23 additions and 3 deletions

View File

@ -20,6 +20,8 @@
#include "tr_torrent.h"
#include "util.h"
/* #define TEST_RTL */
enum
{
P_TORRENT = 1,
@ -515,6 +517,12 @@ torrent_cell_renderer_render( GtkCellRenderer * cell,
GtkCellRendererState flags)
{
TorrentCellRenderer * self = TORRENT_CELL_RENDERER( cell );
#ifdef TEST_RTL
GtkTextDirection real_dir = gtk_widget_get_direction( widget );
gtk_widget_set_direction( widget, GTK_TEXT_DIR_RTL );
#endif
if( self && self->priv->tor )
{
const tr_torrent * tor = self->priv->tor;
@ -649,6 +657,10 @@ torrent_cell_renderer_render( GtkCellRenderer * cell,
g_free( statusString );
}
}
#ifdef TEST_RTL
gtk_widget_set_direction( widget, real_dir );
#endif
}
static void

View File

@ -63,7 +63,7 @@ release_gobject_array (gpointer data)
}
static gboolean
refresh_pieces (GtkWidget * da, GdkEventExpose * event UNUSED, gpointer gtor)
refresh_pieces( GtkWidget * da, GdkEventExpose * event UNUSED, gpointer gtor )
{
tr_torrent * tor = tr_torrent_handle( TR_TORRENT(gtor) );
const tr_info * info = tr_torrent_info( TR_TORRENT(gtor) );
@ -79,6 +79,8 @@ refresh_pieces (GtkWidget * da, GdkEventExpose * event UNUSED, gpointer gtor)
const double piece_h = grid_bounds.height / (double)n_rows;
const int piece_w_int = (int) (piece_w + 1); /* pad for roundoff */
const int piece_h_int = (int) (piece_h + 1); /* pad for roundoff */
const gboolean rtl = gtk_widget_get_direction( da ) == GTK_TEXT_DIR_RTL;
guint8 * prev_color = NULL;
gboolean first_time = FALSE;
@ -157,11 +159,17 @@ refresh_pieces (GtkWidget * da, GdkEventExpose * event UNUSED, gpointer gtor)
i = 0;
for (y=0; y<n_rows; ++y) {
for (x=0; x<n_cols; ++x) {
const int draw_x = grid_bounds.x + (int)(x * piece_w);
const int draw_y = grid_bounds.y + (int)(y * piece_h);
int draw_x = grid_bounds.x + (int)(x * piece_w);
int draw_y = grid_bounds.y + (int)(y * piece_h);
int color = BLACK;
int border = BLACK;
if( rtl )
draw_x = grid_bounds.x + grid_bounds.width - (int)((x+1) * piece_w);
else
draw_x = grid_bounds.x + (int)(x * piece_w);
draw_y = grid_bounds.y + (int)(y * piece_h);
if (i < n_cells)
{
border = GRAY;