|
4 | 4 | */ |
5 | 5 |
|
6 | 6 | public class MainWindow : Gtk.ApplicationWindow { |
7 | | - private Gtk.Stack main_stack; |
8 | | - |
9 | | - public MainWindow (Gtk.Application application) { |
10 | | - Object ( |
11 | | - application: application, |
12 | | - default_height: 300, |
13 | | - default_width: 300, |
14 | | - icon_name: "applications-development", |
15 | | - title: _("App Generator") |
16 | | - ); |
17 | | - } |
18 | | - |
19 | | - static construct { |
| 7 | + private Gtk.Stack main_stack; |
| 8 | + |
| 9 | + public MainWindow (Gtk.Application application) { |
| 10 | + Object ( |
| 11 | + application: application, |
| 12 | + default_height: 300, |
| 13 | + default_width: 300, |
| 14 | + icon_name: "applications-development", |
| 15 | + title: _("App Generator") |
| 16 | + ); |
| 17 | + } |
| 18 | + |
| 19 | + static construct { |
20 | 20 | weak Gtk.IconTheme default_theme = Gtk.IconTheme.get_for_display (Gdk.Display.get_default ()); |
21 | 21 | default_theme.add_resource_path ("/io/github/ellie_commons/app-generator/"); |
22 | 22 | } |
23 | 23 |
|
24 | | - construct { |
25 | | - var headerbar = new Gtk.HeaderBar () { |
| 24 | + construct { |
| 25 | + var headerbar = new Gtk.HeaderBar () { |
26 | 26 | title_widget = new Gtk.Label (null), |
27 | 27 | hexpand = true |
28 | 28 | }; |
29 | 29 |
|
30 | | - var project_icon = new Gtk.Image.from_icon_name ("applications-development") { |
31 | | - pixel_size = 96 |
32 | | - }; |
33 | | - |
34 | | - var title_label = new Gtk.Label (_("App Generator")); |
35 | | - title_label.add_css_class (Granite.STYLE_CLASS_H1_LABEL); |
36 | | - |
37 | | - var description_label = new Gtk.Label (_("Create an elementary OS app using one of the pre-made app templates")) { |
38 | | - wrap = true, |
39 | | - justify = CENTER |
40 | | - }; |
41 | | - description_label.add_css_class (Granite.STYLE_CLASS_DIM_LABEL); |
42 | | - |
43 | | - var left_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 6) { |
44 | | - valign = CENTER, |
45 | | - margin_start = 64, |
46 | | - margin_end = 64, |
47 | | - margin_bottom = 32 |
48 | | - }; |
49 | | - left_box.append (project_icon); |
50 | | - left_box.append (title_label); |
51 | | - left_box.append (description_label); |
52 | | - |
53 | | - var stepper = new Widgets.Stepper () { |
54 | | - margin_start = 24, |
55 | | - margin_end = 24, |
56 | | - margin_bottom = 24 |
57 | | - }; |
58 | | - stepper.add_step (_("Developer")); |
59 | | - stepper.add_step (_("Application")); |
60 | | - stepper.add_step (_("Finalized")); |
61 | | - |
62 | | - var developer_view = new Views.Developer (); |
63 | | - var form_view = new Views.Form (); |
64 | | - var success_view = new Views.Success (); |
65 | | - |
66 | | - main_stack = new Gtk.Stack () { |
67 | | - transition_type = Gtk.StackTransitionType.SLIDE_LEFT_RIGHT |
68 | | - }; |
69 | | - main_stack.add_named (developer_view, "developer"); |
70 | | - main_stack.add_named (form_view, "form"); |
71 | | - main_stack.add_named (success_view, "success"); |
72 | | - |
73 | | - var form_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); |
74 | | - form_box.append (stepper); |
75 | | - form_box.append (main_stack); |
76 | | - |
77 | | - var main_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0) { |
78 | | - hexpand = true, |
79 | | - vexpand = true |
80 | | - }; |
81 | | - |
82 | | - main_box.append (left_box); |
83 | | - main_box.append (new Gtk.Separator (Gtk.Orientation.VERTICAL) { |
84 | | - margin_bottom = 32 |
85 | | - }); |
86 | | - main_box.append (form_box); |
87 | | - |
88 | | - var toolbar_view = new Adw.ToolbarView (); |
| 30 | + var project_icon = new Gtk.Image.from_icon_name ("applications-development") { |
| 31 | + pixel_size = 96 |
| 32 | + }; |
| 33 | + |
| 34 | + var title_label = new Gtk.Label (_("App Generator")); |
| 35 | + title_label.add_css_class (Granite.STYLE_CLASS_H1_LABEL); |
| 36 | + |
| 37 | + var description_label = new Gtk.Label (_("Create an elementary OS app using one of the pre-made app templates")) { |
| 38 | + wrap = true, |
| 39 | + justify = CENTER |
| 40 | + }; |
| 41 | + description_label.add_css_class (Granite.STYLE_CLASS_DIM_LABEL); |
| 42 | + |
| 43 | + var left_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 6) { |
| 44 | + valign = CENTER, |
| 45 | + margin_start = 64, |
| 46 | + margin_end = 64, |
| 47 | + margin_bottom = 32 |
| 48 | + }; |
| 49 | + left_box.append (project_icon); |
| 50 | + left_box.append (title_label); |
| 51 | + left_box.append (description_label); |
| 52 | + |
| 53 | + var stepper = new Widgets.Stepper () { |
| 54 | + margin_start = 24, |
| 55 | + margin_end = 24, |
| 56 | + margin_bottom = 24 |
| 57 | + }; |
| 58 | + stepper.add_step (_("Developer")); |
| 59 | + stepper.add_step (_("Application")); |
| 60 | + stepper.add_step (_("Finalized")); |
| 61 | + |
| 62 | + var developer_view = new Views.Developer (); |
| 63 | + var form_view = new Views.Form (); |
| 64 | + var success_view = new Views.Success (); |
| 65 | + |
| 66 | + main_stack = new Gtk.Stack () { |
| 67 | + transition_type = Gtk.StackTransitionType.SLIDE_LEFT_RIGHT |
| 68 | + }; |
| 69 | + main_stack.add_named (developer_view, "developer"); |
| 70 | + main_stack.add_named (form_view, "form"); |
| 71 | + main_stack.add_named (success_view, "success"); |
| 72 | + |
| 73 | + var form_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); |
| 74 | + form_box.append (stepper); |
| 75 | + form_box.append (main_stack); |
| 76 | + |
| 77 | + var main_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0) { |
| 78 | + hexpand = true, |
| 79 | + vexpand = true |
| 80 | + }; |
| 81 | + |
| 82 | + main_box.append (left_box); |
| 83 | + main_box.append (new Gtk.Separator (Gtk.Orientation.VERTICAL) { |
| 84 | + margin_bottom = 32 |
| 85 | + }); |
| 86 | + main_box.append (form_box); |
| 87 | + |
| 88 | + var toolbar_view = new Adw.ToolbarView (); |
89 | 89 | toolbar_view.add_top_bar (headerbar); |
90 | 90 | toolbar_view.content = main_box; |
91 | 91 |
|
92 | | - child = toolbar_view; |
93 | | - |
94 | | - // We need to hide the title area for the split headerbar |
95 | | - var null_title = new Gtk.Grid () { |
96 | | - visible = false |
97 | | - }; |
98 | | - set_titlebar (null_title); |
99 | | - |
100 | | - // Set default elementary thme |
101 | | - var gtk_settings = Gtk.Settings.get_default (); |
102 | | - gtk_settings.gtk_icon_theme_name = "elementary"; |
103 | | - if (!(gtk_settings.gtk_theme_name.has_prefix ("io.elementary.stylesheet"))) { |
104 | | - gtk_settings.gtk_theme_name = "io.elementary.stylesheet.blueberry"; |
105 | | - } |
106 | | - |
107 | | - form_view.created.connect ((project_naame, location) => { |
108 | | - success_view.project_location = location + "/" + project_naame; |
109 | | - |
110 | | - stepper.active_index = 2; |
111 | | - main_stack.visible_child_name = "success"; |
112 | | - success_view.animation = true; |
113 | | - |
114 | | - Timeout.add_once (1000, () => { |
115 | | - success_view.animation = false; |
116 | | - }); |
117 | | - }); |
118 | | - |
119 | | - form_view.back.connect (() => { |
120 | | - main_stack.visible_child_name = "developer"; |
121 | | - }); |
122 | | - |
123 | | - developer_view.next.connect ((name, email) => { |
124 | | - stepper.active_index = 1; |
125 | | - main_stack.visible_child_name = "form"; |
126 | | - |
127 | | - form_view.developer_name = name; |
128 | | - form_view.developer_email = email; |
129 | | - }); |
130 | | - |
131 | | - success_view.back.connect (() => { |
132 | | - stepper.active_index = 0; |
133 | | - main_stack.visible_child_name = "developer"; |
134 | | - |
135 | | - developer_view.reset_form (); |
136 | | - form_view.reset_form (); |
137 | | - }); |
138 | | - } |
| 92 | + child = toolbar_view; |
| 93 | + |
| 94 | + // We need to hide the title area for the split headerbar |
| 95 | + var null_title = new Gtk.Grid () { |
| 96 | + visible = false |
| 97 | + }; |
| 98 | + set_titlebar (null_title); |
| 99 | + |
| 100 | + // Set default elementary thme |
| 101 | + var gtk_settings = Gtk.Settings.get_default (); |
| 102 | + gtk_settings.gtk_icon_theme_name = "elementary"; |
| 103 | + if (!(gtk_settings.gtk_theme_name.has_prefix ("io.elementary.stylesheet"))) { |
| 104 | + gtk_settings.gtk_theme_name = "io.elementary.stylesheet.blueberry"; |
| 105 | + } |
| 106 | + |
| 107 | + form_view.created.connect ((project_naame, location) => { |
| 108 | + success_view.project_location = location + "/" + project_naame; |
| 109 | + |
| 110 | + stepper.active_index = 2; |
| 111 | + main_stack.visible_child_name = "success"; |
| 112 | + success_view.animation = true; |
| 113 | + |
| 114 | + Timeout.add_once (1000, () => { |
| 115 | + success_view.animation = false; |
| 116 | + }); |
| 117 | + }); |
| 118 | + |
| 119 | + form_view.back.connect (() => { |
| 120 | + main_stack.visible_child_name = "developer"; |
| 121 | + }); |
| 122 | + |
| 123 | + developer_view.next.connect ((name, email) => { |
| 124 | + stepper.active_index = 1; |
| 125 | + main_stack.visible_child_name = "form"; |
| 126 | + |
| 127 | + form_view.developer_name = name; |
| 128 | + form_view.developer_email = email; |
| 129 | + }); |
| 130 | + |
| 131 | + success_view.back.connect (() => { |
| 132 | + stepper.active_index = 0; |
| 133 | + main_stack.visible_child_name = "developer"; |
| 134 | + |
| 135 | + developer_view.reset_form (); |
| 136 | + form_view.reset_form (); |
| 137 | + }); |
| 138 | + } |
139 | 139 | } |
0 commit comments