Re: How to change GTK+3 label color dynamically
On Wed, 2017-03-15 at 15:11 +, Rúben Rodrigues wrote: > Hi, > > Now i need to change GtkLabel color dinamically, so i thing that i > can't > use Css to do this.. I do this in Gtk2: > > gtk_widget_modify_fg(GTK_WIDGET(gtk_builder_get_object(builder,"label > ")),GTK_STATE_NORMAL, > &white); > > How can i change the color in Gtk3? > > You can do it with CSS. But it has changed a bit for 3.20. You may compare this thread: https://mail.gnome.org/archives/gtk-list/2016-November/msg6.html Well, that was not for label widget, but for tooltip. But label widget should behave similar. And with similar code I once set foreground and background for button widgets -- I had that working for 3.18, but I have not yet fixed that for 3.20. (https://github.com/ngtk3/nim-gtk3/bl ob/master/test/colors.nim) ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: How to change GTK+3 label color dynamically
Hi, THanks. This is dynamically? I need in c language if possible :S Thanks On 16-03-2017 07:29, Stefan Salewski wrote: > On Wed, 2017-03-15 at 15:11 +, Rúben Rodrigues wrote: >> Hi, >> >> Now i need to change GtkLabel color dinamically, so i thing that i >> can't >> use Css to do this.. I do this in Gtk2: >> >> gtk_widget_modify_fg(GTK_WIDGET(gtk_builder_get_object(builder,"label >> ")),GTK_STATE_NORMAL, >> &white); >> >> How can i change the color in Gtk3? >> >> > You can do it with CSS. But it has changed a bit for 3.20. You may > compare this thread: > > https://mail.gnome.org/archives/gtk-list/2016-November/msg6.html > > Well, that was not for label widget, but for tooltip. But label widget > should behave similar. And with similar code I once set foreground and > background for button widgets -- I had that working for 3.18, but I > have not yet fixed that for 3.20. (https://github.com/ngtk3/nim-gtk3/bl > ob/master/test/colors.nim) ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: How to change GTK+3 label color dynamically
On Thu, 2017-03-16 at 09:55 +, Rúben Rodrigues wrote: > Hi, > > THanks. This is dynamically? I need in c language if possible :S > > Thanks Yes. The example https://github.com/ngtk3/nim-gtk3/blob/master/test/colors.nim is dynamically, I used it to generate some color schemes. Entered color hex value in a text entry widget, and that color was applied. As I said, it was working for 3.18. I think for 3.20 and above some CSS names have changed, I had not the time to really investigate that. I have no C code currently, I think my Nim code was inspired by Python code, but I have no link to that python code currently. For C it is the same pattern -- generate a CSS string and apply it. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
How to change GTK+3 label color dynamically
Please help me. I don't see nothing with web to change label color dynamically but i need this urgent THanks again! On 16-03-2017 09:55, Rúben Rodrigues wrote: > Hi, > > THanks. This is dynamically? I need in c language if possible :S > > Thanks > > > On 16-03-2017 07:29, Stefan Salewski wrote: >> On Wed, 2017-03-15 at 15:11 +, Rúben Rodrigues wrote: >>> Hi, >>> >>> Now i need to change GtkLabel color dinamically, so i thing that i >>> can't >>> use Css to do this.. I do this in Gtk2: >>> >>> gtk_widget_modify_fg(GTK_WIDGET(gtk_builder_get_object(builder,"label >>> ")),GTK_STATE_NORMAL, >>> &white); >>> >>> How can i change the color in Gtk3? >>> >>> >> You can do it with CSS. But it has changed a bit for 3.20. You may >> compare this thread: >> >> https://mail.gnome.org/archives/gtk-list/2016-November/msg6.html >> >> Well, that was not for label widget, but for tooltip. But label widget >> should behave similar. And with similar code I once set foreground and >> background for button widgets -- I had that working for 3.18, but I >> have not yet fixed that for 3.20. (https://github.com/ngtk3/nim-gtk3/bl >> ob/master/test/colors.nim) > ___ > 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
Re: How to change GTK+3 label color dynamically
Am Donnerstag, den 16.03.2017, 09:55 + schrieb Rúben Rodrigues: > Hi, > > THanks. This is dynamically? I need in c language if possible :S Dynamic version: ... static GtkCssProvider* provider = NULL; static void set_label_color(GtkWidget* label, const char* color) { const char* format = "label { color: %s; }"; size_t length = strlen(format) - 2 + 1; char style[length]; sprintf(style, format, color); if (provider == NULL) { /* only create and add the provider the first time */ provider = gtk_css_provider_new(); gtk_style_context_add_provider( gtk_widget_get_style_context(label), GTK_STYLE_PROVIDER(provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); g_object_unref(provider); } gtk_css_provider_load_from_data(provider, style, -1, NULL); } ... This might not be ideal in all situations. Just make sure you don't create a new provider everytime you set a new color. Hope that helps. --Tilo ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: How to change GTK+3 label color dynamically
Hi, This is what i have, and don't works... On 16-03-2017 11:20, Tilo Villwock wrote: > Am Donnerstag, den 16.03.2017, 09:55 + schrieb Rúben Rodrigues: >> Hi, >> >> THanks. This is dynamically? I need in c language if possible :S > Dynamic version: > > ... > > static GtkCssProvider* provider = NULL; > > static void > set_label_color(GtkWidget* label, const char* color) > { > const char* format = "label { color: %s; }"; > size_t length = strlen(format) - 2 + 1; > char style[length]; > sprintf(style, format, color); > > if (provider == NULL) { > /* only create and add the provider the first time */ > provider = gtk_css_provider_new(); > gtk_style_context_add_provider( > gtk_widget_get_style_context(label), > GTK_STYLE_PROVIDER(provider), > GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); > g_object_unref(provider); > } > > gtk_css_provider_load_from_data(provider, style, -1, NULL); > } > > ... > > This might not be ideal in all situations. Just make sure you don't > create a new provider everytime you set a new color. Hope that helps. > > --Tilo ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: How to change GTK+3 label color dynamically
I provide my code in previous emails. This is my code now: if(css_provider == NULL){ css_provider = gtk_css_provider_new(); gtk_style_context_add_provider (gtk_widget_get_style_context(GTK_WIDGET(gtk_builder_get_object(builder,"window_Main"))), GTK_STYLE_PROVIDER (css_provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); g_object_unref(css_provider); } gtk_css_provider_load_from_data (css_provider,"#label_Sensors { color: red; }",-1,NULL); On 16-03-2017 12:41, Tilo Villwock wrote: > Am Donnerstag, den 16.03.2017, 11:58 + schrieb Rúben Rodrigues: >> Hi, >> >> This is what i have, and don't works... > The code I provided works. What GTK3 version are you using? Also nobody > will be able to help you if you don't show us your code. > > --Tilo ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: How to change GTK+3 label color dynamically
You keep using an id in the selector, but you never show how you set the id on the widget. I suspect you think the buildable ID you use with GtkBuilder is also the ID used when theming — which is definitely not the case. You will need gtk_widget_set_name(), instead. Of course, that comes with its own set of caveats, most importantly: there's no uniqueness of widget name enforced by GTK+ itself. If you want to avoid all of this, use a CSS class; you can add a class programmatically using gtk_style_context_add_class() or you can specify the class in the GtkBuilder XML file. Ciao, Emmanuele. On 16 March 2017 at 12:49, Rúben Rodrigues wrote: > I provide my code in previous emails. > > This is my code now: > > if(css_provider == NULL){ > css_provider = gtk_css_provider_new(); > > gtk_style_context_add_provider > (gtk_widget_get_style_context(GTK_WIDGET(gtk_builder_get_object(builder,"window_Main"))), > GTK_STYLE_PROVIDER (css_provider), > GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); > g_object_unref(css_provider); > > } > gtk_css_provider_load_from_data (css_provider,"#label_Sensors { > color: red; }",-1,NULL); > > > On 16-03-2017 12:41, Tilo Villwock wrote: >> Am Donnerstag, den 16.03.2017, 11:58 + schrieb Rúben Rodrigues: >>> Hi, >>> >>> This is what i have, and don't works... >> The code I provided works. What GTK3 version are you using? Also nobody >> will be able to help you if you don't show us your code. >> >> --Tilo > > ___ > gtk-app-devel-list mailing list > gtk-app-devel-list@gnome.org > https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list -- https://www.bassi.io [@] ebassi [@gmail.com] ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: How to change GTK+3 label color dynamically
No! This is the ID: https://ibin.co/3FlPSBGuokBB.png and this is the widget name https://ibin.co/3FlPnPaDN7Zl.png that i used in css provider. This is not the problem because in start of the program i change the label to other color to understand if css provider is working. And works, but when i tried in the middle of the code change again with this code don't works.. How can i add a Css class? How it works? I tried insert style classes in glade, but the value that i write disappear. Thanks On 16-03-2017 13:19, Emmanuele Bassi wrote: > You keep using an id in the selector, but you never show how you set > the id on the widget. I suspect you think the buildable ID you use > with GtkBuilder is also the ID used when theming — which is definitely > not the case. You will need gtk_widget_set_name(), instead. Of course, > that comes with its own set of caveats, most importantly: there's no > uniqueness of widget name enforced by GTK+ itself. > > If you want to avoid all of this, use a CSS class; you can add a class > programmatically using gtk_style_context_add_class() or you can > specify the class in the GtkBuilder XML file. > > Ciao, > Emmanuele. > > > On 16 March 2017 at 12:49, Rúben Rodrigues wrote: >> I provide my code in previous emails. >> >> This is my code now: >> >> if(css_provider == NULL){ >> css_provider = gtk_css_provider_new(); >> >> gtk_style_context_add_provider >> (gtk_widget_get_style_context(GTK_WIDGET(gtk_builder_get_object(builder,"window_Main"))), >> GTK_STYLE_PROVIDER (css_provider), >> GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); >> g_object_unref(css_provider); >> >> } >> gtk_css_provider_load_from_data (css_provider,"#label_Sensors { >> color: red; }",-1,NULL); >> >> >> On 16-03-2017 12:41, Tilo Villwock wrote: >>> Am Donnerstag, den 16.03.2017, 11:58 + schrieb Rúben Rodrigues: Hi, This is what i have, and don't works... >>> The code I provided works. What GTK3 version are you using? Also nobody >>> will be able to help you if you don't show us your code. >>> >>> --Tilo >> ___ >> 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
Re: How to change GTK+3 label color dynamically
I get this error: gtk-CRITICAL **: gtk_style_context_add_provider_for_screen: assertion 'GDK_IS_SCREEN (screen)' failed COde: gtk_style_context_add_provider_for_screen(gtk_widget_get_style_context(GTK_WIDGET(gtk_builder_get_object(builder,"window_Main"))), GTK_STYLE_PROVIDER (css_provider), G_MAXUINT); On 16-03-2017 13:19, Tilo Villwock wrote: > Am Donnerstag, den 16.03.2017, 12:49 + schrieb Rúben Rodrigues: >> I provide my code in previous emails. >> >> This is my code now: >> >> if(css_provider == NULL){ >> css_provider = gtk_css_provider_new(); >> >> gtk_style_context_add_provider >> (gtk_widget_get_style_context(GTK_WIDGET(gtk_builder_get_object(build >> er,"window_Main"))), >> GTK_STYLE_PROVIDER (css_provider), >> GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); >> g_object_unref(css_provider); >> >> } >> gtk_css_provider_load_from_data (css_provider,"#label_Sensors { >> color: red; }",-1,NULL); > My apologies. You are right. I missed the earlier one. However, quoting > the documentation for gtk_style_context_add_provider: > > "Note that a style provider added by this function only affects the > style of the widget to which context belongs. If you want to affect the > style of all widgets, use gtk_style_context_add_provider_for_screen()." > > I'm guessing `window_Main` is a window? So either you attach the > provider to all the labels you want to change or you use > gtk_style_context_add_provider_for_screen. > > Hope that helps. > > --Tilo ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: How to change GTK+3 label color dynamically
Am Donnerstag, den 16.03.2017, 13:50 + schrieb Rúben Rodrigues: > I get this error: > > gtk-CRITICAL **: gtk_style_context_add_provider_for_screen: > assertion > 'GDK_IS_SCREEN (screen)' failed > > COde: > gtk_style_context_add_provider_for_screen(gtk_widget_get_style_contex > t(GTK_WIDGET(gtk_builder_get_object(builder,"window_Main"))), > GTK_STYLE_PROVIDER (css_provider), > G_MAXUINT); Of course you do. The first argument is meant to be a GdkScreen object. Which makes me wonder if you even read the documentation. Anyways, you can obtain the object by invoking gdk_screen_get_default() and the last argument is supposed to be a priority constant like GTK_STYLE_PROVIDER_PRIORITY_APPLICATION Look them up. I'd also recommend installing devhelp and gtk3-docs if you haven't already. --Tilo ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: How to change GTK+3 label color dynamically
OK, now works: if(css_provider == NULL){ css_provider = gtk_css_provider_new(); apply_css(gtk_builder_get_object(builder,"window_Main"),css_provider); g_object_unref(css_provider); } gtk_css_provider_load_from_data (css_provider,"#label_Sensors { color: red; }",-1,NULL); static void apply_css(GtkWidget *widget, GtkStyleProvider *provider) { gtk_style_context_add_provider(gtk_widget_get_style_context(widget), GTK_STYLE_PROVIDER(provider),G_MAXUINT); if(GTK_IS_CONTAINER(widget)) gtk_container_forall(GTK_CONTAINER(widget),(GtkCallback) apply_css,provider); } I need to create a different selector for each of label that i want to change to red color? On 16-03-2017 13:19, Emmanuele Bassi wrote: > You keep using an id in the selector, but you never show how you set > the id on the widget. I suspect you think the buildable ID you use > with GtkBuilder is also the ID used when theming — which is definitely > not the case. You will need gtk_widget_set_name(), instead. Of course, > that comes with its own set of caveats, most importantly: there's no > uniqueness of widget name enforced by GTK+ itself. > > If you want to avoid all of this, use a CSS class; you can add a class > programmatically using gtk_style_context_add_class() or you can > specify the class in the GtkBuilder XML file. > > Ciao, > Emmanuele. > > > On 16 March 2017 at 12:49, Rúben Rodrigues wrote: >> I provide my code in previous emails. >> >> This is my code now: >> >> if(css_provider == NULL){ >> css_provider = gtk_css_provider_new(); >> >> gtk_style_context_add_provider >> (gtk_widget_get_style_context(GTK_WIDGET(gtk_builder_get_object(builder,"window_Main"))), >> GTK_STYLE_PROVIDER (css_provider), >> GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); >> g_object_unref(css_provider); >> >> } >> gtk_css_provider_load_from_data (css_provider,"#label_Sensors { >> color: red; }",-1,NULL); >> >> >> On 16-03-2017 12:41, Tilo Villwock wrote: >>> Am Donnerstag, den 16.03.2017, 11:58 + schrieb Rúben Rodrigues: Hi, This is what i have, and don't works... >>> The code I provided works. What GTK3 version are you using? Also nobody >>> will be able to help you if you don't show us your code. >>> >>> --Tilo >> ___ >> 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
Re: How to change GTK+3 label color dynamically
You are right. I don't know why don't works before, because I had already tested and doesn't work... BU apparently now works with gdk_screen_get_default(); THanks for your help. On 16-03-2017 14:07, Tilo Villwock wrote: > Am Donnerstag, den 16.03.2017, 13:50 + schrieb Rúben Rodrigues: >> I get this error: >> >> gtk-CRITICAL **: gtk_style_context_add_provider_for_screen: >> assertion >> 'GDK_IS_SCREEN (screen)' failed >> >> COde: >> gtk_style_context_add_provider_for_screen(gtk_widget_get_style_contex >> t(GTK_WIDGET(gtk_builder_get_object(builder,"window_Main"))), >> GTK_STYLE_PROVIDER (css_provider), >> G_MAXUINT); > Of course you do. The first argument is meant to be a GdkScreen object. > Which makes me wonder if you even read the documentation. Anyways, you > can obtain the object by invoking > > gdk_screen_get_default() > > and the last argument is supposed to be a priority constant like > > GTK_STYLE_PROVIDER_PRIORITY_APPLICATION > > Look them up. I'd also recommend installing devhelp and gtk3-docs if > you haven't already. > > --Tilo ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Can I get libgtk dependency packages automation.
Hum... I decided to use this binary. https://www.dropbox.com/sh/8d1qbh5dsp044on/UgkALzhlqH Thanks. On 2017年03月07日 03:05, michinari.nukazawa wrote: Hello. I devel to the vecterion vector graphics editor. https://github.com/MichinariNukazawa/vecterion_vge on Linux and Win64. libgtk binary package is old. I need latest version. Win64: http://win32builder.gnome.org/gtk+-bundle_3.10.4-20131202_win64.zip and Ubuntu16.04: 3.18.9 in default APT package. I think self build (for ubuntu) and cross build (Ubuntu host Win64 target) to libgtk. I need auto download dependency packages(atk, cairo, ...etc) and build. Can I get already implementation or solution? ( like this or other: https://github.com/MichinariNukazawa/GIMP-Compile-bash-Script/blob/master/gimp_make.sh ) I love libgtk, is good cross platform desktop application library. Thanks! -- == Michinari.Nukazawa in the project "daisy bell" https://daisy-bell.booth.pm/ == ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: How to change GTK+3 label color dynamically
From: R?ben Rodrigues > On 16-03-2017 11:20, Tilo Villwock wrote: > > Am Donnerstag, den 16.03.2017, 09:55 + schrieb R?ben Rodrigues: > >> Hi, > >> > >> THanks. This is dynamically? I need in c language if possible :S > > Dynamic version: > > > > ... > > > > static GtkCssProvider* provider = NULL; > > > > static void > > set_label_color(GtkWidget* label, const char* color) > > { > > const char* format = "label { color: %s; }"; > > size_t length = strlen(format) - 2 + 1; > > char style[length]; > > sprintf(style, format, color); > > > > if (provider == NULL) { > > /* only create and add the provider the first time */ > > provider = gtk_css_provider_new(); > > gtk_style_context_add_provider( > > gtk_widget_get_style_context(label), > > GTK_STYLE_PROVIDER(provider), > > GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); > > g_object_unref(provider); > > } > > > > gtk_css_provider_load_from_data(provider, style, -1, NULL); > > } > > > > ... > > > > This might not be ideal in all situations. Just make sure you don't > > create a new provider everytime you set a new color. Hope that helps. > > > > --Tilo > > Hi, > > This is what i have, and don't works... > I have this function (for any widget type): void set_background_color(GtkWidget *w, gchar *color) { GtkCssProvider *gcp; GtkStyleContext *gsc; gsc = gtk_widget_get_style_context(w); const gchar *type = g_type_name (G_TYPE_FROM_INSTANCE (w)); gchar *str = g_strdup_printf ("%s {background-color: %s;}", type, color); gcp= gtk_css_provider_new(); gtk_css_provider_load_from_data(gcp, str, -1, 0); g_free (str); gtk_style_context_add_provider(gsc, GTK_STYLE_PROVIDER(gcp), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); } I don't know if there is a memory leak here though... HTH Richard Shann ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
on screen keyboard error with gtk_main_do_event
HI guys, I have a on-screen keyboard that was made for gtk2. Now in gtk3 i get this errors: Gdk-CRITICAL **: gdk_window_get_user_data: assertion 'GDK_IS_WINDOW (window)' failed Gdk-CRITICAL **: gdk_window_get_display: assertion 'GDK_IS_WINDOW (window)' failed Gdk-WARNING **: Event with type 8 not holding a GdkDevice. It is most likely synthesized outside Gdk/GTK+ Gdk-CRITICAL **: gdk_window_get_display: assertion 'GDK_IS_WINDOW (window)' failed Gdk-CRITICAL **: gdk_display_get_device_manager: assertion 'GDK_IS_DISPLAY (display)' failed Gdk-CRITICAL **: gdk_device_manager_get_client_pointer: assertion 'GDK_IS_DEVICE_MANAGER (device_manager)' failed Gdk-CRITICAL **: gdk_device_get_associated_device: assertion 'GDK_IS_DEVICE (device)' failed Gdk-CRITICAL **: gdk_device_grab_info_libgtk_only: assertion 'GDK_IS_DISPLAY (display)' failed This appears in this line of code : gtk_main_do_event(pxEvent); Here is complete code: void on_Keypad_button_clicked(GtkButton *button, gpointer data) { GdkEvent*pxEvent = NULL; GdkKeymapKey*keys; gintiNkeys; guintcKey; GtkEntryBuffer*pxBuffer; struct xParam_Widget_Keycode*pxData; pxData = (struct xParam_Widget_Keycode *)data; switch(cKey = pxData->iKeyCode) { case GDK_KEY_BackSpace: pxBuffer = gtk_entry_get_buffer(GTK_ENTRY(pxData->pxWidget)); gtk_entry_buffer_delete_text(pxBuffer, gtk_entry_buffer_get_length(pxBuffer) - 1, -1); break; default: pxEvent = gdk_event_new(GDK_KEY_PRESS); if(gdk_keymap_get_entries_for_keyval(gdk_keymap_get_default(), cKey, &keys, &iNkeys)) { pxEvent->key.hardware_keycode = keys[0].keycode; pxEvent->key.group = keys[0].group; g_free(keys); pxEvent->key.keyval = gdk_unicode_to_keyval(cKey); } else { pxEvent->key.keyval = cKey; } pxEvent->key.window = g_object_ref(gtk_widget_get_screen (pxData->pxWidget)); pxEvent->key.state = 0; pxEvent->key.send_event = FALSE; pxEvent->key.time = GDK_CURRENT_TIME; gtk_main_do_event(pxEvent); pxEvent->key.type = GDK_KEY_RELEASE; gtk_main_do_event(pxEvent); gdk_event_free(pxEvent); } } Thanks ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: How to change GTK+3 label color dynamically
Thanks! In some containers we can't change color of label? I have labels inside GtkLayout, and don't change color with Css but other labels out of this layout change. Why don't works? I do this dynamically but don't works too: GtkCssProvider *css_provider = gtk_css_provider_new(); gtk_css_provider_load_from_data (css_provider, "#label_Sensors {" " color: red;" "}", -1, NULL); gtk_style_context_add_provider (gtk_widget_get_style_context(gtk_builder_get_object(builder,"Home_Sensors_Spare_window")), GTK_STYLE_PROVIDER (css_provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); g_object_unref(css_provider); On 16-03-2017 10:23, Stefan Salewski wrote: > On Thu, 2017-03-16 at 09:55 +, Rúben Rodrigues wrote: >> Hi, >> >> THanks. This is dynamically? I need in c language if possible :S >> >> Thanks > Yes. The example > > https://github.com/ngtk3/nim-gtk3/blob/master/test/colors.nim > > is dynamically, I used it to generate some color schemes. Entered color > hex value in a text entry widget, and that color was applied. > > As I said, it was working for 3.18. I think for 3.20 and above some CSS > names have changed, I had not the time to really investigate that. > > I have no C code currently, I think my Nim code was inspired by Python > code, but I have no link to that python code currently. For C it is the > same pattern -- generate a CSS string and apply it. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list