[gnome-font-viewer/wip/ewlsh/gtk4] font-view: Use AdwApplication



commit ddd2aba828838dd45e64c7390b3f806caebcd955
Author: Christopher Davis <christopherdavis gnome org>
Date:   Fri Feb 11 17:15:47 2022 -0800

    font-view: Use AdwApplication
    
    Also renames the CSS file so libadwaita can automatically
    load it.

 src/font-view.c                     | 22 +++++++---------------
 src/gnome-font-viewer.gresource.xml |  2 +-
 src/{application.css => style.css}  |  0
 3 files changed, 8 insertions(+), 16 deletions(-)
---
diff --git a/src/font-view.c b/src/font-view.c
index 8337192..05b0235 100644
--- a/src/font-view.c
+++ b/src/font-view.c
@@ -52,11 +52,11 @@ G_DECLARE_FINAL_TYPE (FontViewApplication,
                       font_view_application,
                       FONT_VIEW,
                       APPLICATION,
-                      GtkApplication)
+                      AdwApplication)
 
 struct _FontViewApplication
 {
-    GtkApplication parent;
+    AdwApplication parent;
 
     GtkApplicationWindow *main_window;
     GtkWidget *main_grid;
@@ -89,7 +89,7 @@ struct _FontViewApplication
 
 G_DEFINE_TYPE (FontViewApplication,
                font_view_application,
-               GTK_TYPE_APPLICATION);
+               ADW_TYPE_APPLICATION);
 
 G_DECLARE_FINAL_TYPE (
     FontViewItem, font_view_item, FONT_VIEW, ITEM, GtkFlowBoxChild);
@@ -1293,8 +1293,6 @@ font_view_application_startup (GApplication *application)
     G_APPLICATION_CLASS (font_view_application_parent_class)
         ->startup (application);
 
-    adw_init ();
-
     if (!FcInit ())
         g_critical ("Can't initialize fontconfig library");
 
@@ -1304,14 +1302,6 @@ font_view_application_startup (GApplication *application)
     const gchar *back_accels[] = {"<Alt>Left", NULL};
     gtk_application_set_accels_for_action (GTK_APPLICATION (application),
                                            "app.back", back_accels);
-
-    GtkCssProvider *provider = gtk_css_provider_new ();
-    gtk_css_provider_load_from_resource (
-        GTK_CSS_PROVIDER (provider), "/org/gnome/font-viewer/application.css");
-
-    gtk_style_context_add_provider_for_display (
-        gdk_display_get_default (), GTK_STYLE_PROVIDER (provider),
-        GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
 }
 
 static void
@@ -1359,8 +1349,10 @@ font_view_application_class_init (FontViewApplicationClass *klass)
 static GApplication *
 font_view_application_new (void)
 {
-    return g_object_new (FONT_VIEW_TYPE_APPLICATION, "application-id",
-                         APPLICATION_ID, "flags", G_APPLICATION_HANDLES_OPEN,
+    return g_object_new (FONT_VIEW_TYPE_APPLICATION,
+                         "application-id", APPLICATION_ID,
+                         "flags", G_APPLICATION_HANDLES_OPEN,
+                         "resource-base-path", "/org/gnome/font-viewer/",
                          NULL);
 }
 
diff --git a/src/gnome-font-viewer.gresource.xml b/src/gnome-font-viewer.gresource.xml
index e4d5333..2a4ea62 100644
--- a/src/gnome-font-viewer.gresource.xml
+++ b/src/gnome-font-viewer.gresource.xml
@@ -2,6 +2,6 @@
 <gresources>
   <gresource prefix="/org/gnome/font-viewer">
     <file preprocess="xml-stripblanks">font-view-app-menu.ui</file>
-    <file>application.css</file>
+    <file>style.css</file>
   </gresource>
 </gresources>
diff --git a/src/application.css b/src/style.css
similarity index 100%
rename from src/application.css
rename to src/style.css


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