[nautilus] application: Adopt AdwApplication



commit 47ee9eaf5404162e517f37d096f16eee077c7d3d
Author: Ignacy Kuchciński <ignacykuchcinski gmail com>
Date:   Sat Aug 20 14:38:02 2022 +0200

    application: Adopt AdwApplication
    
    Doing this allows us to automatically load stylesheets located in the
    resource base path, so move contents of both Adwaita.css and
    nautilus.css to style.css in the root of the resource directory, which
    will be always automatically loaded.
    
    Additionally, create a style-hc.css which will be used when the system
    high contrast preference is enabled, and adjust it to fix issues with
    NautilusPathBar.
    
    Fixes https://gitlab.gnome.org/GNOME/nautilus/-/issues/2166

 src/nautilus-application.c                   | 42 ++--------------------------
 src/nautilus-application.h                   |  8 ++----
 src/resources/css/nautilus.css               |  7 -----
 src/resources/nautilus.gresource.xml         |  4 +--
 src/resources/style-hc.css                   |  3 ++
 src/resources/{css/Adwaita.css => style.css} |  8 ++++++
 6 files changed, 18 insertions(+), 54 deletions(-)
---
diff --git a/src/nautilus-application.c b/src/nautilus-application.c
index 41fb539d2..eb7b6e32e 100644
--- a/src/nautilus-application.c
+++ b/src/nautilus-application.c
@@ -91,7 +91,7 @@ typedef struct
     guint previewer_selection_id;
 } NautilusApplicationPrivate;
 
-G_DEFINE_TYPE_WITH_PRIVATE (NautilusApplication, nautilus_application, GTK_TYPE_APPLICATION);
+G_DEFINE_TYPE_WITH_PRIVATE (NautilusApplication, nautilus_application, ADW_TYPE_APPLICATION);
 
 void
 nautilus_application_set_accelerator (GApplication *app,
@@ -791,7 +791,7 @@ action_kill (GSimpleAction *action,
              GVariant      *parameter,
              gpointer       user_data)
 {
-    GtkApplication *application = user_data;
+    AdwApplication *application = user_data;
 
     /* we have been asked to force quit */
     g_application_quit (G_APPLICATION (application));
@@ -1054,40 +1054,6 @@ nautilus_application_init (NautilusApplication *self)
     nautilus_clipboard_register ();
 }
 
-static void
-setup_theme_extensions (void)
-{
-    static GtkCssProvider *provider = NULL;
-    static GtkCssProvider *permanent_provider = NULL;
-    GdkDisplay *display;
-
-    display = gdk_display_get_default ();
-
-    /* CSS that themes can override */
-    if (provider == NULL)
-    {
-        provider = gtk_css_provider_new ();
-        gtk_css_provider_load_from_resource (provider, "/org/gnome/nautilus/css/Adwaita.css");
-        gtk_style_context_add_provider_for_display (display,
-                                                    GTK_STYLE_PROVIDER (provider),
-                                                    GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
-    }
-
-    /* CSS we want to always load for any theme */
-    if (permanent_provider == NULL)
-    {
-        permanent_provider = gtk_css_provider_new ();
-        gtk_css_provider_load_from_resource (permanent_provider, "/org/gnome/nautilus/css/nautilus.css");
-        /* The behavior of two style providers with the same priority is
-         * undefined and gtk happens to prefer the provider that got added last.
-         * Use a higher priority here to avoid this problem.
-         */
-        gtk_style_context_add_provider_for_display (display,
-                                                    GTK_STYLE_PROVIDER (permanent_provider),
-                                                    GTK_STYLE_PROVIDER_PRIORITY_APPLICATION + 1);
-    }
-}
-
 NautilusApplication *
 nautilus_application_get_default (void)
 {
@@ -1180,12 +1146,8 @@ nautilus_application_startup_common (NautilusApplication *self)
      */
     G_APPLICATION_CLASS (nautilus_application_parent_class)->startup (G_APPLICATION (self));
 
-    adw_init ();
-
     gtk_window_set_default_icon_name (APPLICATION_ID);
 
-    setup_theme_extensions ();
-
     /* initialize preferences and create the global GSettings objects */
     nautilus_global_preferences_init ();
 
diff --git a/src/nautilus-application.h b/src/nautilus-application.h
index 83cc01252..50bcf4d1c 100644
--- a/src/nautilus-application.h
+++ b/src/nautilus-application.h
@@ -20,18 +20,16 @@
 
 #pragma once
 
-#include <gdk/gdk.h>
-#include <gio/gio.h>
-#include <gtk/gtk.h>
+#include <adwaita.h>
 
 #include "nautilus-types.h"
 
 G_BEGIN_DECLS
 #define NAUTILUS_TYPE_APPLICATION (nautilus_application_get_type())
-G_DECLARE_DERIVABLE_TYPE (NautilusApplication, nautilus_application, NAUTILUS, APPLICATION, GtkApplication)
+G_DECLARE_DERIVABLE_TYPE (NautilusApplication, nautilus_application, NAUTILUS, APPLICATION, AdwApplication)
 
 struct _NautilusApplicationClass {
-       GtkApplicationClass parent_class;
+       AdwApplicationClass parent_class;
 
         void  (*open_location_full) (NautilusApplication     *application,
                                      GFile                   *location,
diff --git a/src/resources/nautilus.gresource.xml b/src/resources/nautilus.gresource.xml
index 6057d7eac..bfe8b2bd3 100644
--- a/src/resources/nautilus.gresource.xml
+++ b/src/resources/nautilus.gresource.xml
@@ -32,8 +32,8 @@
     <file alias="gtk/ui/nautilusgtkplacesview.ui">../gtk/nautilusgtkplacesview.ui</file>
     <file alias="gtk/ui/nautilusgtkplacesviewrow.ui">../gtk/nautilusgtkplacesviewrow.ui</file>
     <file alias="icons/filmholes.png">../../icons/filmholes.png</file>
-    <file>css/Adwaita.css</file>
-    <file>css/nautilus.css</file>
+    <file>style.css</file>
+    <file>style-hc.css</file>
     <file>text-x-preview.png</file>
     <file>Checkerboard.png</file>
   </gresource>
diff --git a/src/resources/style-hc.css b/src/resources/style-hc.css
new file mode 100644
index 000000000..c5a1d0c72
--- /dev/null
+++ b/src/resources/style-hc.css
@@ -0,0 +1,3 @@
+#NautilusPathBar {
+       box-shadow: 0 0 0 1px @borders;
+}
diff --git a/src/resources/css/Adwaita.css b/src/resources/style.css
similarity index 96%
rename from src/resources/css/Adwaita.css
rename to src/resources/style.css
index 88afd0a26..205811c53 100644
--- a/src/resources/css/Adwaita.css
+++ b/src/resources/style.css
@@ -291,3 +291,11 @@
   min-height: 36px;
   -gtk-icon-size: 32px;
 }
+
+label.encrypted_zip {
+    background-image: -gtk-icontheme('system-lock-screen-symbolic');
+    background-position: right center;
+    background-repeat: no-repeat;
+    background-size: 16px 16px;
+    padding-right: 22px;
+}


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