Skip to content

Commit 997774b

Browse files
committed
MainWindow: reduce variable scope and organize
1 parent 0405b6f commit 997774b

1 file changed

Lines changed: 26 additions & 33 deletions

File tree

src/MainWindow.vala

Lines changed: 26 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,13 @@
2121
public class Scratch.MainWindow : Hdy.Window {
2222
public const int FONT_SIZE_MAX = 72;
2323
public const int FONT_SIZE_MIN = 7;
24+
2425
private const uint MAX_SEARCH_TEXT_LENGTH = 255;
26+
private static string base_title;
2527

26-
public Scratch.Application app { get; private set; }
2728
public bool restore_docs { get; construct; }
2829
public RestoreOverride restore_override { get; construct set; }
30+
2931
public string default_globalsearch_path {
3032
owned get {
3133
if (document_view.current_document != null) {
@@ -38,32 +40,10 @@ public class Scratch.MainWindow : Hdy.Window {
3840
}
3941
}
4042

41-
public Scratch.Widgets.DocumentView document_view;
42-
43-
// Widgets
44-
public Scratch.HeaderBar toolbar;
45-
public Scratch.Widgets.SearchBar search_bar;
46-
private Code.WelcomeView welcome_view;
47-
private Code.Terminal terminal;
48-
private FolderManager.FileView folder_manager_view;
49-
private Scratch.Services.DocumentManager document_manager;
50-
private Gtk.EventControllerKey key_controller;
51-
// Plugins
52-
private Scratch.Services.PluginsManager plugins;
53-
54-
// Widgets for Plugins
55-
public Code.Sidebar sidebar;
56-
57-
private Gtk.Paned hp1;
58-
private Gtk.Paned vp;
59-
private Gtk.Stack content_stack;
60-
61-
public Gtk.Clipboard clipboard;
62-
63-
// Delegates
64-
delegate void HookFunc ();
65-
66-
public SimpleActionGroup actions { get; construct; }
43+
public Code.Sidebar sidebar { get; private set; }
44+
public Scratch.Application app { get; private set; }
45+
public Scratch.Widgets.DocumentView document_view { get; private set; }
46+
public SimpleActionGroup actions { get; private set; }
6747

6848
public const string ACTION_GROUP = "win";
6949
public const string ACTION_PREFIX = ACTION_GROUP + ".";
@@ -120,12 +100,6 @@ public class Scratch.MainWindow : Hdy.Window {
120100
public const string ACTION_OPEN_IN_NEW_WINDOW = "action-open-in-new-window";
121101

122102
public static Gee.MultiMap<string, string> action_accelerators = new Gee.HashMultiMap<string, string> ();
123-
private static string base_title;
124-
125-
private ulong color_scheme_listener_handler_id = 0;
126-
127-
private Services.GitManager git_manager;
128-
private bool is_first_window;
129103

130104
private const ActionEntry[] ACTION_ENTRIES = {
131105
{ ACTION_CLONE_REPO, action_clone_repo },
@@ -181,6 +155,25 @@ public class Scratch.MainWindow : Hdy.Window {
181155
{ ACTION_OPEN_IN_NEW_WINDOW, action_open_in_new_window, "s" },
182156
};
183157

158+
private bool is_first_window;
159+
private ulong color_scheme_listener_handler_id = 0;
160+
161+
private Code.Terminal terminal;
162+
private Code.WelcomeView welcome_view;
163+
private FolderManager.FileView folder_manager_view;
164+
private Gtk.Clipboard clipboard;
165+
private Gtk.EventControllerKey key_controller;
166+
private Gtk.Paned hp1;
167+
private Gtk.Paned vp;
168+
private Gtk.Stack content_stack;
169+
private Scratch.HeaderBar toolbar;
170+
private Scratch.Services.DocumentManager document_manager;
171+
private Scratch.Services.PluginsManager plugins;
172+
private Scratch.Widgets.SearchBar search_bar;
173+
private Services.GitManager git_manager;
174+
175+
private delegate void HookFunc ();
176+
184177
public MainWindow (bool restore_docs) {
185178
Object (
186179
icon_name: Constants.PROJECT_NAME,

0 commit comments

Comments
 (0)