border-color adds a new border in GtkScrolledWindow (GTK 3.18) ?
- From: Giovanni Panozzo <giovanni panozzo it>
- To: gtk-app-devel-list gnome org
- Subject: border-color adds a new border in GtkScrolledWindow (GTK 3.18) ?
- Date: Mon, 15 Feb 2016 22:47:52 +0100
Hello to all. I have just subscribed to the ML.
I have a problem with GTK 3.18: I have an application with a
GtkScrolledWindow, which contains a GtkViewport which contains a
GtkDrawingArea.
Via CSS I set the background colors of GtkScrolledWindow and GtkDrawingArea.
Up to version 3.16 of GTK, all worked fine:
In GTK 3.18 (which means: current Arch and immediate future Ubuntu
16.04), a strange border has appeared:
(here in green)
The border only appears when both conditions are true:
1. applying the background color with following CSS:
#myscrolledwindow { background-color: green; }
2. scrollbars are shown because the main window is smaller than the
drawing area.
If you move the vertical scrollbar, a second green border on the left
will appear, covering some important pixels of the drawing area.
If you move the horizontal scrollbar, a second green border will appear
on the top, covering some important pixels of the drawing area.
Below you can find the full source code.
Is it a new bug or am I doing something wrong ?
Thank you
Giovanni
------------------------------------------------------------------------
Compile with
gcc `pkg-config --cflags gtk+-3.0` -o gtk318problem gtk318problem.c
`pkg-config --libs gtk+-3.0`
#include <gtk/gtk.h>
static gboolean
draw_callback (GtkWidget *widget, cairo_t *cr, gpointer data)
{
guint width, height;
GdkRGBA color;
width = gtk_widget_get_allocated_width (widget);
height = gtk_widget_get_allocated_height (widget);
cairo_arc (cr,
width / 2.0, height / 2.0,
MIN (width, height) / 2.0,
0, 2 * G_PI);
gtk_style_context_get_color (gtk_widget_get_style_context (widget),
0,
&color);
gdk_cairo_set_source_rgba (cr, &color);
cairo_fill (cr);
return FALSE;
}
static void
activate (GtkApplication* app,
gpointer user_data)
{
GtkWidget *window;
GtkWidget *sw;
GtkWidget *vp;
GtkWidget *da;
GtkCssProvider *provider;
/* Apply CSS */
provider = gtk_css_provider_new();
gtk_css_provider_load_from_data (provider,
"#myscrolledwindow {\n"
" xbackground-color: green;\n"
"}\n"
"#mydrawingarea {\n"
" background-color: #a0a0a0;\n"
"}\n"
, -1, NULL);
gtk_style_context_add_provider_for_screen (gdk_screen_get_default(),
GTK_STYLE_PROVIDER (provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
g_object_unref(provider);
window = gtk_application_window_new (app);
gtk_window_set_title (GTK_WINDOW (window), "Window");
gtk_window_set_default_size (GTK_WINDOW (window), 200, 200);
sw = gtk_scrolled_window_new(NULL, NULL);
gtk_widget_set_name(sw, "myscrolledwindow");
gtk_container_add (GTK_CONTAINER(window), sw);
vp = gtk_viewport_new(NULL, NULL);
gtk_container_add(GTK_CONTAINER(sw), vp);
da = gtk_drawing_area_new();
gtk_widget_set_name(da, "mydrawingarea");
gtk_widget_set_size_request (da, 640, 480);
gtk_container_add(GTK_CONTAINER(vp), da);
g_signal_connect (G_OBJECT(da), "draw", G_CALLBACK (draw_callback),
NULL);
gtk_widget_show_all (window);
}
int main (int argc, char **argv)
{
GtkApplication *app;
int status;
app = gtk_application_new ("org.gtk.example", G_APPLICATION_FLAGS_NONE);
g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
status = g_application_run (G_APPLICATION (app), argc, argv);
g_object_unref (app);
return status;
}
------------------------------------------------------------------------
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]