Mercurial > dwindows
comparison gtk3/dw.c @ 2243:8f9ffba67b7c
Editor on Linux really screwed up the formatting. Purely a formatting fix commit.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Tue, 19 Jan 2021 14:07:47 +0000 |
parents | 0c0ad67aacb5 |
children | 4fb54b9fcf78 |
comparison
equal
deleted
inserted
replaced
2242:0c0ad67aacb5 | 2243:8f9ffba67b7c |
---|---|
2713 GtkStyleContext *scontext = gtk_widget_get_style_context(widget); | 2713 GtkStyleContext *scontext = gtk_widget_get_style_context(widget); |
2714 | 2714 |
2715 /* If we have an old context from a previous override remove it */ | 2715 /* If we have an old context from a previous override remove it */ |
2716 if(provider) | 2716 if(provider) |
2717 { | 2717 { |
2718 gtk_style_context_remove_provider(scontext, GTK_STYLE_PROVIDER(provider)); | 2718 gtk_style_context_remove_provider(scontext, GTK_STYLE_PROVIDER(provider)); |
2719 g_object_unref(provider); | 2719 g_object_unref(provider); |
2720 provider = NULL; | 2720 provider = NULL; |
2721 } | 2721 } |
2722 | 2722 |
2723 /* If we have a new color, create a new provider and add it */ | 2723 /* If we have a new color, create a new provider and add it */ |
2724 if(color) | 2724 if(color) |
2725 { | 2725 { |
2726 gchar *scolor = gdk_rgba_to_string(color); | 2726 gchar *scolor = gdk_rgba_to_string(color); |
2727 gchar *css = g_strdup_printf ("* { %s: %s; }", element, scolor); | 2727 gchar *css = g_strdup_printf ("* { %s: %s; }", element, scolor); |
2728 | 2728 |
2729 provider = gtk_css_provider_new(); | 2729 provider = gtk_css_provider_new(); |
2730 g_free(scolor); | 2730 g_free(scolor); |
2731 gtk_css_provider_load_from_data(provider, css, -1, NULL); | 2731 gtk_css_provider_load_from_data(provider, css, -1, NULL); |
2732 g_free(css); | 2732 g_free(css); |
2733 gtk_style_context_add_provider(scontext, GTK_STYLE_PROVIDER(provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); | 2733 gtk_style_context_add_provider(scontext, GTK_STYLE_PROVIDER(provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); |
2734 } | 2734 } |
2735 g_object_set_data(G_OBJECT(widget), dataname, (gpointer)provider); | 2735 g_object_set_data(G_OBJECT(widget), dataname, (gpointer)provider); |
2736 g_free(dataname); | 2736 g_free(dataname); |
2737 } | 2737 } |
2738 | 2738 |
2739 static void _dw_override_font(GtkWidget *widget, const char *font) | 2739 static void _dw_override_font(GtkWidget *widget, const char *font) |
2740 { | 2740 { |
2741 GtkCssProvider *provider = g_object_get_data(G_OBJECT(widget), "_dw_font"); | 2741 GtkCssProvider *provider = g_object_get_data(G_OBJECT(widget), "_dw_font"); |
2742 GtkStyleContext *scontext = gtk_widget_get_style_context(widget); | 2742 GtkStyleContext *scontext = gtk_widget_get_style_context(widget); |
2743 | 2743 |
2744 /* If we have an old context from a previous override remove it */ | 2744 /* If we have an old context from a previous override remove it */ |
2745 if(provider) | 2745 if(provider) |
2746 { | 2746 { |
2747 gtk_style_context_remove_provider(scontext, GTK_STYLE_PROVIDER(provider)); | 2747 gtk_style_context_remove_provider(scontext, GTK_STYLE_PROVIDER(provider)); |
2748 g_object_unref(provider); | 2748 g_object_unref(provider); |
2749 provider = NULL; | 2749 provider = NULL; |
2750 } | 2750 } |
2751 | 2751 |
2752 /* If we have a new font, create a new provider and add it */ | 2752 /* If we have a new font, create a new provider and add it */ |
2753 if(font) | 2753 if(font) |
2754 { | 2754 { |
2755 gchar *css = g_strdup_printf ("* { font: %s; }", font); | 2755 gchar *css = g_strdup_printf ("* { font: %s; }", font); |
2756 | 2756 |
2757 provider = gtk_css_provider_new(); | 2757 provider = gtk_css_provider_new(); |
2758 gtk_css_provider_load_from_data(provider, css, -1, NULL); | 2758 gtk_css_provider_load_from_data(provider, css, -1, NULL); |
2759 g_free(css); | 2759 g_free(css); |
2760 gtk_style_context_add_provider(scontext, GTK_STYLE_PROVIDER(provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); | 2760 gtk_style_context_add_provider(scontext, GTK_STYLE_PROVIDER(provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); |
2761 } | 2761 } |
2762 g_object_set_data(G_OBJECT(widget), "_dw_font", (gpointer)provider); | 2762 g_object_set_data(G_OBJECT(widget), "_dw_font", (gpointer)provider); |
2763 } | 2763 } |
2764 | 2764 |
2765 /* | 2765 /* |
2766 * Sets the font used by a specified window (widget) handle. | 2766 * Sets the font used by a specified window (widget) handle. |
2767 * Parameters: | 2767 * Parameters: |