diff options
author | Alexander Schwinn <acs82@gmx.de> | 2017-11-27 22:14:40 +0100 |
---|---|---|
committer | Alexander Schwinn <acs82@gmx.de> | 2017-11-28 21:11:36 +0100 |
commit | cae29f86003e1b55428fdbeb2639d80ff2525ecb (patch) | |
tree | 70893de824fed402f2c87a9a088d3f5563b7218e /plugins | |
parent | c0ed53676e42053a37ed9b5031578bfbd559126d (diff) | |
download | thunar-cae29f86003e1b55428fdbeb2639d80ff2525ecb.tar.gz |
Replace gtk3 deprecations "gtk_widget_modify_text",
"gtk_widget_modify_base" and "gdk_color_parse" by css
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/thunar-sbr/thunar-sbr-number-renamer.c | 27 | ||||
-rw-r--r-- | plugins/thunar-sbr/thunar-sbr-remove-renamer.c | 29 | ||||
-rw-r--r-- | plugins/thunar-sbr/thunar-sbr-replace-renamer.c | 19 |
3 files changed, 17 insertions, 58 deletions
diff --git a/plugins/thunar-sbr/thunar-sbr-number-renamer.c b/plugins/thunar-sbr/thunar-sbr-number-renamer.c index 4b816642..1b4b1b26 100644 --- a/plugins/thunar-sbr/thunar-sbr-number-renamer.c +++ b/plugins/thunar-sbr/thunar-sbr-number-renamer.c @@ -467,10 +467,8 @@ thunar_sbr_number_renamer_process (ThunarxRenamer *renamer, static void thunar_sbr_number_renamer_update (ThunarSbrNumberRenamer *number_renamer) { - gboolean invalid = TRUE; - GdkColor back; - GdkColor text; - gchar *endp; + gboolean invalid = TRUE; + gchar *endp; /* check whether "start" is valid for the "mode" */ if (number_renamer->mode < THUNAR_SBR_NUMBER_MODE_ABC) @@ -490,26 +488,11 @@ thunar_sbr_number_renamer_update (ThunarSbrNumberRenamer *number_renamer) /* check if the start entry is realized */ if (gtk_widget_get_realized (number_renamer->start_entry)) { - /* check if the "start" value is valid */ + /* highlight invalid input by using theme specific colors */ if (G_UNLIKELY (invalid)) - { - /* if GTK+ wouldn't be that stupid with style properties and - * type plugins, this would be themable, but unfortunately - * GTK+ is totally broken, and so it's hardcoded. - */ - gdk_color_parse ("#ff6666", &back); - gdk_color_parse ("White", &text); - - /* setup a red background/text color to indicate the error */ - gtk_widget_modify_base (number_renamer->start_entry, GTK_STATE_NORMAL, &back); - gtk_widget_modify_text (number_renamer->start_entry, GTK_STATE_NORMAL, &text); - } + gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (number_renamer->start_entry)), "error"); else - { - /* reset background/text color */ - gtk_widget_modify_base (number_renamer->start_entry, GTK_STATE_NORMAL, NULL); - gtk_widget_modify_text (number_renamer->start_entry, GTK_STATE_NORMAL, NULL); - } + gtk_style_context_remove_class (gtk_widget_get_style_context (GTK_WIDGET (number_renamer->start_entry)), "error"); } /* notify everybody that we have a new state */ diff --git a/plugins/thunar-sbr/thunar-sbr-remove-renamer.c b/plugins/thunar-sbr/thunar-sbr-remove-renamer.c index 373da48b..2f961e57 100644 --- a/plugins/thunar-sbr/thunar-sbr-remove-renamer.c +++ b/plugins/thunar-sbr/thunar-sbr-remove-renamer.c @@ -368,10 +368,8 @@ thunar_sbr_remove_renamer_process (ThunarxRenamer *renamer, static void thunar_sbr_remove_renamer_update (ThunarSbrRemoveRenamer *remove_renamer) { - GdkColor back; - GdkColor text; - guint start_offset; - guint end_offset; + guint start_offset; + guint end_offset; /* check if the renamer is realized */ if (gtk_widget_get_realized (GTK_WIDGET (remove_renamer))) @@ -381,28 +379,17 @@ thunar_sbr_remove_renamer_update (ThunarSbrRemoveRenamer *remove_renamer) ? remove_renamer->end_offset : (G_MAXUINT - remove_renamer->end_offset); start_offset = (remove_renamer->start_offset_mode == THUNAR_SBR_OFFSET_MODE_LEFT) ? remove_renamer->start_offset : (G_MAXUINT - remove_renamer->start_offset); + + /* highlight invalid input by using theme specific colors */ if (G_UNLIKELY (start_offset >= end_offset)) { - /* if GTK+ wouldn't be that stupid with style properties and - * type plugins, this would be themable, but unfortunately - * GTK+ is totally broken, and so it's hardcoded. - */ - gdk_color_parse ("#ff6666", &back); - gdk_color_parse ("White", &text); - - /* setup a red background/text color to indicate the error */ - gtk_widget_modify_base (remove_renamer->end_spinner, GTK_STATE_NORMAL, &back); - gtk_widget_modify_text (remove_renamer->end_spinner, GTK_STATE_NORMAL, &text); - gtk_widget_modify_base (remove_renamer->start_spinner, GTK_STATE_NORMAL, &back); - gtk_widget_modify_text (remove_renamer->start_spinner, GTK_STATE_NORMAL, &text); + gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (remove_renamer->start_spinner)), "error"); + gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (remove_renamer->end_spinner)), "error"); } else { - /* reset background/text colors */ - gtk_widget_modify_base (remove_renamer->end_spinner, GTK_STATE_NORMAL, NULL); - gtk_widget_modify_text (remove_renamer->end_spinner, GTK_STATE_NORMAL, NULL); - gtk_widget_modify_base (remove_renamer->start_spinner, GTK_STATE_NORMAL, NULL); - gtk_widget_modify_text (remove_renamer->start_spinner, GTK_STATE_NORMAL, NULL); + gtk_style_context_remove_class (gtk_widget_get_style_context (GTK_WIDGET (remove_renamer->start_spinner)), "error"); + gtk_style_context_remove_class (gtk_widget_get_style_context (GTK_WIDGET (remove_renamer->end_spinner)), "error"); } } diff --git a/plugins/thunar-sbr/thunar-sbr-replace-renamer.c b/plugins/thunar-sbr/thunar-sbr-replace-renamer.c index 71d27a9c..062357c1 100644 --- a/plugins/thunar-sbr/thunar-sbr-replace-renamer.c +++ b/plugins/thunar-sbr/thunar-sbr-replace-renamer.c @@ -569,8 +569,6 @@ static void thunar_sbr_replace_renamer_pcre_update (ThunarSbrReplaceRenamer *replace_renamer) { const gchar *error_message = NULL; - GdkColor back; - GdkColor text; gchar *tooltip; gchar *message; glong offset; @@ -618,16 +616,8 @@ thunar_sbr_replace_renamer_pcre_update (ThunarSbrReplaceRenamer *replace_renamer /* check if the entry is realized */ if (gtk_widget_get_realized (replace_renamer->pattern_entry)) { - /* if GTK+ wouldn't be that stupid with style properties and - * type plugins, this would be themable, but unfortunately - * GTK+ is totally broken, and so it's hardcoded. - */ - gdk_color_parse ("#ff6666", &back); - gdk_color_parse ("White", &text); - - /* setup a red background/text color to indicate the error */ - gtk_widget_modify_base (replace_renamer->pattern_entry, GTK_STATE_NORMAL, &back); - gtk_widget_modify_text (replace_renamer->pattern_entry, GTK_STATE_NORMAL, &text); + /* highlight invalid input by using theme-specific colors */ + gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (replace_renamer->pattern_entry)), "error"); } } else @@ -635,9 +625,8 @@ thunar_sbr_replace_renamer_pcre_update (ThunarSbrReplaceRenamer *replace_renamer /* check if the entry is realized */ if (gtk_widget_get_realized (replace_renamer->pattern_entry)) { - /* reset background/text color */ - gtk_widget_modify_base (replace_renamer->pattern_entry, GTK_STATE_NORMAL, NULL); - gtk_widget_modify_text (replace_renamer->pattern_entry, GTK_STATE_NORMAL, NULL); + /* stop highlight of invalid input if any */ + gtk_style_context_remove_class (gtk_widget_get_style_context (GTK_WIDGET (replace_renamer->pattern_entry)), "error"); } /* reset to default tooltip */ |