mirror of
https://gitlab.gnome.org/GNOME/gitg
synced 2024-10-01 05:33:49 +00:00
Added convenience function for building ui from resource
This commit is contained in:
parent
800684585a
commit
7354780e04
|
@ -13,6 +13,7 @@ COMMON_VALA_FLAGS = \
|
|||
--pkg libgitg-1.0 \
|
||||
--pkg gio-2.0 \
|
||||
--pkg gtk+-3.0 \
|
||||
--pkg gee-1.0 \
|
||||
--basedir $(top_srcdir) \
|
||||
--gir GitgExt-1.0.gir \
|
||||
--girdir $(top_builddir)/libgitg \
|
||||
|
@ -46,7 +47,8 @@ VALA_FILES = \
|
|||
gitg-ext-message-bus.vala \
|
||||
gitg-ext-object-selection.vala \
|
||||
gitg-ext-command-line.vala \
|
||||
gitg-ext-preferences.vala
|
||||
gitg-ext-preferences.vala \
|
||||
gitg-ext-ui.vala
|
||||
|
||||
libgitg_ext_1_0_la_SOURCES = \
|
||||
$(VALA_FILES) \
|
||||
|
|
59
libgitg-ext/gitg-ext-ui.vala
Normal file
59
libgitg-ext/gitg-ext-ui.vala
Normal file
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* This file is part of gitg
|
||||
*
|
||||
* Copyright (C) 2012 - Jesse van den Kieboom
|
||||
*
|
||||
* gitg is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* gitg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with gitg. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace GitgExt
|
||||
{
|
||||
public class UI
|
||||
{
|
||||
public static Gee.HashMap<string, Object>? from_builder(string path, ...)
|
||||
{
|
||||
var builder = new Gtk.Builder();
|
||||
|
||||
try
|
||||
{
|
||||
builder.add_from_resource("/org/gnome/gitg/" + path);
|
||||
}
|
||||
catch (Error e)
|
||||
{
|
||||
warning("Failed to load ui: %s", e.message);
|
||||
return null;
|
||||
}
|
||||
|
||||
Gee.HashMap<string, Object> ret = new Gee.HashMap<string, Object>();
|
||||
|
||||
var l = va_list();
|
||||
|
||||
while (true)
|
||||
{
|
||||
string? id = l.arg();
|
||||
|
||||
if (id == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
ret[id] = builder.get_object(id);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// vi:ts=4
|
Loading…
Reference in a new issue