Forráskód Böngészése

tools: fix GTK warnings

Daniele Bartolini 5 napja
szülő
commit
7e07f7c1bb

+ 5 - 6
tools/level_editor/level_tree_view.vala

@@ -163,12 +163,6 @@ public class LevelTreeView : Gtk.Box
 
 		// Setup sort menu button popover.
 		_sort_items_box = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
-
-		Gtk.RadioButton? button = null;
-		for (int i = 0; i < SortMode.COUNT; ++i)
-			button = add_sort_item(button, (SortMode)i);
-
-		_sort_items_box.show_all();
 		_sort_items_popover = new Gtk.Popover(null);
 		_sort_items_popover.add(_sort_items_box);
 		_sort_items = new Gtk.MenuButton();
@@ -179,6 +173,11 @@ public class LevelTreeView : Gtk.Box
 		_sort_items.can_focus = false;
 		_sort_items.set_popover(_sort_items_popover);
 
+		Gtk.RadioButton? button = null;
+		for (int i = 0; i < SortMode.COUNT; ++i)
+			button = add_sort_item(button, (SortMode)i);
+		_sort_items_box.show_all();
+
 		var tree_control = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0);
 		tree_control.pack_start(_filter_entry, true, true);
 		tree_control.pack_end(_sort_items, false, false);

+ 9 - 1
tools/level_editor/preferences_dialog.vala

@@ -7,7 +7,7 @@ namespace Crown
 {
 public class PreferencesDialog : Gtk.Window
 {
-	public RuntimeInstance _editor;
+	public RuntimeInstance? _editor;
 
 	// Document page.
 	public InputColor3 _grid_color_button;
@@ -47,6 +47,8 @@ public class PreferencesDialog : Gtk.Window
 		this.title = "Preferences";
 		this.set_icon_name(CROWN_EDITOR_ICON_NAME);
 
+		_editor = null;
+
 		// Widgets
 		_document_set = new PropertyGridSet();
 		_viewport_set = new PropertyGridSet();
@@ -179,6 +181,9 @@ public class PreferencesDialog : Gtk.Window
 
 	public void on_color_set()
 	{
+		if (_editor == null)
+			return;
+
 		_editor.send_script(LevelEditorApi.set_color("grid", _grid_color_button.value));
 		_editor.send_script(LevelEditorApi.set_color("grid_disabled", _grid_disabled_color_button.value));
 		_editor.send_script(LevelEditorApi.set_color("axis_x", _axis_x_color_button.value));
@@ -190,6 +195,9 @@ public class PreferencesDialog : Gtk.Window
 
 	public void on_gizmo_size_value_changed()
 	{
+		if (_editor == null)
+			return;
+
 		_editor.send_script("Gizmo.size = %f".printf(_gizmo_size_spin_button.value));
 		_editor.send(DeviceApi.frame());
 	}

+ 11 - 12
tools/level_editor/project_browser.vala

@@ -1001,7 +1001,6 @@ public class ProjectBrowser : Gtk.Box
 			, null
 			);
 #endif /* if 0 */
-		_tree_view.model = _tree_sort;
 		_tree_view.headers_visible = false;
 
 		_tree_view_gesture_click = new Gtk.GestureMultiPress(_tree_view);
@@ -1118,12 +1117,6 @@ public class ProjectBrowser : Gtk.Box
 		_tree_view_content.pack_start(_scrolled_window, true, true);
 
 		// Setup sort menu button popover.
-		_sort_items_box = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
-
-		Gtk.RadioButton? button = null;
-		for (int i = 0; i < SortMode.COUNT; ++i)
-			button = add_sort_item(button, (SortMode)i);
-
 		_show_all_files = new Gtk.CheckButton.with_label("Show all files");
 		_show_all_files.set_tooltip_text("Show all files, not just resource files.");
 		_show_all_files.set_active(false);
@@ -1139,11 +1132,7 @@ public class ProjectBrowser : Gtk.Box
 		_show_mapped_dirs.set_active(false);
 		_show_mapped_dirs.toggled.connect(on_show_mapped_dirs_toggled);
 
-		_sort_items_box.pack_start(_show_mapped_dirs, false, false);
-		_sort_items_box.pack_start(_show_all_files, false, false);
-		_sort_items_box.pack_start(_show_files_extension, false, false);
-		_sort_items_box.show_all();
-
+		_sort_items_box = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
 		_sort_items_popover = new Gtk.Popover(null);
 		_sort_items_popover.add(_sort_items_box);
 		_sort_items = new Gtk.MenuButton();
@@ -1154,6 +1143,15 @@ public class ProjectBrowser : Gtk.Box
 		_sort_items.can_focus = false;
 		_sort_items.set_popover(_sort_items_popover);
 
+		Gtk.RadioButton? button = null;
+		for (int i = 0; i < SortMode.COUNT; ++i)
+			button = add_sort_item(button, (SortMode)i);
+
+		_sort_items_box.pack_start(_show_mapped_dirs, false, false);
+		_sort_items_box.pack_start(_show_all_files, false, false);
+		_sort_items_box.pack_start(_show_files_extension, false, false);
+		_sort_items_box.show_all();
+
 		bool _show_icon_view = true;
 		_toggle_icon_view_image = new Gtk.Image.from_icon_name("browser-list-view", Gtk.IconSize.SMALL_TOOLBAR);
 		_toggle_icon_view = new Gtk.Button();
@@ -1296,6 +1294,7 @@ public class ProjectBrowser : Gtk.Box
 		};
 		GLib.Application.get_default().add_action_entries(action_entries, this);
 
+		_tree_view.model = _tree_sort;
 		this.pack_start(_paned);
 		this.show.connect(on_show);
 	}

+ 5 - 6
tools/widgets/object_tree.vala

@@ -153,12 +153,6 @@ public class ObjectTree : Gtk.Box
 
 		// Setup sort menu button popover.
 		_sort_items_box = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
-
-		Gtk.RadioButton? button = null;
-		for (int i = 0; i < SortMode.COUNT; ++i)
-			button = add_sort_item(button, (SortMode)i);
-
-		_sort_items_box.show_all();
 		_sort_items_popover = new Gtk.Popover(null);
 		_sort_items_popover.add(_sort_items_box);
 		_sort_items = new Gtk.MenuButton();
@@ -169,6 +163,11 @@ public class ObjectTree : Gtk.Box
 		_sort_items.can_focus = false;
 		_sort_items.set_popover(_sort_items_popover);
 
+		Gtk.RadioButton? button = null;
+		for (int i = 0; i < SortMode.COUNT; ++i)
+			button = add_sort_item(button, (SortMode)i);
+		_sort_items_box.show_all();
+
 		var tree_control = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0);
 		tree_control.pack_start(_filter_entry, true, true);
 		tree_control.pack_end(_sort_items, false, false);