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
|
# This file is part of pybliographer
#
# Copyright (C) 1998-2004 Frederic GOBRY
# Email : gobry@pybliographer.org
#
# 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 2
# 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, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
#
''' Defines a Dialog to open URL '''
import gobject
import gtk
from gnome import ui
import string, os
from Pyblio import Connector, Autoload
from Pyblio.GnomeUI import Utils
class OpenDialog (Connector.Publisher, Utils.GladeWindow):
""" Class implementing the Open Location dialog """
gladeinfo = { 'file': 'openurl.glade',
'root': '_w_openurl',
'name': 'openurl'
}
def __init__ (self, parent = None, has_auto = True):
Utils.GladeWindow.__init__ (self, parent)
liststore = gtk.ListStore (gobject.TYPE_STRING)
menu = self._w_combobox
menu.set_model (liststore)
cell = gtk.CellRendererText()
menu.pack_start(cell, True)
menu.add_attribute(cell, 'text', 0)
liste = Autoload.available ('format')
liste.sort ()
self.formats = [ None ]
if has_auto:
iter = liststore.append ()
liststore.set (iter, 0, _(' - According to file suffix - '))
self.ftype = None
else:
self.ftype = liste [0]
for avail in liste:
iter = liststore.append ()
liststore.set (iter, 0, avail)
self.formats += liste
menu.set_active (0)
menu.connect ("changed", self.menu_select)
return
def menu_select (self, widget):
self.ftype = self.formats [widget.get_active ()]
return
def run (self):
ret = self._w_openurl.run ()
if ret != gtk.RESPONSE_OK:
self._w_openurl.destroy ()
return (None, None)
url = self._w_url.get_text ()
self._w_openurl.destroy ()
return (url, self.ftype)
|