Kaydet (Commit) 35dd925d authored tarafından sulincix's avatar sulincix

remove gettext

üst db2b604f
......@@ -2,23 +2,13 @@ DESTDIR=/
all: clean build
build: @buildmo@
build:
mkdir -p build@prefix@/lib/ || true
cp -prfv live-installer build@prefix@/lib/
#set parmissions
chmod 755 -R build
chown root -R build
buildmo:
mkdir -p build@prefix@/share/ || true
@echo "Building the mo files"
# WARNING: the second sed below will only works correctly with the languages that don't contain "-"
for file in `ls po/*.po`; do \
lang=`echo $$file | sed 's@po/@@' | sed 's/\.po//' | sed 's/live-installer-//'`; \
install -d build@prefix@/share/live-installer/locale/$$lang/LC_MESSAGES/; \
msgfmt -o build@prefix@/share/live-installer/locale/$$lang/LC_MESSAGES/live-installer.mo $$file; \
done \
install:
cp -prfv build/* $(DESTDIR)/
......
......@@ -13,7 +13,6 @@ helpmsg(){
echo "Usage ./configure [options]"
echo " --prefix : Use custom prefix location (default /usr)"
echo " --clear : Remove alt fles"
echo " --disable-nsl : Do not build locale files"
echo " --help : Show this message"
}
#defaults
......@@ -33,21 +32,12 @@ do
exit 0
elif echo $arg | grep "^--prefix=" &>/dev/null; then
export prefix=$(echo "$arg" | sed "s/^.*=//g")
elif echo $arg | grep "^--disable-nsl" &>/dev/null; then
export nsl="false"
fi
done
#Checking program
for item in msgfmt install python3 chown chmod
do
is_exists $item
done
if [ "$nsl" == "false" ] ; then
sed -i "s|@buildmo@||g" Makefile.ac
else
sed -i "s|@buildmo@|buildmo|g" Makefile.ac
fi
sed -i "s|@prefix@|$prefix|g" Makefile.ac
echo -e " Prefix: $prefix"
echo -e " Locale-Support: $nsl"
......
from gi.repository import Gtk
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
class Dialog(Gtk.MessageDialog):
def __init__(self, style, buttons, title, text, text2=None, parent=None):
......@@ -11,7 +12,8 @@ class Dialog(Gtk.MessageDialog):
self.set_title(title)
self.set_markup(text)
self.desc = text[:30] + ' ...' if len(text) > 30 else text
if text2: self.format_secondary_markup(text2)
if text2:
self.format_secondary_markup(text2)
if parent:
self.set_transient_for(parent)
self.set_modal(True)
......@@ -26,23 +28,27 @@ class Dialog(Gtk.MessageDialog):
finally:
self.destroy()
def MessageDialog(*args):
dialog = Dialog(Gtk.MessageType.INFO, Gtk.ButtonsType.NONE, *args)
dialog.add_button(_("OK"), Gtk.ResponseType.OK)
dialog.add_button(("OK"), Gtk.ResponseType.OK)
return dialog.show()
def QuestionDialog(*args):
dialog = Dialog(Gtk.MessageType.QUESTION, Gtk.ButtonsType.NONE, *args)
dialog.add_button(_("No"), Gtk.ResponseType.NO)
dialog.add_button(_("Yes"), Gtk.ResponseType.YES)
dialog.add_button(("No"), Gtk.ResponseType.NO)
dialog.add_button(("Yes"), Gtk.ResponseType.YES)
return dialog.show()
def WarningDialog(*args):
dialog = Dialog(Gtk.MessageType.WARNING, Gtk.ButtonsType.NONE, *args)
dialog.add_button(_("OK"), Gtk.ResponseType.OK)
dialog.add_button(("OK"), Gtk.ResponseType.OK)
return dialog.show()
def ErrorDialog(*args):
dialog = Dialog(Gtk.MessageType.ERROR, Gtk.ButtonsType.NONE, *args)
dialog.add_button(_("OK"), Gtk.ResponseType.OK)
dialog.add_button(("OK"), Gtk.ResponseType.OK)
return dialog.show()
This diff is collapsed.
from gi.repository import Gtk
import gi
from frontend.gtk_interface import InstallerWindow
import sys
import subprocess
import gettext
gettext.install("live-installer", "/usr/share/locale")
sys.path.insert(1, '/usr/lib/live-installer')
from frontend.gtk_interface import InstallerWindow
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
# main entry
if __name__ == "__main__":
if ("--expert-mode" in sys.argv):
win = InstallerWindow(expert_mode=True)
else:
win = InstallerWindow()
if ("--window" not in sys.argv):
win.fullscreen()
Gtk.main()
if ("--expert-mode" in sys.argv):
win = InstallerWindow(expert_mode=True)
else:
win = InstallerWindow()
if ("--window" not in sys.argv):
win.fullscreen()
Gtk.main()
This diff is collapsed.
from gi.repository import Gtk, Gdk, WebKit2
import sys
import gi
import os
......@@ -7,13 +8,13 @@ from slideshow import Slideshow
gi.require_version("Gtk", "3.0")
gi.require_version("WebKit2", "4.0")
from gi.repository import Gtk, Gdk, WebKit2
def on_context_menu(unused_web_view, unused_context_menu,
unused_event, unused_hit_test_result):
# True will not show the menu
return True
resource_dir = './resources'
glade_file = os.path.join(resource_dir, 'interface.ui')
builder = Gtk.Builder()
......@@ -42,4 +43,3 @@ builder.get_object("notebook1").set_current_page(8)
window.show_all()
window.connect("destroy", Gtk.main_quit)
Gtk.main()
......@@ -21,9 +21,12 @@ NIGHT_IM = Image.open(TIMEZONE_RESOURCES + 'night.png').convert('RGBA')
LIGHTS_IM = Image.open(TIMEZONE_RESOURCES + 'lights.png').convert('RGBA')
DOT_IM = Image.open(TIMEZONE_RESOURCES + 'dot.png').convert('RGBA')
MAP_CENTER = (351, 246) # pixel center of where equatorial line and 0th meridian cross on our bg map; WARNING: cc.png relies on this exactly!
# pixel center of where equatorial line and 0th meridian cross on our bg map; WARNING: cc.png relies on this exactly!
MAP_CENTER = (351, 246)
MAP_SIZE = BACK_IM.size # size of the map image
assert MAP_SIZE == (752, 384), 'MAP_CENTER (et al.?) calculations depend on this size'
assert MAP_SIZE == (
752, 384), 'MAP_CENTER (et al.?) calculations depend on this size'
def debug(func):
'''Decorator to print function call details - parameters names and effective values'''
......@@ -35,28 +38,35 @@ def debug(func):
params = []
for argNo in range(func.__code__.co_argcount):
argName = func.__code__.co_varnames[argNo]
argValue = func_args[argNo] if argNo < len(func_args) else func.__defaults__[argNo - func.__code__.co_argcount]
argValue = func_args[argNo] if argNo < len(func_args) else func.__defaults__[
argNo - func.__code__.co_argcount]
params.append((argName, argValue))
for argName, argValue in list(func_kwargs.items()):
params.append((argName, argValue))
params = [ argName + ' = ' + repr(argValue) for argName, argValue in params]
params = [argName + ' = ' + repr(argValue)
for argName, argValue in params]
#print(func.__name__ + '(' + ', '.join(params) + ')')
return func(*func_args, **func_kwargs)
return wrapper
def to_float(position, wholedigits):
assert position and len(position) > 4 and wholedigits < 9
return float(position[:wholedigits + 1] + '.' + position[wholedigits + 1:])
def pixel_position(lat, lon):
"""Transform latlong pair into map pixel coordinates"""
dx = MAP_SIZE[0] / 2 / 180
dy = MAP_SIZE[1] / 2 / 90
# formulae from http://en.wikipedia.org/wiki/Miller_cylindrical_projection
x = MAP_CENTER[0] + dx * lon
y = MAP_CENTER[1] - dy * math.degrees(5/4 * math.log(math.tan(math.pi/4 + 2/5 * math.radians(lat))))
y = MAP_CENTER[1] - dy * \
math.degrees(
5/4 * math.log(math.tan(math.pi/4 + 2/5 * math.radians(lat))))
return int(x), int(y)
TZ_SPLIT_COORDS = re.compile('([+-][0-9]+)([+-][0-9]+)')
timezones = []
......@@ -64,6 +74,7 @@ region_menus = {}
Timezone = namedtuple('Timezone', 'name ccode x y'.split())
@debug
def build_timezones(_installer):
global installer, time_label, time_label_box, timezone
......@@ -73,7 +84,8 @@ def build_timezones(_installer):
cssProvider.load_from_path('./resources/style.css')
screen = Gdk.Screen.get_default()
styleContext = Gtk.StyleContext()
styleContext.add_provider_for_screen(screen, cssProvider, Gtk.STYLE_PROVIDER_PRIORITY_USER)
styleContext.add_provider_for_screen(
screen, cssProvider, Gtk.STYLE_PROVIDER_PRIORITY_USER)
# Add the label displaying current time
time_label = installer.builder.get_object("label_time")
......@@ -84,7 +96,8 @@ def build_timezones(_installer):
update_local_time_label()
# Populate timezones model
installer.builder.get_object("image_timezones").set_from_file(TIMEZONE_RESOURCES + 'bg.png')
installer.builder.get_object("image_timezones").set_from_file(
TIMEZONE_RESOURCES + 'bg.png')
def autovivified():
return defaultdict(autovivified)
......@@ -94,13 +107,16 @@ def build_timezones(_installer):
ccode, coords, name = line.split()
lat, lon = TZ_SPLIT_COORDS.search(coords).groups()
x, y = pixel_position(to_float(lat, 2), to_float(lon, 3))
if x < 0: x = MAP_SIZE[0] + x
if x < 0:
x = MAP_SIZE[0] + x
tup = Timezone(name, ccode, x, y)
submenu = hierarchy
parts = name.split('/')
for i, part in enumerate(parts, 1):
if i != len(parts): submenu = submenu[part]
else: submenu[part] = tup
if i != len(parts):
submenu = submenu[part]
else:
submenu[part] = tup
timezones.append(tup)
def _build_tz_menu(d):
......@@ -135,43 +151,53 @@ def build_timezones(_installer):
cont_menu = _build_cont_menu(hierarchy)
cont_menu.show_all()
installer.builder.get_object('cont_button').connect('event', button_callback)
installer.builder.get_object(
'cont_button').connect('event', button_callback)
installer.builder.get_object('cont_button').menu = cont_menu
installer.builder.get_object('tz_button').connect('event', button_callback)
installer.builder.get_object("event_timezones").connect('button-release-event', map_clicked)
installer.builder.get_object("event_timezones").connect(
'button-release-event', map_clicked)
adjust_time = timedelta(0)
def button_callback(button, event):
if event.type == Gdk.EventType.BUTTON_PRESS:
button.menu.popup(None, None, None, None, 0, event.time)
return True
return False
def update_local_time_label():
now = datetime.utcnow() + adjust_time
time_label.set_label(now.strftime('%H:%M'))
return True
def cont_menu_selected(widget, cont):
installer.builder.get_object("cont_button").set_label(cont)
installer.builder.get_object("tz_button").set_label(_('Select timezone'))
installer.builder.get_object("tz_button").set_label(('Select timezone'))
installer.builder.get_object("tz_button").menu = region_menus[cont]
def tz_menu_selected(widget, tz):
select_timezone(tz)
def map_clicked(widget, event, data=None):
x, y = event.x, event.y
if event.window != installer.builder.get_object("event_timezones").get_window():
dx, dy = event.window.get_position()
x, y = x + dx, y + dy
closest_timezone = min(timezones, key=lambda tz: math.sqrt((x - tz.x)**2 + (y - tz.y)**2))
closest_timezone = min(timezones, key=lambda tz: math.sqrt(
(x - tz.x)**2 + (y - tz.y)**2))
select_timezone(closest_timezone)
# Timezone offsets color coded in cc.png
# If someone can make this more robust (maintainable), I buy you lunch!
TIMEZONE_COLORS = {
......@@ -217,7 +243,9 @@ TIMEZONE_COLORS = {
ADJUST_HOURS_MINUTES = re.compile('([+-])([0-9][0-9])([0-9][0-9])')
IS_WINTER = datetime.now().timetuple().tm_yday not in list(range(80, 264)) # today is between Mar 20 and Sep 20
IS_WINTER = datetime.now().timetuple().tm_yday not in list(
range(80, 264)) # today is between Mar 20 and Sep 20
def select_timezone(tz):
# Adjust time preview to current timezone (using `date` removes need for pytz package)
......@@ -231,7 +259,8 @@ def select_timezone(tz):
cont, separator, tz_str = tz.name.partition("/")
installer.builder.get_object("cont_button").set_label(cont)
installer.builder.get_object("tz_button").set_label(tz_str.replace("_", " "))
installer.builder.get_object(
"tz_button").set_label(tz_str.replace("_", " "))
installer.builder.get_object("tz_button").menu = region_menus[cont]
update_local_time_label()
......@@ -244,15 +273,22 @@ def select_timezone(tz):
x = tz.x - (width / 2)
y = tz.y - (height / 2)
if x < 0: x = 0
if y < 0: y = 0
if (x + width) > MAP_SIZE[0]: x = MAP_SIZE[0] - width
if (y + height) > MAP_SIZE[1]: y = MAP_SIZE[1] - height
if x < 0:
x = 0
if y < 0:
y = 0
if (x + width) > MAP_SIZE[0]:
x = MAP_SIZE[0] - width
if (y + height) > MAP_SIZE[1]:
y = MAP_SIZE[1] - height
installer.builder.get_object("fixed_timezones").move(time_label_box, x, y)
def _get_x_offset():
now = datetime.utcnow().timetuple()
return - int((now.tm_hour*60 + now.tm_min - 12*60) / (24*60) * MAP_SIZE[0]) # night is centered at UTC noon (12)
# night is centered at UTC noon (12)
return - int((now.tm_hour*60 + now.tm_min - 12*60) / (24*60) * MAP_SIZE[0])
def _get_image(overlay, x, y):
"""Superpose the picture of the timezone on the map"""
......@@ -263,6 +299,7 @@ def _get_image(overlay, x, y):
# night_im = ImageChops.offset(NIGHT_IM, _get_x_offset(), 0)
# if IS_WINTER: night_im = ImageOps.flip(night_im)
# im.paste(Image.alpha_composite(night_im, LIGHTS_IM), night_im)
im.paste(DOT_IM, (int(x - DOT_IM.size[1]/2), int(y - DOT_IM.size[0]/2)), DOT_IM)
im.paste(
DOT_IM, (int(x - DOT_IM.size[1]/2), int(y - DOT_IM.size[0]/2)), DOT_IM)
return GdkPixbuf.Pixbuf.new_from_data(im.tobytes(), GdkPixbuf.Colorspace.RGB,
False, 8, im.size[0], im.size[1], im.size[0] * 3)
False, 8, im.size[0], im.size[1], im.size[0] * 3)
......@@ -19,6 +19,7 @@ def memoize(func):
class memodict(dict):
def __call__(self, *args):
return self[args]
def __missing__(self, key):
ret = self[key] = func(*key)
return ret
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment