瀏覽代碼

tools: add resource_at_path()

Daniele Bartolini 6 月之前
父節點
當前提交
976dfd8607
共有 1 個文件被更改,包括 19 次插入13 次删除
  1. 19 13
      tools/level_editor/project_browser.vala

+ 19 - 13
tools/level_editor/project_browser.vala

@@ -386,21 +386,10 @@ public class ProjectFolderView : Gtk.Stack
 			if (path != null) {
 				_icon_view.select_path(path);
 				_icon_view.scroll_to_path(path, false, 0.0f, 0.0f);
-
-				Gtk.TreeIter iter;
-				_list_store.get_iter(out iter, path);
-
-				Value val;
-				_list_store.get_value(iter, Column.TYPE, out val);
-				type = (string)val;
-				_list_store.get_value(iter, Column.NAME, out val);
-				name = (string)val;
-
-			} else {
-				type = _selected_type;
-				name = _selected_name;
 			}
 
+			resource_at_path(out type, out name, path);
+
 			GLib.Menu? menu_model;
 			if (_showing_project_folder)
 				menu_model = project_entry_menu_create(type, name);
@@ -679,6 +668,23 @@ public class ProjectFolderView : Gtk.Stack
 
 		return path;
 	}
+
+	private void resource_at_path(out string type, out string name, Gtk.TreePath? path)
+	{
+		if (path != null) {
+			Gtk.TreeIter iter;
+			_list_store.get_iter(out iter, path);
+
+			Value val;
+			_list_store.get_value(iter, Column.TYPE, out val);
+			type = (string)val;
+			_list_store.get_value(iter, Column.NAME, out val);
+			name = (string)val;
+		} else {
+			type = _selected_type;
+			name = _selected_name;
+		}
+	}
 }
 
 public class ProjectBrowser : Gtk.Paned