(gtk) #703: fix right-to-left locale issues in the details dialog
This commit is contained in:
parent
7ab59f951f
commit
c3e87bc4ea
|
@ -20,6 +20,8 @@
|
||||||
#include "tr_torrent.h"
|
#include "tr_torrent.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
|
/* #define TEST_RTL */
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
P_TORRENT = 1,
|
P_TORRENT = 1,
|
||||||
|
@ -515,6 +517,12 @@ torrent_cell_renderer_render( GtkCellRenderer * cell,
|
||||||
GtkCellRendererState flags)
|
GtkCellRendererState flags)
|
||||||
{
|
{
|
||||||
TorrentCellRenderer * self = TORRENT_CELL_RENDERER( cell );
|
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 )
|
if( self && self->priv->tor )
|
||||||
{
|
{
|
||||||
const tr_torrent * tor = self->priv->tor;
|
const tr_torrent * tor = self->priv->tor;
|
||||||
|
@ -649,6 +657,10 @@ torrent_cell_renderer_render( GtkCellRenderer * cell,
|
||||||
g_free( statusString );
|
g_free( statusString );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef TEST_RTL
|
||||||
|
gtk_widget_set_direction( widget, real_dir );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -63,7 +63,7 @@ release_gobject_array (gpointer data)
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
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) );
|
tr_torrent * tor = tr_torrent_handle( TR_TORRENT(gtor) );
|
||||||
const tr_info * info = tr_torrent_info( 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 double piece_h = grid_bounds.height / (double)n_rows;
|
||||||
const int piece_w_int = (int) (piece_w + 1); /* pad for roundoff */
|
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 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;
|
guint8 * prev_color = NULL;
|
||||||
gboolean first_time = FALSE;
|
gboolean first_time = FALSE;
|
||||||
|
|
||||||
|
@ -157,11 +159,17 @@ refresh_pieces (GtkWidget * da, GdkEventExpose * event UNUSED, gpointer gtor)
|
||||||
i = 0;
|
i = 0;
|
||||||
for (y=0; y<n_rows; ++y) {
|
for (y=0; y<n_rows; ++y) {
|
||||||
for (x=0; x<n_cols; ++x) {
|
for (x=0; x<n_cols; ++x) {
|
||||||
const int draw_x = grid_bounds.x + (int)(x * piece_w);
|
int draw_x = grid_bounds.x + (int)(x * piece_w);
|
||||||
const int draw_y = grid_bounds.y + (int)(y * piece_h);
|
int draw_y = grid_bounds.y + (int)(y * piece_h);
|
||||||
int color = BLACK;
|
int color = BLACK;
|
||||||
int border = 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)
|
if (i < n_cells)
|
||||||
{
|
{
|
||||||
border = GRAY;
|
border = GRAY;
|
||||||
|
|
Loading…
Reference in New Issue