Beispiel #1
0
 def __init__(self, tback='', fname=None, plugins=''):
     self.sourceforge = sourceforge()
     self.tback = tback
     self.fname = fname
     self.plugins = plugins
     self.autogen = False
    def __init__(self, title, exception_text, w3af_version, filename, **data):
        '''
        The first window that the user sees when a bug was detected.
        '''
        super(bug_report_window,self).__init__(type=gtk.WINDOW_TOPLEVEL)
        
        # Set generic window settings
        self.set_modal(True)
        self.set_title(title)
        self.set_icon_from_file('core/ui/gtkUi/data/w3af_icon.png')
        self.connect("delete-event", gtk.main_quit)
        self.vbox = gtk.VBox()
        
        # Internal variables
        self.bug_url = None
        self.manual_bug_report = 'https://sourceforge.net/apps/trac/w3af/newticket'
        
        # Save the info for later
        self.exception_text = exception_text
        self.w3af_version = w3af_version
        self.filename = filename
        self.data = data
        
        # the label for the title
        self.title_label = gtk.Label()
        self.title_label.set_line_wrap(True)
        label_text = _('\n<b>An unhandled exception was raised:</b>\n\n')
        self.title_label.set_markup( label_text )
        self.title_label.show()
        
        # A gtk.TextView for the exception
        sw = gtk.ScrolledWindow()
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        
        self.text_view = gtk.TextView()
        self.text_view.set_size_request(150, 250) 
        self.text_view.set_editable(False)
        self.text_view.set_wrap_mode( gtk.WRAP_CHAR )

        buffer = self.text_view.get_buffer()
        buffer.set_text(exception_text)
        
        sw.add(self.text_view)
        
        # the label for the rest of the message
        self.label = gtk.Label()
        self.label.set_line_wrap(True)
        label_text = _("<i>All this info is in a file called ") + filename + _(" for later review.</i>\n\n")
        label_text += _('If you wish, <b>you can contribute</b> to the w3af project and submit this')
        label_text += _(' bug to the sourceforge\'s Trac system from within this window.')
        label_text += _(' It\'s a simple <i>two step process</i>.\n\n')
        label_text += _('w3af will only send the exception traceback and the version information to')
        label_text += _(' sourceforge, no personal or confidencial information is collected.\n\n')
        label_text += _('Please click "Ok" to contribute, or "Cancel" to go back to w3af (possibly with an invalid state).\n')
        self.label.set_markup( label_text )
        self.label.show()
        
        self.vbox.pack_start(self.title_label, True, False)
        self.vbox.pack_start(sw, False, False)
        self.vbox.pack_start(self.label, True, False)
        
        # the buttons
        self.hbox = gtk.HBox()
        self.butt_send = gtk.Button(stock=gtk.STOCK_OK)
        self.butt_send.connect("clicked", self._handle_send )
        self.hbox.pack_start(self.butt_send, True, False)
        
        self.butt_cancel = gtk.Button(stock=gtk.STOCK_CANCEL)
        self.butt_cancel.connect("clicked", self._handle_cancel )
        self.hbox.pack_start(self.butt_cancel, True, False)
        self.vbox.pack_start(self.hbox, True, False)
        
        # Init sourceforge object
        self.sourceforge = sourceforge()
        
        #self.resize(400,450)
        self.add(self.vbox)
        self.show_all()
        
        # This is a quick fix to get around the problem generated by "set_selectable"
        # that selects the text by default
        self.label.select_region(0, 0)