This file is indexed.

/usr/share/pyshared/ase/gui/widgets.py is in python-ase 3.6.0.2515-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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
from gettext import gettext as _
import gtk


class Number(gtk.SpinButton):
    def __init__(self, value=0,
                 lower=0, upper=10000,
                 step_incr=1, page_incr=10,
                 climb_rate=0.5, digits=0):
        self.adj = gtk.Adjustment(value, lower, upper, step_incr, page_incr, 0)
        gtk.SpinButton.__init__(self, self.adj, climb_rate, digits)

    def connect(self, *args):
        return self.adj.connect(*args)


class Menu:
    def __init__(self, menubar, name, items):
        self.items = {}
        menu = gtk.Menu()
        for data in items:
            text = data[0]
            callback = data[1]
            args = data[2:]
            menuitem = gtk.MenuItem(text)
            menu.append(menuitem)
            menuitem.connect('activate', callback, *args)
            menuitem.show()
            self.items[text] = menuitem
        menuitem = gtk.MenuItem(name)
        menubar.append(menuitem)
        menuitem.set_submenu(menu)
        menuitem.show()


class Help(gtk.Window):
    __instance = None
    def __new__(cls, *args, **kwargs):
        # Make this a singleton.
        if Help.__instance is None:
            Help.__instance = gtk.Window.__new__(cls, *args, **kwargs)
        return Help.__instance
    def __init__(self, text):
        # Now, __init__ may be called multiple times!
        if not hasattr(self, '_initialized'):
            self.initialize(text)
        else:
            self.set_text(text)
        self.present()  # Show the window.
        
    def initialize(self, text):
        gtk.Window.__init__(self)
        self.set_title(_("Help"))
        self._initialized = True
        vbox = gtk.VBox()
        self.add(vbox)
        self.label = pack(vbox, gtk.Label())
        self.label.set_line_wrap(True)
        self.set_text(text)
        close = gtk.Button(_('Close'))
        pack(vbox, [close])
        close.connect('clicked', self.destroy)
        self.connect("delete-event", self.destroy) 
        self.show_all()

    def set_text(self, text):
        # Count line length
        linelen = max([len(x) for x in text.split('\n')])
        text = text.replace('<c>', '<span foreground="blue">')
        text = text.replace('</c>', '</span>')
        self.label.set_width_chars(linelen)
        self.label.set_line_wrap(False)
        self.label.set_markup(text)

    def destroy(self, *args):
        self.hide()
        return True  # Prevents destruction of the window.
        
def help(text):
    button = gtk.Button(_('Help'))
    button.connect('clicked', lambda widget, text=text: Help(text))
    return button


class Window(gtk.Window):
    def __init__(self, gui):
        self.gui = gui
        gtk.Window.__init__(self)
        self.set_title(_('Constraints'))
        vbox = gtk.VBox()
        b = pack(vbox, [gtk.Button(_('Constrain')),
                        gtk.Label(_(' selected atoms'))])[0]
        b.connect('clicked', self.selected)
        b = pack(vbox, [gtk.Button(_('Constrain')),
                        gtk.Label(_(' immobile atoms:'))])[0]
        b.connect('clicked', self.immobile)
        b = pack(vbox, gtk.Button(_('Clear constraint')))
        b.connect('clicked', self.clear)
        close = pack(vbox, gtk.Button(_('Close')))
        close.connect('clicked', lambda widget: self.destroy())
        self.add(vbox)
        vbox.show()
        self.show()

def pack(vbox, widgets, end=False, bottom=False, expand=False, padding=0):
    if not isinstance(widgets, list):
        widgets.show()
        if bottom:
            vbox.pack_end(widgets, expand, expand, padding)
        else:
            vbox.pack_start(widgets, expand, expand, padding)
        return widgets
    hbox = gtk.HBox(0, 0)
    hbox.show()
    if bottom:
        vbox.pack_end(hbox, expand, expand, padding)
    else:
        vbox.pack_start(hbox, expand, expand, padding)
    for widget in widgets:
        if type(widget) is gtk.Entry:
            widget.set_size_request(widget.get_max_length() * 9, 24)
        widget.show()
        if end and widget is widgets[-1]:
            hbox.pack_end(widget, expand, expand, padding)
        else:
            hbox.pack_start(widget, expand, expand, padding)
    return widgets

class cancel_apply_ok(gtk.HButtonBox):
    "Widget with Cancel, Apply and OK buttons.  The arguments are callbacks."
    def __init__(self, cancel, apply, ok):
        gtk.HButtonBox.__init__(self)
        cancel_but = gtk.Button(stock=gtk.STOCK_CANCEL)
        cancel_but.connect('clicked', cancel)
        apply_but = gtk.Button(stock=gtk.STOCK_APPLY)
        apply_but.connect('clicked', apply)
        ok_but = gtk.Button(stock=gtk.STOCK_OK)
        ok_but.connect('clicked', ok)
        for w in (cancel_but, apply_but, ok_but):
            self.pack_start(w, 0, 0)
            w.show()
        #self.show_all()
        
def oops(message, message2=None):
    dialog = gtk.MessageDialog(flags=gtk.DIALOG_MODAL,
                               type=gtk.MESSAGE_WARNING,
                               buttons=gtk.BUTTONS_CLOSE,
                               message_format=message)
    try:
        dialog.format_secondary_text(message2)
    except AttributeError:
        print >>sys.stderr, message
        print >>sys.stderr, message2
    dialog.connect('response', lambda x, y, dialog=dialog: dialog.destroy())
    dialog.show()

class AseGuiCancelException(Exception):
    pass