From 38020e7234837a72e8e47f1926d0ed0a581010fe Mon Sep 17 00:00:00 2001 From: rbuj Date: Tue, 11 Feb 2020 15:13:26 +0100 Subject: logview: Rewrite logview-filter.ui from scratch --- logview/data/logview-filter.ui | 356 +++++++++++++++++++++-------------- logview/src/logview-filter-manager.c | 80 +++----- 2 files changed, 235 insertions(+), 201 deletions(-) diff --git a/logview/data/logview-filter.ui b/logview/data/logview-filter.ui index 57e8cb59..55fc65c5 100644 --- a/logview/data/logview-filter.ui +++ b/logview/data/logview-filter.ui @@ -1,198 +1,298 @@ - + + - - + + + True + False + process-stop + + + True + False + gtk-apply + - 5 - True - normal + False + dialog + + + - - True - 6 - - - True - 3 - 2 - 12 - 6 - - - True - 0 - _Name: - True - - - GTK_FILL - GTK_FILL - - + + False + vertical + 12 + + + False + end - + + _Cancel True - 0 - _Regular Expression: + True + True + image1 True + True - 1 - 2 - GTK_FILL - GTK_FILL + True + True + 0 - + + _Apply True True + True + True + True + image2 + True + True - 1 - 2 + True + True + 1 + + + False + False + 0 + + + + + True + False + 12 + 12 + 12 + vertical + 12 - + True - True + False + 6 + 6 + + + True + False + start + _Name: + True + entry_name + + + + + + 0 + 0 + + + + + True + False + start + _Regular Expression: + True + entry_regex + + + + + + 0 + 1 + + + + + True + True + True + + + + + + 1 + 0 + + + + + True + True + True + + + + + + 1 + 1 + + - 1 - 2 - 1 - 2 + False + True + 0 - + True + False 0 - 0 none - + True + False 12 - + True - 2 - 2 - 12 - 12 + False + 6 + vertical + 12 - - Highlight + True - True - False - 0 - True - True - - - - - Hide - True - True - False - 0 - True - True - - - 1 - 2 - - - - - True - 5 + False + vertical + + + Highlight + True + True + False + start + True + True + + + False + True + 0 + + - + + True - 12 + False + 12 + 6 + 6 + True Foreground: True True False - 0 + start True - 0 + 0 + 0 - + + True + Background: True True - True + False + start + True - 1 + 0 + 1 - - - 0 - - - - - True - 12 - - Background: + + True True - False - 0 - True + True + rgb(238,238,236) - 0 + 1 + 0 + True True True + rgb(164,0,0) - 1 + 1 + 1 + False + True 1 - 1 - 2 + False + True + 0 - + + Hide + True + True + False + start + True + radio_color + + + False + True + 1 + - + True - 0 + False Effect: @@ -201,49 +301,15 @@ - 2 - 2 - 3 - 6 - - - - - 1 - - - - - True - end - - - gtk-cancel - True - True - True - True - - - 0 - - - - - gtk-apply - True - True - True - True - - + False + True 1 False - end + True 0 diff --git a/logview/src/logview-filter-manager.c b/logview/src/logview-filter-manager.c index 299a5a53..d411029d 100644 --- a/logview/src/logview-filter-manager.c +++ b/logview/src/logview-filter-manager.c @@ -156,13 +156,6 @@ check_regex (LogviewFilterManager *manager, const gchar *regex) return TRUE; } -static void -on_check_toggled (GtkToggleButton *button, GtkWidget *widget) -{ - gtk_widget_set_sensitive (widget, - gtk_toggle_button_get_active (button)); -} - static void on_dialog_add_edit_reponse (GtkWidget *dialog, int response_id, LogviewFilterManager *manager) @@ -201,24 +194,6 @@ on_dialog_add_edit_reponse (GtkWidget *dialog, int response_id, tag = gtk_text_tag_new (name); if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radio_color))) { - if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_foreground))) { - GdkRGBA foreground_color; - gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (color_foreground), - &foreground_color); - g_object_set (G_OBJECT (tag), - "foreground-rgba", &foreground_color, - "foreground-set", TRUE, NULL); - } - - if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_background))) { - GdkRGBA background_color; - gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (color_background), - &background_color); - g_object_set (tag, - "paragraph-background-rgba", &background_color, - "paragraph-background-set", TRUE, NULL); - } - if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_foreground)) && !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_background))) { GtkWidget *error_dialog; @@ -236,6 +211,19 @@ on_dialog_add_edit_reponse (GtkWidget *dialog, int response_id, return; } + + GdkRGBA foreground_color, background_color; + + gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (color_foreground), &foreground_color); + g_object_set (G_OBJECT (tag), + "foreground-rgba", &foreground_color, + "foreground-set", gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_foreground)), + NULL); + gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (color_background), &background_color); + g_object_set (tag, + "paragraph-background-rgba", &background_color, + "paragraph-background-set", gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_background)), + NULL); } else { /* !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radio_color)) */ g_object_set (tag, "invisible", TRUE, NULL); } @@ -264,7 +252,7 @@ run_add_edit_dialog (LogviewFilterManager *manager, LogviewFilter *filter) const gchar *title; GtkWidget *dialog, *entry_name, *entry_regex, *radio_color; GtkWidget *radio_visible, *check_foreground, *check_background; - GtkWidget *color_foreground, *color_background, *vbox_color; + GtkWidget *color_foreground, *color_background; gboolean foreground_set, background_set, invisible; GtkTextTag *tag; GtkBuilder* builder; @@ -289,65 +277,45 @@ run_add_edit_dialog (LogviewFilterManager *manager, LogviewFilter *filter) check_background = GET_WIDGET ("check_background"); color_foreground = GET_WIDGET ("color_foreground"); color_background = GET_WIDGET ("color_background"); - vbox_color = GET_WIDGET ("vbox_color"); title = (filter != NULL ? _("Edit filter") : _("Add new filter")); gtk_window_set_title (GTK_WINDOW (dialog), title); - gtk_radio_button_set_group (GTK_RADIO_BUTTON (radio_color), - gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio_visible))); - - g_signal_connect (check_foreground, "toggled", G_CALLBACK (on_check_toggled), - color_foreground); - g_signal_connect (check_background, "toggled", G_CALLBACK (on_check_toggled), - color_background); - - on_check_toggled (GTK_TOGGLE_BUTTON (check_foreground), - color_foreground); - on_check_toggled (GTK_TOGGLE_BUTTON (check_background), - color_background); - - g_signal_connect (radio_color, "toggled", G_CALLBACK (on_check_toggled), - vbox_color); - on_check_toggled (GTK_TOGGLE_BUTTON (radio_color), - vbox_color); - if (filter) { + GdkRGBA *foreground, *background; + g_object_get (filter, "name", &name, "regex", ®ex, "texttag", &tag, NULL); + g_object_get (tag, "foreground-set", &foreground_set, "paragraph-background-set", &background_set, - "invisible", &invisible, NULL); + "invisible", &invisible, + NULL); + gtk_entry_set_text (GTK_ENTRY(entry_name), name); gtk_entry_set_text (GTK_ENTRY(entry_regex), regex); if (foreground_set) { - GdkRGBA *foreground; - g_object_get (tag, "foreground-rgba", &foreground, NULL); gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (color_foreground), foreground); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_foreground), - TRUE); - gdk_rgba_free (foreground); } + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_foreground), + foreground_set); if (background_set) { - GdkRGBA *background; - g_object_get (tag, "paragraph-background-rgba", &background, NULL); gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (color_background), background); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_background), - TRUE); - gdk_rgba_free (background); } + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_background), + background_set); if (background_set || foreground_set) { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio_color), TRUE); -- cgit v1.2.1