3 Module for displaying dialogs related to errors, warnings, notifications,
6 __copyright__
= "Copyright (c) 2002-2005 Free Software Foundation, Inc."
8 Straw is free software; you can redistribute it and/or modify it under the
9 terms of the GNU General Public License as published by the Free Software
10 Foundation; either version 2 of the License, or (at your option) any later
13 Straw is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License along with
18 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
19 Place - Suite 330, Boston, MA 02111-1307, USA. """
27 import FeedCategoryList
37 def _setup_filechooser_dialog(title
, action
, extra_widget_title
):
39 Setup the file chooser dialog. This includes an extra widget (a combobox)
40 to include the categories to import or export
42 dialog
= gtk
.FileChooserDialog(title
, action
=action
,
43 buttons
=(gtk
.STOCK_CANCEL
,
45 gtk
.STOCK_OK
, gtk
.RESPONSE_OK
))
46 category_list
= FeedCategoryList
.get_instance()
47 model
= gtk
.ListStore(gobject
.TYPE_STRING
, gobject
.TYPE_PYOBJECT
)
48 combobox
= gtk
.ComboBox(model
)
49 celltitle
= gtk
.CellRendererText()
50 combobox
.pack_start(celltitle
,False)
51 combobox
.add_attribute(celltitle
, 'text', 0)
55 model
.set(it
, 0, category_list
.all_category
.title
,
56 1, category_list
.all_category
)
59 for category
in category_list
.user_categories
:
61 model
.set(it
, 0, category
.title
, 1, category
)
64 combobox
.set_active(0)
65 label
= gtk
.Label(extra_widget_title
)
66 label
.set_alignment(1.0,0.5)
67 hbox
= gtk
.HBox(spacing
=6)
68 hbox
.pack_start(label
,True,True,0)
69 hbox
.pack_end(combobox
,False,False,0)
72 dialog
.set_extra_widget(hbox
)
73 return (dialog
, combobox
)
76 def export_subscriptions(parent
):
77 (dialog
,combobox
) = _setup_filechooser_dialog(_("Export Subscriptions"),
78 gtk
.FILE_CHOOSER_ACTION_SAVE
,
79 _("Select category to export:"))
80 def selection_changed(widget
, dialog
):
81 model
= widget
.get_model()
82 category
= model
[widget
.get_active()][1]
83 dialog
.set_current_name("Straw-%s.xml" % category
.title
)
85 combobox
.connect('changed',
88 selection_changed(combobox
, dialog
)
89 dialog
.set_transient_for(parent
)
90 response
= dialog
.run()
91 if response
== gtk
.RESPONSE_OK
:
92 filename
= dialog
.get_filename()
93 model
= combobox
.get_model()
94 cat
= model
[combobox
.get_active()][1]
95 OPMLExport
.export(cat
.title
, cat
.feeds
, filename
)
98 def import_subscriptions(parent
):
99 (dialog
,combobox
) = _setup_filechooser_dialog(_("Import Subscriptions"),
100 gtk
.FILE_CHOOSER_ACTION_OPEN
,
101 _("Add new subscriptions in:"))
102 ffilter
= gtk
.FileFilter()
103 ffilter
.set_name(_("OPML Files Only"))
104 ffilter
.add_pattern("*.xml")
105 ffilter
.add_pattern("*.opml")
106 dialog
.add_filter(ffilter
)
107 dialog
.set_transient_for(parent
)
108 response
= dialog
.run()
109 if response
== gtk
.RESPONSE_OK
:
110 filename
= dialog
.get_filename()
111 model
= combobox
.get_model()
112 cat
= model
[combobox
.get_active()][1]
114 OPMLImport
.import_opml(filename
, cat
)
117 def report_error(primary
, secondary
, parent
=None):
118 dialog
= gtk
.MessageDialog(parent
,
119 type=gtk
.MESSAGE_ERROR
,
120 buttons
=gtk
.BUTTONS_OK
,
121 message_format
=primary
)
122 dialog
.format_secondary_text(secondary
)
123 response
= dialog
.run()
127 def report_offline_status(parent
=None):
128 dialog
= gtk
.MessageDialog(parent
,
129 type=gtk
.MESSAGE_WARNING
,
130 buttons
=gtk
.BUTTONS_OK_CANCEL
,
131 message_format
="You Are Offline!")
132 dialog
.format_secondary_markup(_("You are currently reading offline. Would you like to go online now?"))
133 response
= dialog
.run()
137 def confirm_delete(primary
, secondary
,parent
=None):
138 dialog
= gtk
.MessageDialog(parent
,
139 type=gtk
.MESSAGE_QUESTION
,
140 buttons
=gtk
.BUTTONS_OK_CANCEL
,
141 message_format
=primary
)
142 dialog
.format_secondary_text(secondary
)
143 response
= dialog
.run()
148 iconfile
= os
.path
.join(utils
.find_image_dir(),"straw.png")
149 logo
= gtk
.gdk
.pixbuf_new_from_file(iconfile
)
150 description
= _("A feed aggregator for the GNOME Desktop")
151 straw_copyright
= u
"""
152 Copyright \xa9 2002-2004 Juri Pakaste
153 Copyright \xa9 2005-2007 Straw Contributors"""
155 u
"Iain McCoy <iain@mccoy.id.au>",
156 u
"Jan Alonzo <jmalonzo@unpluggable.com>",
157 u
"Juri Pakaste <juri@iki.fi>",
158 u
"Leandro Lameiro <lameiro@gmail.com>",
159 u
"Lucas Nussbaum <lucas@lucas-nussbaum.net>",
160 u
"Mark Pilgrim (feedparser and feedfinder)",
161 u
"Olivier Crete <tester@tester.ca>",
162 u
"Ryan P. Skadberg <skadz@stigmata.org>",
163 u
"Scott Douglas-Watson <sdouglaswatson@yahoo.co.uk>",
164 u
"Terje R\xf8sten (distutils)",
165 u
"Tuukka Hastrup <tuukka@iki.fi>"]
168 u
"Jakub 'jimmac' Steiner"
172 u
"GNOME i18n Project and Translators<http://developer.gnome.org/projects/gtp/>",
173 u
"Juri Pakaste <juri@iki.fi>",
174 u
"Martin Steldinger <tribble@hanfplantage.de>",
175 u
"David Rousseau <boiteaflood@wanadoo.fr>",
176 u
"Sergei Vavinov <svv@cmc.msu.ru>",
177 u
"Terje R\xf8sten <terjeros@phys.ntnu.no>",
178 u
"Francisco J. Fernandez <franciscojavier.fernandez.serrador@hispalinux.es>",
179 u
"Elros Cyriatan (Dutch Translation)"
182 translator_credits
= 'translator_credits'
183 about
= gtk
.AboutDialog()
184 about
.set_name(constants
.APPNAME
)
185 about
.set_version(constants
.VERSION
)
186 about
.set_copyright(straw_copyright
)
187 about
.set_comments(description
)
188 about
.set_authors(people
)
189 artists
.append(u
'Juri Pakaste')
190 about
.set_artists(artists
)
192 about
.set_translator_credits(translator_credits
)
193 about
.set_license(__license__
)
194 gtk
.about_dialog_set_url_hook(lambda about
, url
: utils
.url_show(url
))
195 about
.set_website(constants
.STRAW_URL
)
196 about
.set_website_label(constants
.STRAW_URL
)
197 about
.connect('response', lambda widget
, response
: widget
.destroy())