Commit 6cab997b authored by Daniel Brötzmann's avatar Daniel Brötzmann

Use Q_() for specific translations, replace birthday popover by entry icon

parent 6c1edc12
Pipeline #3904 passed with stages
in 3 minutes and 12 seconds
......@@ -29,6 +29,7 @@ from nbxmpp import Node
from gajim import gtkgui_helpers
from gajim.common import app
from gajim.common.i18n import _
from gajim.common.i18n import Q_
from gajim.common.const import AvatarSize
from gajim.common.const import URIType
from gajim.common.helpers import open_uri
......@@ -44,22 +45,22 @@ LABEL_DICT = {
'NICKNAME': _('Nickname'),
'PHOTO': _('Avatar'),
'BDAY': _('Birthday'),
'ADR': _('Address'),
'ADR': Q_('?profile:Address'),
'TEL': _('Phone No.'),
'EMAIL': _('Email'),
'JABBERID': _('XMPP Address'),
'TITLE': _('Title'),
'ROLE': _('Role'),
'TITLE': Q_('?profile:Title'),
'ROLE': Q_('?profile:Role'),
'ORG': _('Organisation'),
'ORGUNIT': _('Unit'),
'ORGNAME': _('Name'),
'NOTE': _('Note'),
'UID': _('uid'),
'ORGUNIT': Q_('?profile organisation:Unit'),
'ORGNAME': Q_('?profile organisation:Name'),
'NOTE': Q_('?profile:Note'),
'UID': Q_('?profile:uid'),
'URL': _('URL'),
'KEY': _('key'),
'KEY': Q_('?profile:key'),
'DESC': _('Description'),
'HOME': _('Home'),
'WORK': _('Work')}
'HOME': Q_('?profile:Home'),
'WORK': Q_('?profile:Work')}
ADR_LIST = [('STREET', ''), ('EXTADD', ''),
('LOCALITY', ''), ('REGION', ''),
......@@ -472,6 +473,7 @@ class BDAYRow(CommonRow):
'focus-in-event', self._on_entry_focus_in_event)
self.entry.connect(
'changed', self._on_entry_changed)
# Build calendar button
self.calendar_button = Gtk.MenuButton()
image = Gtk.Image.new_from_icon_name(
......@@ -481,6 +483,8 @@ class BDAYRow(CommonRow):
'clicked', self._on_calendar_button_clicked)
self.value.add(self.entry)
self.value.add(self.calendar_button)
# Build calendar popover
self.calendar_popover = Gtk.Popover()
self.calendar = Gtk.Calendar(year=1980, month=5, day=15)
self.calendar.set_visible(True)
......@@ -488,19 +492,6 @@ class BDAYRow(CommonRow):
'day-selected', self._on_calendar_day_selected)
self.calendar_popover.add(self.calendar)
self.calendar_button.set_popover(self.calendar_popover)
# Build warning popover
self.date_entry_popover = Gtk.Popover.new(self.entry)
self.date_entry_popover.set_modal(False)
box = Gtk.Box(spacing=12)
image = Gtk.Image.new_from_icon_name(
'dialog-warning-symbolic', Gtk.IconSize.BUTTON)
image.get_style_context().add_class('warning-color')
label = Gtk.Label(label=_('Please use: YYYY-MM-DD'))
label.get_style_context().add_class('bold')
box.add(image)
box.add(label)
box.show_all()
self.date_entry_popover.add(box)
else:
# Display date of birth with locale's date format
try:
......@@ -539,18 +530,13 @@ class BDAYRow(CommonRow):
self.entry.set_text(date_str)
def _on_entry_focus_out_event(self, widget, event):
# TODO: Better logic and locking
if self._check_birthday():
self.date_entry_popover.popdown()
else:
self.date_entry_popover.popup()
# self.entry.grab_focus()
self._check_birthday()
def _on_entry_focus_in_event(self, widget, event):
self.date_entry_popover.popdown()
self._check_birthday()
def _on_entry_changed(self, widget):
self.date_entry_popover.popdown()
self._check_birthday()
def _check_birthday(self):
birthday = self.entry.get_text()
......@@ -559,8 +545,13 @@ class BDAYRow(CommonRow):
try:
datetime.datetime.strptime(birthday, '%Y-%m-%d')
except ValueError:
self.date_entry_popover.popup()
self.entry.set_icon_from_icon_name(Gtk.EntryIconPosition.SECONDARY,
'dialog-warning-symbolic')
self.entry.set_icon_tooltip_text(Gtk.EntryIconPosition.SECONDARY,
_('Please use: YYYY-MM-DD'))
return False
self.entry.set_icon_from_icon_name(Gtk.EntryIconPosition.SECONDARY,
None)
return True
def get_node(self):
......
......@@ -9,7 +9,9 @@ import nbxmpp
from gajim.common import app
from gajim.common import ged
from gajim.common.i18n import _
from gajim.common.i18n import Q_
from gajim.common.helpers import event_filter
from gajim.gtk.profile_grid import Profile
log = logging.getLogger('gajim.profile')
......@@ -23,13 +25,13 @@ MENU_DICT = {
'TEL': _('Phone No.'),
'EMAIL': _('Email'),
'JABBERID': _('XMPP Address'),
'TITLE': _('Title'),
'ROLE': _('Role'),
'ORG': _('Organisation'),
'NOTE': _('Note'),
'UID': _('uid'),
'TITLE': Q_('?profile:Title'),
'ROLE': Q_('?profile:Role'),
'ORG': Q_('?profile:Organisation'),
'NOTE': Q_('?profile:Note'),
'UID': Q_('?profile:uid'),
'URL': _('URL'),
'KEY': _('key'),
'KEY': Q_('?profile:key'),
'DESC': _('Description')}
......
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