I want to apply a border to GtkText Widget using css but facing issue. If I apply the border via CSS, the copy paste option in the default right click context menu stops working. Showing this warning — Gtk-WARNING **: 23:17:00.572: Broken accounting of active state for widget 0x5591d99d8220(GtkPopoverMenu)
.
How to apply outer border on GtkText widget without any issue?
#include <gtk/gtk.h>
static const char *css =
"text {"
" all: unset;"
" border: 1px solid black;" /*copy past from right click contextmenu not working by this line */
" min-height:20px;"
" padding-left: 10px;"
" font-size: 9.5px;"
"}" ;
static void
activate (GtkApplication* app,
gpointer user_data)
{
GtkWidget *window;
window = gtk_application_window_new (app);
gtk_window_set_title (GTK_WINDOW (window), "Window");
gtk_window_set_default_size (GTK_WINDOW (window), 200, 200);
gtk_window_present (GTK_WINDOW (window));
GtkWidget *grid = gtk_grid_new ();
gtk_window_set_child (GTK_WINDOW (window), grid);
GtkCssProvider* provider = gtk_css_provider_new ();
gtk_css_provider_load_from_data (provider, css, -1);
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
GTK_STYLE_PROVIDER (provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
g_object_unref(provider);
GtkWidget *text = gtk_text_new();
gtk_grid_attach ((GtkGrid *)grid, text, 0, 0, 1, 1);
gtk_window_present (GTK_WINDOW(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;
}