[gitg] Use Gitg.UI.from_builder
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gitg] Use Gitg.UI.from_builder
- Date: Fri, 2 Nov 2012 16:02:39 +0000 (UTC)
commit de95b0f3d5c0f9570bcd8e9f86cbb30409e84cb6
Author: Jesse van den Kieboom <jessevdk gnome org>
Date: Fri Nov 2 17:01:00 2012 +0100
Use Gitg.UI.from_builder
gitg/gitg-application.vala | 8 +++++---
gitg/gitg-resource.vala | 29 ++---------------------------
2 files changed, 7 insertions(+), 30 deletions(-)
---
diff --git a/gitg/gitg-application.vala b/gitg/gitg-application.vala
index 58b35dc..5622237 100644
--- a/gitg/gitg-application.vala
+++ b/gitg/gitg-application.vala
@@ -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()
diff --git a/gitg/gitg-resource.vala b/gitg/gitg-resource.vala
index 8c17800..581f259 100644
--- a/gitg/gitg-resource.vala
+++ b/gitg/gitg-resource.vala
@@ -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)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]