|
|
4b6aa8 |
From 4c0f1e7f4cd136ef515529df9330989f398ed6a1 Mon Sep 17 00:00:00 2001
|
|
|
4b6aa8 |
From: Martin Kutlak <mkutlak@redhat.com>
|
|
|
4b6aa8 |
Date: Thu, 8 Jun 2017 12:06:40 +0200
|
|
|
4b6aa8 |
Subject: [PATCH] gui: replace gtk_widget_override functions
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
gtk_widget_override_{font, color} functions were deprecated in version 3.16.
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
Elements should be styled with CSS.
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
https://developer.gnome.org/gtk3/stable/GtkWidget.html#gtk-widget-override-color
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
Signed-off-by: Martin Kutlak <mkutlak@redhat.com>
|
|
|
4b6aa8 |
---
|
|
|
4b6aa8 |
src/gtk-helpers/event_config_dialog.c | 17 +++++----
|
|
|
4b6aa8 |
src/gui-wizard-gtk/wizard.c | 55 +++++++++++++++------------
|
|
|
4b6aa8 |
2 files changed, 41 insertions(+), 31 deletions(-)
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
diff --git a/src/gtk-helpers/event_config_dialog.c b/src/gtk-helpers/event_config_dialog.c
|
|
|
4b6aa8 |
index 421a156..029e459 100644
|
|
|
4b6aa8 |
--- a/src/gtk-helpers/event_config_dialog.c
|
|
|
4b6aa8 |
+++ b/src/gtk-helpers/event_config_dialog.c
|
|
|
4b6aa8 |
@@ -292,13 +292,16 @@ config_dialog_t *create_event_config_dialog_content(event_config_t *event, GtkWi
|
|
|
4b6aa8 |
GtkWidget *keyring_warn_lbl =
|
|
|
4b6aa8 |
gtk_label_new(
|
|
|
4b6aa8 |
_("Secret Service is not available, your settings won't be saved!"));
|
|
|
4b6aa8 |
- static const GdkRGBA red = {
|
|
|
4b6aa8 |
- .red = 1.0,
|
|
|
4b6aa8 |
- .green = 0.0,
|
|
|
4b6aa8 |
- .blue = 0.0,
|
|
|
4b6aa8 |
- .alpha = 1.0,
|
|
|
4b6aa8 |
- };
|
|
|
4b6aa8 |
- gtk_widget_override_color(keyring_warn_lbl, GTK_STATE_FLAG_NORMAL, &red;;
|
|
|
4b6aa8 |
+ gtk_widget_set_name(keyring_warn_lbl, "keyring_warn_lbl");
|
|
|
4b6aa8 |
+
|
|
|
4b6aa8 |
+ GtkCssProvider *g_provider = gtk_css_provider_new();
|
|
|
4b6aa8 |
+ gtk_style_context_add_provider_for_screen(gdk_screen_get_default(),
|
|
|
4b6aa8 |
+ GTK_STYLE_PROVIDER(g_provider),
|
|
|
4b6aa8 |
+ GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
|
|
4b6aa8 |
+ const gchar *data = "#keyring_warn_lbl {color: rgba(100%, 0%, 0%, 1);}";
|
|
|
4b6aa8 |
+ gtk_css_provider_load_from_data(g_provider, data, -1, NULL);
|
|
|
4b6aa8 |
+ g_object_unref (g_provider);
|
|
|
4b6aa8 |
+
|
|
|
4b6aa8 |
gtk_box_pack_start(GTK_BOX(content), keyring_warn_lbl, false, false, 0);
|
|
|
4b6aa8 |
}
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
diff --git a/src/gui-wizard-gtk/wizard.c b/src/gui-wizard-gtk/wizard.c
|
|
|
4b6aa8 |
index 634a508..e19f790 100644
|
|
|
4b6aa8 |
--- a/src/gui-wizard-gtk/wizard.c
|
|
|
4b6aa8 |
+++ b/src/gui-wizard-gtk/wizard.c
|
|
|
4b6aa8 |
@@ -61,6 +61,8 @@ static guint g_event_source_id = 0;
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
static bool g_expert_mode;
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
+static GtkCssProvider *g_provider = NULL;
|
|
|
4b6aa8 |
+
|
|
|
4b6aa8 |
static GtkNotebook *g_assistant;
|
|
|
4b6aa8 |
static GtkWindow *g_wnd_assistant;
|
|
|
4b6aa8 |
static GtkBox *g_box_assistant;
|
|
|
4b6aa8 |
@@ -172,7 +174,6 @@ enum
|
|
|
4b6aa8 |
};
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
static GtkBuilder *g_builder;
|
|
|
4b6aa8 |
-static PangoFontDescription *g_monospace_font;
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
/* THE PAGE FLOW
|
|
|
4b6aa8 |
* page_0: introduction/summary
|
|
|
4b6aa8 |
@@ -294,6 +295,20 @@ static GtkBuilder *make_builder()
|
|
|
4b6aa8 |
return builder;
|
|
|
4b6aa8 |
}
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
+static void load_css_style()
|
|
|
4b6aa8 |
+{
|
|
|
4b6aa8 |
+ g_provider = gtk_css_provider_new();
|
|
|
4b6aa8 |
+ gtk_style_context_add_provider_for_screen(gdk_screen_get_default(),
|
|
|
4b6aa8 |
+ GTK_STYLE_PROVIDER(g_provider),
|
|
|
4b6aa8 |
+ GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
|
|
4b6aa8 |
+ const gchar *data = "#green_color {color: rgba(0%, 50%, 0%, 1);}\
|
|
|
4b6aa8 |
+ #red_color {color: rgba(100%, 0%, 0%, 1);}\
|
|
|
4b6aa8 |
+ #tev, #g_tv_event_log {font-family: monospace;}\
|
|
|
4b6aa8 |
+ #g_eb_comment {color: #CC3333;}";
|
|
|
4b6aa8 |
+ gtk_css_provider_load_from_data(g_provider, data, -1, NULL);
|
|
|
4b6aa8 |
+ g_object_unref (g_provider);
|
|
|
4b6aa8 |
+}
|
|
|
4b6aa8 |
+
|
|
|
4b6aa8 |
static void label_wrapper(GtkWidget *widget, gpointer data_unused)
|
|
|
4b6aa8 |
{
|
|
|
4b6aa8 |
if (GTK_IS_CONTAINER(widget))
|
|
|
4b6aa8 |
@@ -1061,6 +1076,9 @@ static event_gui_data_t *add_event_buttons(GtkBox *box,
|
|
|
4b6aa8 |
char *event_name,
|
|
|
4b6aa8 |
GCallback func)
|
|
|
4b6aa8 |
{
|
|
|
4b6aa8 |
+ if (g_provider == NULL)
|
|
|
4b6aa8 |
+ load_css_style();
|
|
|
4b6aa8 |
+
|
|
|
4b6aa8 |
//log_info("removing all buttons from box %p", box);
|
|
|
4b6aa8 |
gtk_container_foreach(GTK_CONTAINER(box), &remove_child_widget, NULL);
|
|
|
4b6aa8 |
g_list_foreach(*p_event_list, (GFunc)free_event_gui_data_t, NULL);
|
|
|
4b6aa8 |
@@ -1155,21 +1173,8 @@ static event_gui_data_t *add_event_buttons(GtkBox *box,
|
|
|
4b6aa8 |
GtkWidget *child = gtk_bin_get_child(GTK_BIN(button));
|
|
|
4b6aa8 |
if (child)
|
|
|
4b6aa8 |
{
|
|
|
4b6aa8 |
- static const GdkRGBA red = {
|
|
|
4b6aa8 |
- .red = 1.0,
|
|
|
4b6aa8 |
- .green = 0.0,
|
|
|
4b6aa8 |
- .blue = 0.0,
|
|
|
4b6aa8 |
- .alpha = 1.0,
|
|
|
4b6aa8 |
- };
|
|
|
4b6aa8 |
- static const GdkRGBA green = {
|
|
|
4b6aa8 |
- .red = 0.0,
|
|
|
4b6aa8 |
- .green = 0.5,
|
|
|
4b6aa8 |
- .blue = 0.0,
|
|
|
4b6aa8 |
- .alpha = 1.0,
|
|
|
4b6aa8 |
- };
|
|
|
4b6aa8 |
- const GdkRGBA *color = (green_choice ? &green : &red;;
|
|
|
4b6aa8 |
- //gtk_widget_modify_text(button, GTK_STATE_NORMAL, color);
|
|
|
4b6aa8 |
- gtk_widget_override_color(child, GTK_STATE_FLAG_NORMAL, color);
|
|
|
4b6aa8 |
+ const char *child_name = (green_choice ? "green_color" : "red_color");
|
|
|
4b6aa8 |
+ gtk_widget_set_name(child, child_name);
|
|
|
4b6aa8 |
}
|
|
|
4b6aa8 |
}
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
@@ -1321,6 +1326,9 @@ static void remove_tabs_from_notebook(GtkNotebook *notebook)
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
static void append_item_to_ls_details(gpointer name, gpointer value, gpointer data)
|
|
|
4b6aa8 |
{
|
|
|
4b6aa8 |
+ if (g_provider == NULL)
|
|
|
4b6aa8 |
+ load_css_style();
|
|
|
4b6aa8 |
+
|
|
|
4b6aa8 |
problem_item *item = (problem_item*)value;
|
|
|
4b6aa8 |
struct cd_stats *stats = data;
|
|
|
4b6aa8 |
GtkTreeIter iter;
|
|
|
4b6aa8 |
@@ -1335,11 +1343,11 @@ static void append_item_to_ls_details(gpointer name, gpointer value, gpointer da
|
|
|
4b6aa8 |
{
|
|
|
4b6aa8 |
GtkWidget *tab_lbl = gtk_label_new((char *)name);
|
|
|
4b6aa8 |
GtkWidget *tev = gtk_text_view_new();
|
|
|
4b6aa8 |
+ gtk_widget_set_name(GTK_WIDGET(tev), "tev");
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
if (strcmp(name, FILENAME_COMMENT) == 0 || strcmp(name, FILENAME_REASON) == 0)
|
|
|
4b6aa8 |
gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(tev), GTK_WRAP_WORD);
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
- gtk_widget_override_font(GTK_WIDGET(tev), g_monospace_font);
|
|
|
4b6aa8 |
load_text_to_text_view(GTK_TEXT_VIEW(tev), (char *)name);
|
|
|
4b6aa8 |
/* init searching */
|
|
|
4b6aa8 |
GtkTextBuffer *buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(tev));
|
|
|
4b6aa8 |
@@ -3503,6 +3511,9 @@ static void add_pages(void)
|
|
|
4b6aa8 |
{
|
|
|
4b6aa8 |
g_builder = make_builder();
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
+ if (g_provider == NULL)
|
|
|
4b6aa8 |
+ load_css_style();
|
|
|
4b6aa8 |
+
|
|
|
4b6aa8 |
int i;
|
|
|
4b6aa8 |
int page_no = 0;
|
|
|
4b6aa8 |
for (i = 0; page_names[i] != NULL; i++)
|
|
|
4b6aa8 |
@@ -3549,7 +3560,9 @@ static void add_pages(void)
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
gtk_widget_set_no_show_all(GTK_WIDGET(g_spinner_event_log), true);
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
- gtk_widget_override_font(GTK_WIDGET(g_tv_event_log), g_monospace_font);
|
|
|
4b6aa8 |
+ gtk_widget_set_name(GTK_WIDGET(g_tv_event_log), "g_tv_event_log");
|
|
|
4b6aa8 |
+ gtk_widget_set_name(GTK_WIDGET(g_eb_comment), "g_eb_comment");
|
|
|
4b6aa8 |
+
|
|
|
4b6aa8 |
fix_all_wrapped_labels(GTK_WIDGET(g_assistant));
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
g_signal_connect(g_cb_no_comment, "toggled", G_CALLBACK(on_no_comment_toggled), NULL);
|
|
|
4b6aa8 |
@@ -3557,10 +3570,6 @@ static void add_pages(void)
|
|
|
4b6aa8 |
g_signal_connect(g_rb_forbidden_words, "toggled", G_CALLBACK(on_forbidden_words_toggled), NULL);
|
|
|
4b6aa8 |
g_signal_connect(g_rb_custom_search, "toggled", G_CALLBACK(on_custom_search_toggled), NULL);
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
- /* Set color of the comment evenbox */
|
|
|
4b6aa8 |
- GdkRGBA color;
|
|
|
4b6aa8 |
- gdk_rgba_parse(&color, "#CC3333");
|
|
|
4b6aa8 |
- gtk_widget_override_color(GTK_WIDGET(g_eb_comment), GTK_STATE_FLAG_NORMAL, &color;;
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
g_signal_connect(g_tv_details, "key-press-event", G_CALLBACK(on_key_press_event_in_item_list), NULL);
|
|
|
4b6aa8 |
g_tv_sensitive_sel_hndlr = g_signal_connect(g_tv_sensitive_sel, "changed", G_CALLBACK(on_sensitive_word_selection_changed), NULL);
|
|
|
4b6aa8 |
@@ -3730,8 +3739,6 @@ void create_assistant(GtkApplication *app, bool expert_mode)
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
g_expert_mode = expert_mode;
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
- g_monospace_font = pango_font_description_from_string("monospace");
|
|
|
4b6aa8 |
-
|
|
|
4b6aa8 |
g_assistant = GTK_NOTEBOOK(gtk_notebook_new());
|
|
|
4b6aa8 |
|
|
|
4b6aa8 |
/* Show tabs only in verbose expert mode
|
|
|
4b6aa8 |
--
|
|
|
4b6aa8 |
2.21.0
|
|
|
4b6aa8 |
|