mirror of
https://gitlab.gnome.org/GNOME/gitg
synced 2024-08-27 20:09:23 +00:00
Use Gitg.UI.from_builder
This commit is contained in:
parent
af7a4e72ac
commit
de95b0f3d5
|
@ -269,10 +269,12 @@ public class Application : Gtk.Application
|
|||
{
|
||||
add_action_entries(app_entries, this);
|
||||
|
||||
MenuModel[] menus = Resource.load_objects<MenuModel>("ui/gitg-menus.ui", {"app-menu", "win-menu"});
|
||||
MenuModel? menu = Resource.load_object<MenuModel>("ui/gitg-menus.ui", "app-menu");
|
||||
|
||||
set_app_menu(menus[0]);
|
||||
//set_menubar(menus[1]);
|
||||
if (menu != null)
|
||||
{
|
||||
set_app_menu(menu);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void startup()
|
||||
|
|
|
@ -21,41 +21,16 @@ namespace Gitg
|
|||
{
|
||||
class Resource
|
||||
{
|
||||
public static T[]? load_objects<T>(string id, string[] objects)
|
||||
{
|
||||
var builder = new Gtk.Builder();
|
||||
|
||||
try
|
||||
{
|
||||
builder.add_from_resource("/org/gnome/gitg/" + id);
|
||||
}
|
||||
catch (Error e)
|
||||
{
|
||||
warning("Error while loading resource: %s", e.message);
|
||||
return null;
|
||||
}
|
||||
|
||||
T[] ret = new T[objects.length];
|
||||
ret.length = 0;
|
||||
|
||||
foreach (string obj in objects)
|
||||
{
|
||||
ret += (T)builder.get_object(obj);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static T? load_object<T>(string id, string object)
|
||||
{
|
||||
T[]? ret = load_objects<T>(id, new string[] {object});
|
||||
var ret = GitgExt.UI.from_builder(id, object);
|
||||
|
||||
if (ret == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return ret[0];
|
||||
return (T?)ret[object];
|
||||
}
|
||||
|
||||
public static Gtk.CssProvider? load_css(string id)
|
||||
|
|
Loading…
Reference in a new issue