179
178
self.menu_entry = False
180
179
self.toolbar_entry = False
182
self.menu_item = gtk.MenuItem(_("Export the tasks currently listed"))
181
self.menu_item = Gtk.MenuItem(_("Export the tasks currently listed"))
183
182
self.menu_item.connect('activate', self.show_dialog)
184
183
self.menu_item.show()
186
self.tb_button = gtk.ToolButton(gtk.STOCK_PRINT)
185
self.tb_button = Gtk.ToolButton(Gtk.STOCK_PRINT)
187
186
self.tb_button.connect('clicked', self.show_dialog)
188
187
self.tb_button.show()
190
builder = gtk.Builder()
189
builder = Gtk.Builder()
191
190
cur_dir = os.path.dirname(os.path.abspath(__file__))
192
191
builder_file = os.path.join(cur_dir, "export.ui")
193
192
builder.add_from_file(builder_file)
195
194
self.combo = builder.get_object("export_combo_templ")
196
templates_list = gtk.ListStore(gobject.TYPE_STRING,
198
gobject.TYPE_STRING, gobject.TYPE_STRING
195
templates_list = Gtk.ListStore(
196
GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_STRING,
200
198
self.combo.set_model(templates_list)
201
cell = gtk.CellRendererText()
199
cell = Gtk.CellRendererText()
202
200
self.combo.pack_start(cell, True)
203
201
self.combo.add_attribute(cell, 'text', 1)
293
291
description, image = model[active][2], model[active][3]
296
pixbuf = gtk.gdk.pixbuf_new_from_file(image)
294
pixbuf = GdkPixbuf.Pixbuf.new_from_file(image)
297
295
width, height = self.export_image.get_size_request()
298
296
pixbuf = pixbuf.scale_simple(width, height,
299
gtk.gdk.INTERP_BILINEAR)
297
GdkPixbuf.InterpType.BILINEAR)
300
298
self.export_image.set_from_pixbuf(pixbuf)
302
300
self.export_image.clear()
309
307
def show_error_dialog(self, message):
310
308
""" Display an error """
311
dialog = gtk.MessageDialog(
309
dialog = Gtk.MessageDialog(
312
310
parent=self.export_dialog,
313
flags=gtk.DIALOG_DESTROY_WITH_PARENT,
314
type=gtk.MESSAGE_ERROR,
315
buttons=gtk.BUTTONS_OK,
311
flags=Gtk.DialogFlags.DESTROY_WITH_PARENT,
312
type=Gtk.MessageType.ERROR,
313
buttons=Gtk.ButtonsType.OK,
316
314
message_format=message)
320
318
def choose_file(self):
321
319
""" Let user choose a file to save and return its path """
322
chooser = gtk.FileChooserDialog(
320
chooser = Gtk.FileChooserDialog(
323
321
title=_("Choose where to save your list"),
324
322
parent=self.export_dialog,
325
action=gtk.FILE_CHOOSER_ACTION_SAVE,
326
buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
327
gtk.STOCK_SAVE, gtk.RESPONSE_OK))
323
action=Gtk.FileChooserAction.SAVE,
324
buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
325
Gtk.STOCK_SAVE, Gtk.ResponseType.OK))
328
326
chooser.set_do_overwrite_confirmation(True)
329
chooser.set_default_response(gtk.RESPONSE_OK)
327
chooser.set_default_response(Gtk.ResponseType.OK)
330
328
chooser.set_current_folder(get_desktop_dir())
331
329
response = chooser.run()
332
330
filename = chooser.get_filename()
333
331
chooser.destroy()
334
if response == gtk.RESPONSE_OK:
332
if response == Gtk.ResponseType.OK: