Debian Codegraph @

src/devedeng/opensave.py

raw
1 # Copyright 2014 (C) Raster Software Vigo (Sergio Costas)
2 #
3 # This file is part of DeVeDe-NG
4 #
5 # DeVeDe-NG is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License version 3
7 # as published by the Free Software Foundation.
8 #
9 # DeVeDe-NG is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>
16
17 from gi.repository import Gtk
18 import os
19 import devedeng.configuration_data
20
21
22 class opensave_window:
23
24 def __init__(self, save):
25
26 self.config = devedeng.configuration_data.configuration.get_config()
27 self.save = save
28
29 def run(self, current_file=None):
30
31 builder = Gtk.Builder()
32 builder.set_translation_domain(self.config.gettext_domain)
33
34 if self.save:
35 builder.add_from_file(os.path.join(self.config.glade, "wsave_project.ui"))
36 else:
37 builder.add_from_file(os.path.join(self.config.glade, "wopen_project.ui"))
38 builder.connect_signals(self)
39 w_window = builder.get_object("data_project")
40 if current_file is not None:
41 w_window.set_filename(current_file)
42
43 file_filter_projects = Gtk.FileFilter()
44 file_filter_projects.set_name(_("DevedeNG projects"))
45 file_filter_projects.add_pattern("*.devedeng")
46
47 file_filter_all = Gtk.FileFilter()
48 file_filter_all.set_name(_("All files"))
49 file_filter_all.add_pattern("*")
50
51 w_window.add_filter(file_filter_projects)
52 w_window.add_filter(file_filter_all)
53
54 w_window.show_all()
55 retval = w_window.run()
56 self.final_filename = w_window.get_filename()
57 w_window.destroy()
58 if (retval == 1):
59 return self.final_filename
60 else:
61 return None