In my case, I have a chemical periodic table made with GTK buttons, each one representing a chemical element, with its default color. Users can change these chemical element default colors directly from the interface or from XML config files:
http://www.gamgi.org/screenshots/screenshot13_5.htmlRewritting an entire CSS file and downloading it everytime users change the default color of a chemical element looks really depressing... I am sure button colors can be changed directly from the code in GTK 3??
Carlos
On Sun, August 26, 2012 1:39 pm, Giuseppe Penone wrote:Hi, I faced the same problem some time ago in gtkmm3. I asked a question and then replied myself in this post: http://stackoverflow.com/questions/8952679/gtkmm-3-button-background-color-change You have to use a CSS file (a working example in my code) and import from code to override the gtk3 theme that you are using on your distribution. Cheers, Giuseppe.I had a similar problem and it seems that even with Priority = Application the default theme is overriding "override_background_color()". I would like to know if this is a bug as I wasted several hours trying to find the work around and ended up having to use the css method with the applicable config from the default theme which seems a little excessive when a 1 liner in code should be possible.On Sun, Aug 26, 2012 at 1:44 PM, Rudra Banerjee <bnrj.ru...@yahoo.com>wrote:I will be grateful if someone please show me the way. On Sun, 2012-08-26 at 00:20 +0100, Rudra Banerjee wrote:Friends, I am putting gtkbuttons inside a grid with modify_bg. I am getting an odd case that when the window is focused, all buttons are showingwhite,not what suggested by modify_bg. The same structure was working fineingtk2 (while I was using table instead of grid). I am posting the complete minimal code(60 line only) for yourreference.I have seen that the gtk_widget_modify_bg is deprecated in gtk 3 so I tried the suggested method with gtk_widget_override_background_colorbutthere it seems that declaration of GdkColor colorRed2 = {0x0000,65535,29555, 24158} has changed to something like GdkRGBA. I tried to change to GdkRGBA colorRed = {1,0,0,1}; yeilding error: ‘const struct GdkRGBA *’ but argument is of type ‘GdkRGBA’ Please Help. here is the complete code: #include<gtk/gtk.h> int main(int argc, char *argv[]) { GtkWidget *window; GtkWidget *grid; GtkWidget *menubar; GtkWidget *filemenu; GtkWidget *quit; GtkAccelGroup *accel_group = NULL; gtk_init(&argc,&argv); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(window), "Try Grid"); gtk_container_set_border_width(GTK_CONTAINER(window), 05); grid = gtk_grid_new(); gtk_container_add(GTK_CONTAINER(window), grid); gtk_grid_set_column_homogeneous(GTK_GRID(grid),TRUE); gtk_grid_set_row_homogeneous(GTK_GRID(grid),TRUE); menubar = gtk_menu_bar_new(); filemenu = gtk_menu_new(); accel_group = gtk_accel_group_new(); gtk_window_add_accel_group(GTK_WINDOW(window), accel_group); GtkWidget *file = gtk_menu_item_new_with_mnemonic("_File"); quit = gtk_image_menu_item_new_from_stock(GTK_STOCK_QUIT, accel_group); gtk_menu_item_set_submenu(GTK_MENU_ITEM(file), filemenu); gtk_menu_shell_append(GTK_MENU_SHELL(filemenu), quit); gtk_menu_shell_append(GTK_MENU_SHELL(menubar), file); g_signal_connect(G_OBJECT(quit), "activate", G_CALLBACK(gtk_main_quit), NULL); gtk_grid_attach(GTK_GRID(grid), menubar, 0, 0, 2, 1); /* Color Scheme */ GdkColor colorRed2 = {0x0000, 65535, 29555, 24158}; GdkColor colorBlue = {0x0000, 3598, 57054, 61937}; GdkColor colorWht = {0x0000, 65535, 65535, 65535}; GtkWidget *Abutton = gtk_button_new_with_label("A"); gtk_grid_attach(GTK_GRID(grid), Abutton, 0, 1, 1, 1); gtk_widget_modify_bg(Abutton, GTK_STATE_NORMAL,&colorBlue); gtk_widget_modify_bg(Abutton, GTK_STATE_PRELIGHT,&colorWht); /* Create second button */ GtkWidget *Bbutton = gtk_button_new_with_label("B"); gtk_grid_attach(GTK_GRID(grid), Bbutton, 10, 1, 1, 1); gtk_widget_modify_bg(Bbutton, GTK_STATE_NORMAL,&colorRed2); gtk_widget_modify_bg(Bbutton, GTK_STATE_PRELIGHT,&colorWht); gtk_widget_show_all(window); gtk_main(); return 0; } _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list_______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list_______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list-- Patrick Shirkey Boost Hardware Ltd _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
_______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list