[gnome-contacts] ContactsWindow: incorporate UI/CSS loading
- From: Niels De Graef <nielsdg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-contacts] ContactsWindow: incorporate UI/CSS loading
- Date: Sun, 24 Dec 2017 14:09:14 +0000 (UTC)
commit c719a960958cb2743039ed4b04c4930451a5f171
Author: Niels De Graef <nielsdegraef gmail com>
Date: Sun Dec 24 15:08:41 2017 +0100
ContactsWindow: incorporate UI/CSS loading
src/contacts-app.vala | 19 ++++++++++++++-----
src/contacts-utils.vala | 21 ---------------------
2 files changed, 14 insertions(+), 26 deletions(-)
---
diff --git a/src/contacts-app.vala b/src/contacts-app.vala
index 5557f33..c297160 100644
--- a/src/contacts-app.vala
+++ b/src/contacts-app.vala
@@ -174,7 +174,12 @@ public class Contacts.App : Gtk.Application {
this.set_accels_for_action ("app.help", {"F1"});
this.set_accels_for_action ("app.new-contact", {"<Primary>n"});
- var builder = load_ui ("app-menu.ui");
+ var builder = new Gtk.Builder ();
+ try {
+ builder.add_from_resource ("/org/gnome/contacts/ui/app-menu.ui");
+ } catch (GLib.Error e) {
+ error ("Error loading app menu: %s", e.message);
+ }
set_app_menu ((MenuModel)builder.get_object ("app-menu"));
}
@@ -247,11 +252,15 @@ public class Contacts.App : Gtk.Application {
this.contacts_store = new Store ();
base.startup ();
- var css_provider = load_css ("style.css");
- Gtk.StyleContext.add_provider_for_screen (Gdk.Screen.get_default(),
- css_provider,
- Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
+ load_styling ();
+ }
+ public void load_styling () {
+ var provider = new Gtk.CssProvider ();
+ provider.load_from_resource ("/org/gnome/contacts/ui/style.css");
+ StyleContext.add_provider_for_screen (Gdk.Screen.get_default(),
+ provider,
+ Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
}
public override void activate () {
diff --git a/src/contacts-utils.vala b/src/contacts-utils.vala
index a589a16..bcfec4d 100644
--- a/src/contacts-utils.vala
+++ b/src/contacts-utils.vala
@@ -27,27 +27,6 @@ namespace Contacts {
return str != null && str != "";
}
- public Gtk.Builder load_ui (string ui) {
- var builder = new Gtk.Builder ();
- try {
- builder.add_from_resource ("/org/gnome/contacts/ui/".concat (ui, null));
- } catch (GLib.Error e) {
- error ("loading ui file: %s", e.message);
- }
- return builder;
- }
-
- public Gtk.CssProvider load_css (string css) {
- var provider = new Gtk.CssProvider ();
- try {
- var file = File.new_for_uri("resource:///org/gnome/contacts/ui/" + css);
- provider.load_from_file (file);
- } catch (GLib.Error e) {
- warning ("loading css: %s", e.message);
- }
- return provider;
- }
-
public void add_separator (ListBoxRow row, ListBoxRow? before_row) {
row.set_header (new Separator (Orientation.HORIZONTAL));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]