summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgnacy Kuchciński <ignacykuchcinski@gmail.com>2022-08-20 14:38:02 +0200
committerAntónio Fernandes <antoniof@gnome.org>2022-09-01 23:35:15 +0000
commit47ee9eaf5404162e517f37d096f16eee077c7d3d (patch)
treed8e0924f4bab749598aea02a497986579f4f96e3
parent1e06525a8d529fc9a29169ca087806bb2e58571f (diff)
downloadnautilus-47ee9eaf5404162e517f37d096f16eee077c7d3d.tar.gz
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
-rw-r--r--src/nautilus-application.c42
-rw-r--r--src/nautilus-application.h8
-rw-r--r--src/resources/css/nautilus.css7
-rw-r--r--src/resources/nautilus.gresource.xml4
-rw-r--r--src/resources/style-hc.css3
-rw-r--r--src/resources/style.css (renamed from src/resources/css/Adwaita.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/css/nautilus.css b/src/resources/css/nautilus.css
deleted file mode 100644
index fd47a9c81..000000000
--- a/src/resources/css/nautilus.css
+++ /dev/null
@@ -1,7 +0,0 @@
-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;
-}
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
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;
+}