2
* Copyright (c) 2013 Christopher Timberlake
3
* <Chris@TimberlakeTechnologies.com> -or- <www.ChristopherTimberlake.com>
5
* Permission is hereby granted, free of charge, to any person obtaining a copy
6
* of this software and associated documentation files (the "Software"), to deal
7
* in the Software without restriction, including without limitation the rights
8
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
* copies of the Software, and to permit persons to whom the Software is
10
* furnished to do so, subject to the following conditions:
12
* The above copyright notice and this permission notice shall be included in
13
* all copies or substantial portions of the Software.
15
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26
class WelcomeScreen : Gtk.Box {
28
private static const string TEXT = "Hello World!";
29
public MainWindow main_window;
31
public Granite.Widgets.WidgetWelcome lbl;
43
public WelcomeScreen(MainWindow window){
46
//Build the welcome screen!
47
lbl = new Granite.Widgets.WidgetWelcome("eStudio (Baseline)", "Beating the code into you.. One line at a time!");
49
lbl.append("document-new", "Create A Project", "A Whole New Project!");
50
lbl.append("document-open", "Open A Project", "Finish Some Old Work!");
52
//Lets connect the welcome menu to a function!
53
lbl.activated.connect (on_activated);
55
var view_contents = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 3);
57
var view = new TreeView ();
58
var listmodel = new ListStore (4, typeof (string), typeof (string),
59
typeof (string), typeof (string));
62
//view.insert_column_with_attributes (0, "Icon", new CellRendererText (), "text", 0);
63
view.insert_column_with_attributes (0, "Name", new CellRendererText (), "text", Recent.Name);
64
view.insert_column_with_attributes (1, "Type", new CellRendererText (), "text", Recent.Type);
65
view.insert_column_with_attributes (2, "Directory", new CellRendererText (), "text", Recent.Path);
68
for (var i=0;i<FileManager.rp_name.length; i++) {
69
listmodel.append (out iter);
70
listmodel.set (iter, 0, FileManager.rp_name[i], 1, FileManager.rp_type[i], 2, FileManager.rp_path[i]);
74
view.set_model (listmodel);
75
view.headers_visible = false;
76
view.set_size_request(550, 150);
78
var selection = view.get_selection ();
79
selection.changed.connect (this.on_changed);
81
view_contents.pack_start(new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0), true, true, 0);
82
view_contents.pack_start(view, false, false, 0);
83
view_contents.pack_start(new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0), true, true, 0);
85
lbl.set_content(view_contents);
91
public void on_changed (Gtk.TreeSelection selection){
96
if (selection.get_selected (out model, out iter)) {
97
model.get (iter, Recent.Path, out path);
98
FileManager.OpenProject(path, this.main_window);
101
private void on_activated(int index) {
104
case 0: // New Project
105
var newproj = new CreateProject_Dialog(main_window);
107
newproj.window_position = Gtk.WindowPosition.CENTER;
110
case 1: // Existing Project
111
var file_chooser = new FileChooserDialog ("Open Project", main_window,
112
FileChooserAction.SELECT_FOLDER,
113
Stock.CANCEL, ResponseType.CANCEL,
114
Stock.OPEN, ResponseType.ACCEPT);
115
if (file_chooser.run () == ResponseType.ACCEPT) {
116
FileManager.OpenProject(file_chooser.get_filename (), main_window);
118
file_chooser.destroy ();