menu/main_menu: Better RTL support
This commit is contained in:
parent
ab7cffe4d6
commit
a087ecfa30
@ -29,7 +29,7 @@ class MainPanel(MenuPanel):
|
|||||||
if i > 3:
|
if i > 3:
|
||||||
break
|
break
|
||||||
self.labels[x] = self._gtk.ButtonImage("extruder-"+str(i), self._gtk.formatTemperatureString(0, 0))
|
self.labels[x] = self._gtk.ButtonImage("extruder-"+str(i), self._gtk.formatTemperatureString(0, 0))
|
||||||
col = 0 if len(self._printer.get_tools()) == 1 else (i%2 if self._screen.lang_ltr else 1 - i%2)
|
col = 0 if len(self._printer.get_tools()) == 1 else i%2
|
||||||
row = i/2
|
row = i/2
|
||||||
eq_grid.attach(self.labels[x], col, row, 1, 1)
|
eq_grid.attach(self.labels[x], col, row, 1, 1)
|
||||||
i += 1
|
i += 1
|
||||||
@ -47,12 +47,8 @@ class MainPanel(MenuPanel):
|
|||||||
self.grid.set_row_homogeneous(True)
|
self.grid.set_row_homogeneous(True)
|
||||||
self.grid.set_column_homogeneous(True)
|
self.grid.set_column_homogeneous(True)
|
||||||
|
|
||||||
if self._screen.lang_ltr:
|
grid.attach(eq_grid, 0, 0, 1, 1)
|
||||||
grid.attach(eq_grid, 0, 0, 1, 1)
|
grid.attach(self.arrangeMenuItems(items, 2, True), 1, 0, 1, 1)
|
||||||
grid.attach(self.arrangeMenuItems(items, 2, True), 1, 0, 1, 1)
|
|
||||||
else:
|
|
||||||
grid.attach(eq_grid, 1, 0, 1, 1)
|
|
||||||
grid.attach(self.arrangeMenuItems(items, 2, True), 0, 0, 1, 1)
|
|
||||||
|
|
||||||
self.grid = grid
|
self.grid = grid
|
||||||
|
|
||||||
|
@ -42,14 +42,12 @@ class MenuPanel(ScreenPanel):
|
|||||||
if not self.evaluate_enable(item[key]['enable']):
|
if not self.evaluate_enable(item[key]['enable']):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
col = i % columns if self._screen.lang_ltr == True else (columns - (i % columns) - 1)
|
col = i % columns
|
||||||
row = int(i/columns)
|
row = int(i/columns)
|
||||||
width = 1
|
width = 1
|
||||||
|
|
||||||
if expandLast == True and i+1 == l and l%2 == 1:
|
if expandLast == True and i+1 == l and l%2 == 1:
|
||||||
width = 2
|
width = 2
|
||||||
if not self._screen.lang_ltr:
|
|
||||||
col = col - 1
|
|
||||||
|
|
||||||
self.grid.attach(self.labels[key], col, row, width, 1)
|
self.grid.attach(self.labels[key], col, row, width, 1)
|
||||||
i += 1
|
i += 1
|
||||||
|
@ -108,6 +108,7 @@ class KlipperScreen(Gtk.Window):
|
|||||||
for lang in self.rtl_languages:
|
for lang in self.rtl_languages:
|
||||||
if os.getenv('LANG').lower().startswith(lang):
|
if os.getenv('LANG').lower().startswith(lang):
|
||||||
self.lang_ltr = False
|
self.lang_ltr = False
|
||||||
|
Gtk.Widget.set_default_direction(Gtk.TextDirection.RTL)
|
||||||
logger.debug("Enabling RTL mode")
|
logger.debug("Enabling RTL mode")
|
||||||
break
|
break
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user