[gtksourceview/wip/chergert/gsv-gtk4] completion: register CSS at gtk_source_init()
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/chergert/gsv-gtk4] completion: register CSS at gtk_source_init()
- Date: Sun, 30 Aug 2020 21:39:45 +0000 (UTC)
commit 384dff28728375c8702453f328124474cea9fd56
Author: Christian Hergert <chergert redhat com>
Date: Sun Aug 30 14:38:56 2020 -0700
completion: register CSS at gtk_source_init()
gtksourceview/GtkSourceView.css | 94 +++++++++++++++++++++++++++++++
gtksourceview/gtksourceinit.c | 23 ++++++++
gtksourceview/gtksourceview.gresource.xml | 3 +
3 files changed, 120 insertions(+)
---
diff --git a/gtksourceview/GtkSourceView.css b/gtksourceview/GtkSourceView.css
new file mode 100644
index 000000000..fd8b06ca1
--- /dev/null
+++ b/gtksourceview/GtkSourceView.css
@@ -0,0 +1,94 @@
+@define-color selected_border_color shade(@theme_selected_bg_color, 0.9);
+
+GtkSourceAssistant {
+ background-color: @theme_bg_color;
+ border-radius: 7px;
+ font: initial;
+ margin: 10px 10px 10px 10px;
+ box-shadow: 0 3px 5px 1px @wm_shadow,
+ 0 0 0 1px alpha(@wm_border, 1);
+ outline: 1px solid alpha(@wm_highlight, 0.25);
+ margin: 20px;
+ background: @theme_bg_color;
+}
+
+GtkSourceAssistant.completion {
+ background-color: @content_view_bg;
+ border: none;
+ min-width: 150px;
+}
+GtkSourceAssistant.completion scrollbar.vertical slider {
+ min-height: 10px;
+}
+GtkSourceAssistant.completion scrollbar.vertical {
+ border-top-right-radius: 5px;
+}
+GtkSourceAssistant.completion scrolledwindow:last-child scrollbar.vertical {
+ border-bottom-right-radius: 5px;
+}
+GtkSourceAssistant.completion list {
+ border-top-left-radius: 5px;
+ border-top-right-radius: 5px;
+ margin: 0px;
+}
+GtkSourceAssistant.completion list,
+GtkSourceAssistant.completion list row:not(:selected):not(:hover),
+GtkSourceAssistant.completion list row cell {
+ background: transparent;
+}
+GtkSourceAssistant.completion list row {
+ transition: none;
+ box-shadow: none;
+}
+GtkSourceAssistant.completion list row:first-child {
+ border-top-left-radius: 5px;
+ border-top-right-radius: 5px;
+}
+GtkSourceAssistant.completion scrolledwindow:last-child list row:last-child {
+ border-bottom-left-radius: 5px;
+ border-bottom-right-radius: 5px;
+}
+GtkSourceAssistant.completion list row cell.icon {
+ padding: 6px;
+ min-width: 16px;
+ min-height: 16px;
+}
+GtkSourceAssistant.completion list row cell.typed-text {
+ margin-left: 6px;
+ margin-right: 6px;
+}
+GtkSourceAssistant.completion list row cell.after {
+ margin-right: 6px;
+}
+GtkSourceAssistant.completion list row cell.before {
+ opacity: 0.65;
+}
+GtkSourceAssistant.completion list row box.more button {
+ margin: 0px;
+ padding: 0px;
+}
+GtkSourceAssistant.completion list row box.more button image {
+ margin: 0px;
+ padding: 0px;
+}
+GtkSourceAssistant.completion .details {
+ border-top: 1px solid @borders;
+ border-bottom-left-radius: 5px;
+ border-bottom-right-radius: 5px;
+ background-color: @theme_bg_color;
+ padding-left: 6px;
+ padding-right: 3px;
+}
+GtkSourceAssistant.completion .details cell {
+ margin-left: 24px;
+ margin-bottom: 8px;
+}
+GtkSourceAssistant.completion .details button.flat {
+ min-height: 8px;
+ margin: 3px 0px;
+ padding: 3px 6px;
+}
+
+GtkSourceAssistant.completion-info {
+ padding: 6px;
+}
diff --git a/gtksourceview/gtksourceinit.c b/gtksourceview/gtksourceinit.c
index 0e10b0471..8e4dcd463 100644
--- a/gtksourceview/gtksourceinit.c
+++ b/gtksourceview/gtksourceinit.c
@@ -24,6 +24,10 @@
#include "gtksourcebuffer.h"
#include "gtksourcebufferinputstream-private.h"
#include "gtksourcebufferoutputstream-private.h"
+#include "gtksourcecompletion.h"
+#include "gtksourcecompletioncontext.h"
+#include "gtksourcecompletionproposal.h"
+#include "gtksourcecompletionprovider.h"
#include "gtksourcefileloader.h"
#include "gtksourcefilesaver.h"
#include "gtksourcegutterrenderer.h"
@@ -161,6 +165,7 @@ gtk_source_init (void)
if (!done)
{
+ GdkDisplay *display;
gchar *locale_dir;
locale_dir = get_locale_dir ();
@@ -179,6 +184,10 @@ gtk_source_init (void)
g_type_ensure (GTK_SOURCE_TYPE_BUFFER);
g_type_ensure (GTK_SOURCE_TYPE_BUFFER_INPUT_STREAM);
g_type_ensure (GTK_SOURCE_TYPE_BUFFER_OUTPUT_STREAM);
+ g_type_ensure (GTK_SOURCE_TYPE_COMPLETION);
+ g_type_ensure (GTK_SOURCE_TYPE_COMPLETION_CONTEXT);
+ g_type_ensure (GTK_SOURCE_TYPE_COMPLETION_PROVIDER);
+ g_type_ensure (GTK_SOURCE_TYPE_COMPLETION_PROPOSAL);
g_type_ensure (GTK_SOURCE_TYPE_FILE_LOADER);
g_type_ensure (GTK_SOURCE_TYPE_FILE_SAVER);
g_type_ensure (GTK_SOURCE_TYPE_GUTTER_RENDERER);
@@ -190,6 +199,20 @@ gtk_source_init (void)
g_type_ensure (GTK_SOURCE_TYPE_STYLE_SCHEME_CHOOSER_WIDGET);
g_type_ensure (GTK_SOURCE_TYPE_VIEW);
+ display = gdk_display_get_default ();
+
+ if (display != NULL)
+ {
+ GtkCssProvider *css_provider = gtk_css_provider_new ();
+
+ gtk_css_provider_load_from_resource (css_provider,
+
"/org/gnome/gtksourceview/css/GtkSourceView.css");
+ gtk_style_context_add_provider_for_display (display,
+ GTK_STYLE_PROVIDER (css_provider),
+
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION-1);
+ g_clear_object (&css_provider);
+ }
+
done = TRUE;
}
}
diff --git a/gtksourceview/gtksourceview.gresource.xml b/gtksourceview/gtksourceview.gresource.xml
index 182638ad0..682563130 100644
--- a/gtksourceview/gtksourceview.gresource.xml
+++ b/gtksourceview/gtksourceview.gresource.xml
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
+ <gresource prefix="/org/gnome/gtksourceview/css/">
+ <file>GtkSourceView.css</file>
+ </gresource>
<gresource prefix="/org/gnome/gtksourceview/ui">
<file preprocess="xml-stripblanks">gtksourcecompletionlist.ui</file>
<file preprocess="xml-stripblanks">gtksourcecompletionlistboxrow.ui</file>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]