This file is indexed.

/usr/share/vitables/vitables/docBrowser/helpBrowser.py is in vitables 2.1-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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
# -*- coding: utf-8 -*-
#!/usr/bin/env python

#       Copyright (C) 2005-2007 Carabos Coop. V. All rights reserved
#       Copyright (C) 2008-2011 Vicent Mas. All rights reserved
#
#       This program is free software: you can redistribute it and/or modify
#       it under the terms of the GNU General Public License as published by
#       the Free Software Foundation, either version 3 of the License, or
#       (at your option) any later version.
#
#       This program is distributed in the hope that it will be useful,
#       but WITHOUT ANY WARRANTY; without even the implied warranty of
#       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#       GNU General Public License for more details.
#
#       You should have received a copy of the GNU General Public License
#       along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
#       Author:  Vicent Mas - vmas@vitables.org

"""
The controller of the Users' Guide browser is implemented in this module.

The documentation browser is used for browsing the HTML version of the Guide
which is distributed along the source code in every supported platform.
"""

__docformat__ = 'restructuredtext'

from PyQt4 import QtCore
from PyQt4 import QtGui


import vitables.utils
from vitables.docBrowser import bookmarksDlg
from vitables.docBrowser import browserGUI

translate = QtGui.QApplication.translate


class HelpBrowser(QtCore.QObject) :
    """
    This is the controller of the ``ViTables`` documentation browser.
    Features:

    * reasonably good understanding of ``HTML`` format
    * navigation toolbar
    * session capable

      - filenames of files opened during the session are available at
          any moment
      - last session can be restored next time we open the `HelpBrowser`

    * basic bookmarks management
    """

    def __init__(self) :
        """
        Initializes the browser.

        Restore history and bookmarks from disk and makes the browser window.
        """

        super(HelpBrowser, self).__init__()

        self.vtapp = vitables.utils.getVTApp()

        # Get the bookmarks and the navigation history
        self.bookmarks = self.vtapp.config.hb_bookmarks
        self.history = self.vtapp.config.hb_history

        # create the GUI
        self.gui = browserGUI.HelpBrowserGUI(self)

        # The working directory used in QFileDialog calls
        self.working_dir = vitables.utils.getHomeDir()

        # The GUI setup is slow so it is not shown until the setup is
        # done (it avoids displaying an ugly empty widget)
        self.displaySrc('index.html')
        self.gui.show()


    def displaySrc(self, src=False):
        """
        Displays a document in the `HelpBrowser` window.

        This slot is called when:

            - :meth:`vitables.docBrowser.bookmarksDlg.BookmarksDlg.displayBookmark` is launched
            - a new item is activated in the `History` combo
            - an entry is selected in the `Bookmarks` menu

        :Parameter src: the path of the file being displayed
        """

        if src is False: # entry selected in the Bookmarks menu
            action = self.gui.sender()
            src = action.data()

        src = QtCore.QDir(src).dirName()
        src = QtCore.QDir().fromNativeSeparators(src)
        url = QtCore.QUrl(src)
        self.gui.text_browser.setSource(url)

    #########################################################
    #
    # 					File menu related slots
    #
    #########################################################

    def exitBrowser(self) :
        """
        Quit the `HelpBrowser`.

        Before quitting this slot saves session and bookmarks. Then all browser
        windows are closed. The saved state corresponds to the window on which 
        Exit is invoqued.
        """

        # Close all browsers
        self.vtapp.config.hb_history = self.history
        self.vtapp.config.hb_bookmarks = self.bookmarks
        self.vtapp.doc_browser = None
        self.gui.close()

    #########################################################
    #
    # 					View menu related slots
    #
    #########################################################

    def zoomIn(self) :
        """Increases the font size of the displayed source."""
        self.gui.text_browser.zoomIn(2)


    def zoomOut(self) :
        """Increases the font size of the displayed source."""
        self.gui.text_browser.zoomOut(2)

    #########################################################
    #
    # 					Go menu related slots
    #
    #########################################################

    def updateHome(self) :
        """
        Enables/disables the ``Go --> Home`` menu item.

        If the history list is empty the menu item is disabled. Otherwise
        it is enabled.
        """

        if self.gui.text_browser.source():
            self.gui.actions['goHome'].setEnabled(1)
        else:
            self.gui.actions['goHome'].setEnabled(0)


    def updateForward(self, available) :
        """Enables/disables the ``Go --> Forward`` menu item.

        :Parameter available: a boolean. Indicates if a Next page is available.
        """
        self.gui.actions['goForward'].setEnabled(available)


    def updateBackward(self, available) :
        """Enables/disables the ``Go --> Backward`` menu item.

        :Parameter available: a boolean. Indicates if a Previous page is available
        """
        self.gui.actions['goBackward'].setEnabled(available)

    #########################################################
    #
    # 					Bookmarks menu related slots
    #
    #########################################################

    def addBookmark(self) :
        """
        Add the current page to the bookmarks menu.
        """

        src = self.gui.text_browser.source().toString()
        src = QtCore.QDir.fromNativeSeparators(src)
        src = src.replace('///', '/')
        if self.bookmarks.count(src) :
            # if the page is already bookmarked we do nothing
            pass
        else :
            # The page is not bookmarked so we append it to the bookmarks list.
            self.bookmarks.append(src)


    def editBookmarks(self) :
        """
        Raise the dialog for editing bookmarks.
        """

        # update bookmarks list
        edit_dlg = bookmarksDlg.BookmarksDlg(self.bookmarks, self.gui)
        edit_dlg.exec_()


    def clearBookmarks(self) :
        """Clear all bookmarks."""
        self.bookmarks = []

    #########################################################
    #
    # 					History related slots
    #
    #########################################################

    def clearHistory(self) :
        """
        Clear the history of visited pages.
        """

        self.history = []
        self.gui.combo_history.clear()
        self.updateHome()


    def updateHistory(self, src) :
        """
        Updates the contents of the combo selector.

        Combo selector has to be updated when:

        - a new file is opened
        - a link is clicked in the current document
        - a bookmark is opened

        The history combobox is a visual representation of the `history list`, 
        so entries will occupy the same position in both, the list and the combo.

        :Parameter src: the path being added to the combo
        """

        url = QtCore.QDir.fromNativeSeparators(src.toString())
        url = url.replace('///', '/')
        if url not in self.history:
            self.history.append(url)
            self.gui.combo_history.addItem(url)

        self.gui.combo_history.setCurrentIndex(self.history.index(url))
        self.updateHome()

    #########################################################
    #
    # 					Help menu related slots
    #
    #########################################################

    def aboutBrowser(self) :
        """
        Shows a message box with the application `About` info.
        """

        QtGui.QMessageBox.information(self.gui, \
            translate('HelpBrowser', 'About HelpBrowser', 'A dialog caption'), 
            translate('HelpBrowser', """<html><h3>HelpBrowser</h3>
                HelpBrowser is a very simple tool for displaying the HTML
                version of the ViTables' Guide without using external programs.
                <p>Best of all... it is written using PyQt, the Python
                bindings for the Qt GUI toolkit.</html>""",
                'About Help browser text')
            )


    def aboutQt(self) :
        """
        Shows a message box with the `Qt About` info.
        """

        caption = translate('HelpBrowser', 'About Qt', 'A dialog caption')
        QtGui.QMessageBox.aboutQt(self.gui, caption)