GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Sat Aug 27, 2016 4:39 am

All times are UTC

Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Window manager overrides border color ?
PostPosted: Wed Aug 22, 2012 7:20 pm 
GTK+ Guru

Joined: Fri Mar 25, 2011 5:16 pm
Posts: 181
Location: USA
I have a button that I've changed the border color on but it appears that the window manager is overlaying the stock grey border color with it resulting in a muted version of the color.
Image 1 on the far left is a stock button with a 10 pixel wide border. Image 2 has a pink left border and image 3 is when hovering and pressing the mouse button.
Image 2 should have a red border the same brightness as image three but it's being overlaid with grey resulting in the pink color.
I'm running on Ubuntu Natty. I've tried both classic and Unico. Could someone on Precise Pangolin and or Debian confirm this behaviour ?
btn.png [ 17.11 KiB | Viewed 1028 times ]

*     gcc -Wall -o btnborder `pkg-config --cflags --libs gtk+-3.0` btnborder.c

#include <gtk/gtk.h>
#include <string.h>
int main (int argc, char *argv[])
  GtkWidget *window;
  GtkWidget *mybutton;

/*-- CSS ------------------*/
  GtkCssProvider *provider;
  GdkDisplay *display;
  GdkScreen *screen;
  gtk_init(&argc, &argv);

  window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
  gtk_widget_set_size_request(window, 200, 200);
  gtk_window_set_title(GTK_WINDOW(window), "button border");
  g_signal_connect(G_OBJECT (window), "destroy",
                   G_CALLBACK(gtk_main_quit), NULL);

  mybutton = gtk_button_new();
  gtk_widget_set_name( GTK_WIDGET(mybutton),"mybtn" );

  gtk_widget_set_margin_top( GTK_WIDGET(mybutton), 40);
  gtk_widget_set_margin_bottom( GTK_WIDGET(mybutton), 40);
  gtk_widget_set_margin_left( GTK_WIDGET(mybutton), 40);
  gtk_widget_set_margin_right( GTK_WIDGET(mybutton), 40);

/*---------------- CSS ----------------------------------------------------------------------------------------------------*/
  provider = gtk_css_provider_new ();
  display = gdk_display_get_default ();
  screen = gdk_display_get_default_screen (display);
  gtk_style_context_add_provider_for_screen (screen, GTK_STYLE_PROVIDER (provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);

  gsize bytes_written, bytes_read;

  const gchar* home = "/home/zerohour/gtk/programming/Tests/btn1.css"; 

  GError *error = 0;

   gtk_css_provider_load_from_path (provider,
                                    g_filename_to_utf8(home, strlen(home), &bytes_read, &bytes_written, &error),
  g_object_unref (provider);

  gtk_container_add( GTK_CONTAINER(window), mybutton );
  gtk_main ();
  return 0;

GtkWindow {
   background-color: black;

#mybtn  {
   border-width: 10;

   border-left-color: red;   

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC

Who is online

Users browsing this forum: Google [Bot], Yahoo [Bot] and 1 guest

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group