/usr/lib/python2.7/dist-packages/tryton/gui/window/view_form/view/form_gtk/url.py is in tryton-client 3.8.4-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | # This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
import gtk
from .char import Char
import webbrowser
import tryton.common as common
from tryton.config import CONFIG
class URL(Char):
"url"
def __init__(self, view, attrs):
super(URL, self).__init__(view, attrs)
self.tooltips = common.Tooltips()
self.button = gtk.Button()
img = gtk.Image()
img.set_from_stock('tryton-web-browser', gtk.ICON_SIZE_SMALL_TOOLBAR)
self.button.set_image(img)
self.button.set_relief(gtk.RELIEF_NONE)
self.button.connect('clicked', self.button_clicked)
self.button.set_alignment(0.5, 0.5)
self.widget.pack_start(self.button, expand=False, fill=False)
self.widget.set_focus_chain([self.entry])
def display(self, record, field):
super(URL, self).display(record, field)
self.set_tooltips()
if record and 'icon' in self.attrs:
icon = self.attrs['icon']
if icon in record.group.fields:
value = record[icon].get_client(record) or 'tryton-web-browser'
else:
value = icon
common.ICONFACTORY.register_icon(value)
img = gtk.Image()
img.set_from_stock(value, gtk.ICON_SIZE_SMALL_TOOLBAR)
self.button.set_image(img)
def set_tooltips(self):
value = self.entry.get_text()
if value:
self.tooltips.enable()
self.tooltips.set_tip(self.button, value)
else:
self.tooltips.set_tip(self.button, '')
self.tooltips.disable()
def _readonly_set(self, value):
super(URL, self)._readonly_set(value)
if value:
self.entry.hide()
else:
self.entry.show()
if value and CONFIG['client.fast_tabbing']:
self.widget.set_focus_chain([self.button])
else:
self.widget.set_focus_chain([self.entry])
self.button.set_sensitive(True)
def button_clicked(self, widget):
value = self.entry.get_text()
if value:
webbrowser.open(value, new=2)
class Email(URL):
"email"
def button_clicked(self, widget):
value = self.entry.get_text()
if value:
webbrowser.open('mailto:%s' % value, new=2)
def set_tooltips(self):
value = self.entry.get_text()
if value:
self.tooltips.enable()
self.tooltips.set_tip(self.button, 'mailto:%s' % value)
else:
self.tooltips.set_tip(self.button, '')
self.tooltips.disable()
class CallTo(URL):
"call to"
def button_clicked(self, widget):
value = self.entry.get_text()
if value:
webbrowser.open('callto:%s' % value, new=2)
def set_tooltips(self):
value = self.entry.get_text()
if value:
self.tooltips.enable()
self.tooltips.set_tip(self.button, 'callto:%s' % value)
else:
self.tooltips.set_tip(self.button, '')
self.tooltips.disable()
class SIP(URL):
"sip"
def button_clicked(self, widget):
value = self.entry.get_text()
if value:
webbrowser.open('sip:%s' % value, new=2)
def set_tooltips(self):
value = self.entry.get_text()
if value:
self.tooltips.enable()
self.tooltips.set_tip(self.button, 'sip:%s' % value)
else:
self.tooltips.set_tip(self.button, '')
self.tooltips.disable()
|