/usr/share/pyshared/reinteract/custom_result.py is in reinteract 0.5.0-3.
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 | # Copyright 2007 Owen Taylor
#
# This file is part of Reinteract and distributed under the terms
# of the BSD license. See the file COPYING in the Reinteract
# distribution for full details.
#
########################################################################
import gtk
class CustomResult(object):
def create_widget(self):
raise NotImplementedError()
def show_menu(widget, event, save_callback=None):
"""Convenience function to create a right-click menu with a Save As option"""
toplevel = widget.get_toplevel()
menu = gtk.Menu()
menu.attach_to_widget(widget, None)
menu_item = gtk.ImageMenuItem(stock_id=gtk.STOCK_SAVE_AS)
menu_item.show()
menu.add(menu_item)
def on_selection_done(menu):
menu.destroy()
menu.connect('selection-done', on_selection_done)
def on_activate(menu):
chooser = gtk.FileChooserDialog("Save As...", toplevel, gtk.FILE_CHOOSER_ACTION_SAVE,
(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
gtk.STOCK_SAVE, gtk.RESPONSE_OK))
chooser.set_default_response(gtk.RESPONSE_OK)
response = chooser.run()
filename = None
if response == gtk.RESPONSE_OK:
filename = chooser.get_filename()
chooser.destroy()
if filename != None:
save_callback(filename)
menu_item.connect('activate', on_activate)
menu.popup(None, None, None, event.button, event.time)
|