1/*
2 * This file is part of gitg
3 *
4 * Copyright (C) 2012 - Jesse van den Kieboom
5 *
6 * gitg is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * gitg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with gitg. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20namespace GitgExt
21{
22	public class UI
23	{
24		public static Gee.HashMap<string, Object>? from_builder(string path, ...)
25		{
26			var builder = new Gtk.Builder();
27
28			try
29			{
30				builder.add_from_resource("/org/gnome/gitg/" + path);
31			}
32			catch (Error e)
33			{
34				warning("Failed to load ui: %s", e.message);
35				return null;
36			}
37
38			Gee.HashMap<string, Object> ret = new Gee.HashMap<string, Object>();
39
40			var l = va_list();
41
42			while (true)
43			{
44				string? id = l.arg();
45
46				if (id == null)
47				{
48					break;
49				}
50
51				ret[id] = builder.get_object(id);
52			}
53
54			return ret;
55		}
56	}
57}
58
59// vi:ts=4
60