Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add soft light border in dark theme (#20)
- Loading branch information
Showing
15 changed files
with
627 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
window.csd.unified:not(.solid-csd):not(.fullscreen):not(.maximized) decoration-overlay { | ||
box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.07); | ||
} | ||
|
||
window.csd.unified:not(.solid-csd):not(.fullscreen):not(.maximized) headerbar { | ||
box-shadow: none; | ||
} | ||
|
||
decoration { | ||
box-shadow: 0 3px 9px 1px rgba(0,0,0,.5); | ||
} | ||
|
||
decoration:backdrop { | ||
box-shadow: 0 3px 9px 1px transparent, | ||
0 2px 6px 2px rgba(0,0,0,.2); | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
Copyright 2013 The Flutter Authors. All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without modification, | ||
are permitted provided that the following conditions are met: | ||
|
||
* Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
* Redistributions in binary form must reproduce the above | ||
copyright notice, this list of conditions and the following | ||
disclaimer in the documentation and/or other materials provided | ||
with the distribution. | ||
* Neither the name of Google Inc. nor the names of its | ||
contributors may be used to endorse or promote products derived | ||
from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR | ||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# HandySettings | ||
|
||
Based on FlSettings, FlSettingsPortal, and FlGnomeSettings: | ||
https://github.com/flutter/engine/tree/main/shell/platform/linux |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "handy_gnome_settings.h" | ||
|
||
#include <gio/gio.h> | ||
#include <glib.h> | ||
|
||
static constexpr char kDesktopInterfaceSchema[] = "org.gnome.desktop.interface"; | ||
static constexpr char kDesktopGtkThemeKey[] = "gtk-theme"; | ||
|
||
static constexpr char kGtkThemeDarkSuffix[] = "-dark"; | ||
static constexpr char kInterfaceSettings[] = "interface-settings"; | ||
|
||
struct _HandyGnomeSettings { | ||
GObject parent_instance; | ||
|
||
GSettings* interface_settings; | ||
}; | ||
|
||
enum { kProp0, kPropInterfaceSettings, kPropLast }; | ||
|
||
static void handy_gnome_settings_iface_init(HandySettingsInterface* iface); | ||
|
||
G_DEFINE_TYPE_WITH_CODE(HandyGnomeSettings, handy_gnome_settings, G_TYPE_OBJECT, | ||
G_IMPLEMENT_INTERFACE(handy_settings_get_type(), | ||
handy_gnome_settings_iface_init)) | ||
|
||
static HandyColorScheme handy_gnome_settings_get_color_scheme( | ||
HandySettings* settings) { | ||
HandyGnomeSettings* self = HANDY_GNOME_SETTINGS(settings); | ||
|
||
HandyColorScheme color_scheme = HANDY_COLOR_SCHEME_LIGHT; | ||
|
||
if (self->interface_settings != nullptr) { | ||
// check whether org.gnome.desktop.interface.gtk-theme ends with "-dark" | ||
g_autofree gchar* value = | ||
g_settings_get_string(self->interface_settings, kDesktopGtkThemeKey); | ||
if (g_str_has_suffix(value, kGtkThemeDarkSuffix)) { | ||
color_scheme = HANDY_COLOR_SCHEME_DARK; | ||
} | ||
} | ||
return color_scheme; | ||
} | ||
|
||
static void handy_gnome_settings_set_interface_settings( | ||
HandyGnomeSettings* self, GSettings* settings) { | ||
g_return_if_fail(G_IS_SETTINGS(settings)); | ||
|
||
g_signal_connect_object(settings, "changed::gtk-theme", | ||
G_CALLBACK(handy_settings_emit_changed), self, | ||
G_CONNECT_SWAPPED); | ||
|
||
self->interface_settings = G_SETTINGS(g_object_ref(settings)); | ||
} | ||
|
||
static void handy_gnome_settings_set_property(GObject* object, guint prop_id, | ||
const GValue* value, | ||
GParamSpec* pspec) { | ||
HandyGnomeSettings* self = HANDY_GNOME_SETTINGS(object); | ||
switch (prop_id) { | ||
case kPropInterfaceSettings: | ||
handy_gnome_settings_set_interface_settings( | ||
self, G_SETTINGS(g_value_get_object(value))); | ||
break; | ||
default: | ||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); | ||
break; | ||
} | ||
} | ||
|
||
static void handy_gnome_settings_dispose(GObject* object) { | ||
HandyGnomeSettings* self = HANDY_GNOME_SETTINGS(object); | ||
|
||
g_clear_object(&self->interface_settings); | ||
|
||
G_OBJECT_CLASS(handy_gnome_settings_parent_class)->dispose(object); | ||
} | ||
|
||
static void handy_gnome_settings_class_init(HandyGnomeSettingsClass* klass) { | ||
GObjectClass* object_class = G_OBJECT_CLASS(klass); | ||
object_class->dispose = handy_gnome_settings_dispose; | ||
object_class->set_property = handy_gnome_settings_set_property; | ||
|
||
g_object_class_install_property( | ||
object_class, kPropInterfaceSettings, | ||
g_param_spec_object( | ||
kInterfaceSettings, kInterfaceSettings, kDesktopInterfaceSchema, | ||
g_settings_get_type(), | ||
static_cast<GParamFlags>(G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | | ||
G_PARAM_STATIC_STRINGS))); | ||
} | ||
|
||
static void handy_gnome_settings_iface_init(HandySettingsInterface* iface) { | ||
iface->get_color_scheme = handy_gnome_settings_get_color_scheme; | ||
} | ||
|
||
static void handy_gnome_settings_init(HandyGnomeSettings*) {} | ||
|
||
static GSettings* create_settings(const gchar* schema_id) { | ||
GSettings* settings = nullptr; | ||
GSettingsSchemaSource* source = g_settings_schema_source_get_default(); | ||
if (source != nullptr) { | ||
g_autoptr(GSettingsSchema) schema = | ||
g_settings_schema_source_lookup(source, schema_id, TRUE); | ||
if (schema != nullptr) { | ||
settings = g_settings_new_full(schema, nullptr, nullptr); | ||
} | ||
} | ||
return settings; | ||
} | ||
|
||
HandySettings* handy_gnome_settings_new() { | ||
g_autoptr(GSettings) interface_settings = | ||
create_settings(kDesktopInterfaceSchema); | ||
return HANDY_SETTINGS(g_object_new(handy_gnome_settings_get_type(), | ||
kInterfaceSettings, interface_settings, | ||
nullptr)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef HANDY_GNOME_SETTINGS_H_ | ||
#define HANDY_GNOME_SETTINGS_H_ | ||
|
||
#include "handy_settings.h" | ||
|
||
G_BEGIN_DECLS | ||
|
||
G_DECLARE_FINAL_TYPE(HandyGnomeSettings, handy_gnome_settings, HANDY, | ||
GNOME_SETTINGS, GObject); | ||
|
||
/** | ||
* handy_gnome_settings_new: | ||
* | ||
* Creates a new settings instance for GNOME. | ||
* | ||
* Returns: a new #HandySettings. | ||
*/ | ||
HandySettings* handy_gnome_settings_new(); | ||
|
||
G_END_DECLS | ||
|
||
#endif // HANDY_GNOME_SETTINGS_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "handy_settings.h" | ||
|
||
#include "handy_gnome_settings.h" | ||
#include "handy_settings_portal.h" | ||
|
||
G_DEFINE_INTERFACE(HandySettings, handy_settings, G_TYPE_OBJECT) | ||
|
||
enum { | ||
kSignalChanged, | ||
kSignalLastSignal, | ||
}; | ||
|
||
static guint signals[kSignalLastSignal]; | ||
|
||
static void handy_settings_default_init(HandySettingsInterface* iface) { | ||
/** | ||
* HandySettings::changed: | ||
* @settings: an #HandySettings | ||
* | ||
* This signal is emitted after the settings have been changed. | ||
*/ | ||
signals[kSignalChanged] = | ||
g_signal_new("changed", G_TYPE_FROM_INTERFACE(iface), G_SIGNAL_RUN_LAST, | ||
0, NULL, NULL, NULL, G_TYPE_NONE, 0); | ||
} | ||
|
||
HandyColorScheme handy_settings_get_color_scheme(HandySettings* self) { | ||
return HANDY_SETTINGS_GET_IFACE(self)->get_color_scheme(self); | ||
} | ||
|
||
void handy_settings_emit_changed(HandySettings* self) { | ||
g_return_if_fail(HANDY_IS_SETTINGS(self)); | ||
g_signal_emit(self, signals[kSignalChanged], 0); | ||
} | ||
|
||
HandySettings* handy_settings_new() { | ||
g_autoptr(HandySettingsPortal) portal = handy_settings_portal_new(); | ||
|
||
g_autoptr(GError) error = nullptr; | ||
if (!handy_settings_portal_start(portal, &error)) { | ||
g_debug("XDG desktop portal settings unavailable: %s", error->message); | ||
return handy_gnome_settings_new(); | ||
} | ||
|
||
return HANDY_SETTINGS(g_object_ref(portal)); | ||
} |
Oops, something went wrong.