diff options
| author | Po Lu | 2022-03-11 20:07:52 +0800 |
|---|---|---|
| committer | Po Lu | 2022-03-11 20:10:23 +0800 |
| commit | 7ad1df5e1684532efeec435be4ac7fc76affc814 (patch) | |
| tree | e1fa68133b3802e1810440358f1327b3c115e608 /src/gtkutil.c | |
| parent | 92ebfe7da4af5c60d33538d3526ef06d2a0142c4 (diff) | |
| download | emacs-7ad1df5e1684532efeec435be4ac7fc76affc814.tar.gz emacs-7ad1df5e1684532efeec435be4ac7fc76affc814.zip | |
Implement customization of scroll bar colors on GTK 3
* src/gtkutil.c (xg_create_frame_widgets): Create CSS providers
for scroll bars.
(xg_finish_scroll_bar_creation): Attach created CSS providers.
* src/xfns.c (x_set_scroll_bar_foreground):
(x_set_scroll_bar_background): Put appropriate content into CSS
providers.
* src/xterm.c (x_free_frame_resources): Free CSS providers.
* src/xterm.h (struct x_output): New fields for scroll bar
stylesheet providers.
Diffstat (limited to 'src/gtkutil.c')
| -rw-r--r-- | src/gtkutil.c | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/src/gtkutil.c b/src/gtkutil.c index 1b4ecaf9492..f488b0ff752 100644 --- a/src/gtkutil.c +++ b/src/gtkutil.c | |||
| @@ -1612,10 +1612,7 @@ xg_create_frame_widgets (struct frame *f) | |||
| 1612 | with regular X drawing primitives, so from a GTK/GDK point of | 1612 | with regular X drawing primitives, so from a GTK/GDK point of |
| 1613 | view, the widget is totally blank. When an expose comes, this | 1613 | view, the widget is totally blank. When an expose comes, this |
| 1614 | will make the widget blank, and then Emacs redraws it. This flickers | 1614 | will make the widget blank, and then Emacs redraws it. This flickers |
| 1615 | a lot, so we turn off double buffering. | 1615 | a lot, so we turn off double buffering. */ |
| 1616 | FIXME: gtk_widget_set_double_buffered is deprecated and might stop | ||
| 1617 | working in the future. We need to migrate away from combining | ||
| 1618 | X and GTK+ drawing to a pure GTK+ build. */ | ||
| 1619 | 1616 | ||
| 1620 | #ifndef HAVE_PGTK | 1617 | #ifndef HAVE_PGTK |
| 1621 | gtk_widget_set_double_buffered (wfixed, FALSE); | 1618 | gtk_widget_set_double_buffered (wfixed, FALSE); |
| @@ -1634,6 +1631,14 @@ xg_create_frame_widgets (struct frame *f) | |||
| 1634 | G_CALLBACK (delete_cb), f); | 1631 | G_CALLBACK (delete_cb), f); |
| 1635 | #endif | 1632 | #endif |
| 1636 | 1633 | ||
| 1634 | #if defined HAVE_GTK3 && !defined HAVE_PGTK | ||
| 1635 | /* On PGTK this is done in Fx_create_frame. */ | ||
| 1636 | FRAME_OUTPUT_DATA (f)->scrollbar_background_css_provider | ||
| 1637 | = gtk_css_provider_new (); | ||
| 1638 | FRAME_OUTPUT_DATA (f)->scrollbar_foreground_css_provider | ||
| 1639 | = gtk_css_provider_new (); | ||
| 1640 | #endif | ||
| 1641 | |||
| 1637 | /* Convert our geometry parameters into a geometry string | 1642 | /* Convert our geometry parameters into a geometry string |
| 1638 | and specify it. | 1643 | and specify it. |
| 1639 | GTK will itself handle calculating the real position this way. */ | 1644 | GTK will itself handle calculating the real position this way. */ |
| @@ -4448,6 +4453,10 @@ xg_finish_scroll_bar_creation (struct frame *f, | |||
| 4448 | const char *scroll_bar_name) | 4453 | const char *scroll_bar_name) |
| 4449 | { | 4454 | { |
| 4450 | GtkWidget *webox = gtk_event_box_new (); | 4455 | GtkWidget *webox = gtk_event_box_new (); |
| 4456 | #ifdef HAVE_GTK3 | ||
| 4457 | GtkCssProvider *foreground_provider; | ||
| 4458 | GtkCssProvider *background_provider; | ||
| 4459 | #endif | ||
| 4451 | 4460 | ||
| 4452 | gtk_widget_set_name (wscroll, scroll_bar_name); | 4461 | gtk_widget_set_name (wscroll, scroll_bar_name); |
| 4453 | #ifndef HAVE_GTK3 | 4462 | #ifndef HAVE_GTK3 |
| @@ -4496,15 +4505,14 @@ xg_finish_scroll_bar_creation (struct frame *f, | |||
| 4496 | /* Set the cursor to an arrow. */ | 4505 | /* Set the cursor to an arrow. */ |
| 4497 | xg_set_cursor (webox, FRAME_DISPLAY_INFO (f)->xg_cursor); | 4506 | xg_set_cursor (webox, FRAME_DISPLAY_INFO (f)->xg_cursor); |
| 4498 | 4507 | ||
| 4499 | #ifdef HAVE_PGTK | 4508 | #ifdef HAVE_GTK3 |
| 4500 | GtkStyleContext *ctxt = gtk_widget_get_style_context (wscroll); | 4509 | GtkStyleContext *ctxt = gtk_widget_get_style_context (wscroll); |
| 4501 | gtk_style_context_add_provider (ctxt, | 4510 | foreground_provider = FRAME_OUTPUT_DATA (f)->scrollbar_foreground_css_provider; |
| 4502 | GTK_STYLE_PROVIDER (FRAME_OUTPUT_DATA (f)-> | 4511 | background_provider = FRAME_OUTPUT_DATA (f)->scrollbar_background_css_provider; |
| 4503 | scrollbar_foreground_css_provider), | 4512 | |
| 4513 | gtk_style_context_add_provider (ctxt, GTK_STYLE_PROVIDER (foreground_provider), | ||
| 4504 | GTK_STYLE_PROVIDER_PRIORITY_USER); | 4514 | GTK_STYLE_PROVIDER_PRIORITY_USER); |
| 4505 | gtk_style_context_add_provider (ctxt, | 4515 | gtk_style_context_add_provider (ctxt, GTK_STYLE_PROVIDER (background_provider), |
| 4506 | GTK_STYLE_PROVIDER (FRAME_OUTPUT_DATA (f)-> | ||
| 4507 | scrollbar_background_css_provider), | ||
| 4508 | GTK_STYLE_PROVIDER_PRIORITY_USER); | 4516 | GTK_STYLE_PROVIDER_PRIORITY_USER); |
| 4509 | #endif | 4517 | #endif |
| 4510 | 4518 | ||