[baobab/wip/cdavis/gtk4: 2/2] Use AdwApplication




commit 7166805835079e2d7f6458b341a6691cd6027c3c
Author: Christopher Davis <christopherdavis gnome org>
Date:   Fri Oct 8 04:05:37 2021 -0700

    Use AdwApplication
    
    AdwApplication automatically loads styling for us.

 data/baobab.gresource.xml      |  2 +-
 data/{baobab.css => style.css} |  0
 src/baobab-application.vala    | 11 +++--------
 3 files changed, 4 insertions(+), 9 deletions(-)
---
diff --git a/data/baobab.gresource.xml b/data/baobab.gresource.xml
index 2f1709f..1082907 100644
--- a/data/baobab.gresource.xml
+++ b/data/baobab.gresource.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <gresources>
   <gresource prefix="/org/gnome/baobab">
-    <file compressed="true">baobab.css</file>
+    <file compressed="true">style.css</file>
     <file compressed="true">ui/baobab-excluded-row.ui</file>
     <file compressed="true">ui/baobab-folder-display.ui</file>
     <file compressed="true">ui/baobab-location-list.ui</file>
diff --git a/data/baobab.css b/data/style.css
similarity index 100%
rename from data/baobab.css
rename to data/style.css
diff --git a/src/baobab-application.vala b/src/baobab-application.vala
index eed5846..07ac0df 100644
--- a/src/baobab-application.vala
+++ b/src/baobab-application.vala
@@ -22,7 +22,7 @@
 
 namespace Baobab {
 
-    public class Application : Gtk.Application {
+    public class Application : Adw.Application {
 
         private Window window;
 
@@ -75,13 +75,6 @@ namespace Baobab {
         protected override void startup () {
             base.startup ();
 
-            Adw.init ();
-
-            // Load custom CSS
-            var css_provider = new Gtk.CssProvider ();
-            css_provider.load_from_resource ("/org/gnome/baobab/baobab.css");
-            Gtk.StyleContext.add_provider_for_display (Gdk.Display.get_default (), css_provider, 
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
-
             set_accels_for_action ("win.show-home-page", { "<Alt>Left" });
             set_accels_for_action ("win.show-primary-menu", { "F10" });
             set_accels_for_action ("win.scan-folder", { "<Primary>o" });
@@ -102,6 +95,8 @@ namespace Baobab {
         public Application () {
             Object (application_id: "org.gnome.baobab", flags: ApplicationFlags.HANDLES_OPEN);
 
+            set_resource_base_path("/org/gnome/baobab/");
+
             add_main_option_entries (option_entries);
             set_option_context_parameter_string ("[DIRECTORY]");
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]