[balsa/gtk4: 311/311] HTML filter bug fixes and clarifications
- From: Peter Bloomfield <peterb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa/gtk4: 311/311] HTML filter bug fixes and clarifications
- Date: Fri, 17 Dec 2021 19:54:28 +0000 (UTC)
commit e95fdb617af9d4c10f6f0a19504b7f80e9f72575
Author: Albrecht Dreß <albrecht dress netcologne de>
Date: Sat Nov 6 21:23:40 2021 +0100
HTML filter bug fixes and clarifications
Fix bugs reported by @peterb in #62#note_1304251:
- do not show the info bar re. loading external content if the sender
preference in the database is set
- rename functions, parameters, etc. to indicate that external contents
is loaded, not only images
- fix user messages
Signed-off-by: Albrecht Dreß <albrecht dress netcologne de>
libbalsa/html-pref-db.c | 194 +++++++++++++++++++------------------------
libbalsa/html.c | 12 +--
src/balsa-mime-widget-text.c | 17 ++--
src/print-gtk.c | 6 +-
4 files changed, 108 insertions(+), 121 deletions(-)
---
diff --git a/libbalsa/html-pref-db.c b/libbalsa/html-pref-db.c
index 53cf43b35..a06523c6e 100644
--- a/libbalsa/html-pref-db.c
+++ b/libbalsa/html-pref-db.c
@@ -142,115 +142,95 @@ static const char action_namespace[] = "html-pref-popup-menu";
void
libbalsa_html_pref_dialog_run(GtkWindow *parent)
{
- GtkWidget *dialog;
- GtkWidget *vbox;
- GtkWidget *scrolled_window;
- GtkListStore *model;
- GtkWidget *tree_view;
- GtkTreeView *view;
- GtkGesture *gesture;
- GtkTreeSelection *selection;
- GtkCellRenderer *renderer;
- GtkTreeViewColumn *column;
- int sqlite_res;
+ GtkWidget *dialog;
+ GtkWidget *vbox;
+ GtkWidget *scrolled_window;
+ GtkListStore *model;
+ GtkWidget *tree_view;
+ GtkGesture *gesture;
+ GtkTreeSelection *selection;
+ GtkCellRenderer *renderer;
+ GtkTreeViewColumn *column;
+ int sqlite_res;
- if (!pref_db_check()) {
- return;
- }
+ if (!pref_db_check()) {
+ return;
+ }
- dialog =
- gtk_dialog_new_with_buttons(_("HTML preferences"), parent,
- GTK_DIALOG_DESTROY_WITH_PARENT | libbalsa_dialog_flags(),
- _("_Close"), GTK_RESPONSE_CLOSE, NULL);
- geometry_manager_attach(GTK_WINDOW(dialog), "HTMLPrefsDB");
-
- vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 12);
- gtk_box_append(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), vbox);
- gtk_widget_set_vexpand(vbox, TRUE);
-
- scrolled_window = gtk_scrolled_window_new();
-
- gtk_widget_set_margin_top(scrolled_window, 12U);
- gtk_widget_set_margin_bottom(scrolled_window, 12U);
- gtk_widget_set_margin_start(scrolled_window, 12U);
- gtk_widget_set_margin_end(scrolled_window, 12U);
-
- gtk_scrolled_window_set_has_frame(GTK_SCROLLED_WINDOW(scrolled_window), TRUE);
- gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window),
- GTK_POLICY_AUTOMATIC,
- GTK_POLICY_AUTOMATIC);
-
- gtk_widget_set_vexpand(scrolled_window, TRUE);
- gtk_widget_set_valign(scrolled_window, GTK_ALIGN_FILL);
- gtk_box_append(GTK_BOX(vbox), scrolled_window);
-
- model = gtk_list_store_new(PREFS_DB_VIEW_COLUMNS, G_TYPE_STRING, /* address */
- G_TYPE_BOOLEAN, /* prefer html over plain text */
- G_TYPE_BOOLEAN); /* auto-load images */
-
- tree_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model));
- view = GTK_TREE_VIEW(tree_view);
-
- gesture = gtk_gesture_click_new();
- gtk_widget_add_controller(tree_view, GTK_EVENT_CONTROLLER(gesture));
- gtk_gesture_single_set_button(GTK_GESTURE_SINGLE(gesture), 0);
- g_signal_connect(gesture, "pressed", G_CALLBACK(button_press_cb), NULL);
- gtk_event_controller_set_propagation_phase(GTK_EVENT_CONTROLLER(gesture), GTK_PHASE_CAPTURE);
- g_signal_connect(tree_view, "popup-menu", G_CALLBACK(popup_menu_cb), NULL);
-
- add_actions(tree_view, action_namespace);
-
- selection = gtk_tree_view_get_selection(view);
- gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);
-
- gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(scrolled_window), tree_view);
-
- /* add all database items */
- G_LOCK(db_mutex);
- sqlite_res = sqlite3_step(query[4]);
- while (sqlite_res == SQLITE_ROW) {
- GtkTreeIter iter;
-
- gtk_list_store_append(model, &iter);
- gtk_list_store_set(model, &iter,
- PREFS_ADDRESS_COLUMN, sqlite3_column_text(query[4], 0),
- PREFS_PREFER_HTML_COLUMN, sqlite3_column_int(query[4], 1),
- PREFS_LOAD_IMAGES_COLUMN, sqlite3_column_int(query[4], 2), -1);
- sqlite_res = sqlite3_step(query[4]);
- }
- sqlite3_reset(query[4]);
- G_UNLOCK(db_mutex);
-
- /* set up the tree view */
- renderer = gtk_cell_renderer_text_new();
- column =
- gtk_tree_view_column_new_with_attributes(_("Sender"), renderer, "text",
- PREFS_ADDRESS_COLUMN, NULL);
- gtk_tree_view_column_set_sort_column_id(column, PREFS_ADDRESS_COLUMN);
- gtk_tree_view_append_column(view, column);
- gtk_tree_view_column_set_resizable(column, TRUE);
-
- renderer = gtk_cell_renderer_toggle_new();
- g_object_set_data(G_OBJECT(renderer), "dbcol", GINT_TO_POINTER(PREFS_PREFER_HTML_COLUMN));
- g_signal_connect(renderer, "toggled", G_CALLBACK(on_prefs_button_toggled), model);
- column =
- gtk_tree_view_column_new_with_attributes(_("Prefer HTML"), renderer, "active",
- PREFS_PREFER_HTML_COLUMN, NULL);
- gtk_tree_view_append_column(view, column);
- gtk_tree_view_column_set_resizable(column, TRUE);
-
- renderer = gtk_cell_renderer_toggle_new();
- g_object_set_data(G_OBJECT(renderer), "dbcol", GINT_TO_POINTER(PREFS_LOAD_IMAGES_COLUMN));
- g_signal_connect(renderer, "toggled", G_CALLBACK(on_prefs_button_toggled), model);
- column =
- gtk_tree_view_column_new_with_attributes(_("Auto-load images"), renderer, "active",
- PREFS_LOAD_IMAGES_COLUMN, NULL);
- gtk_tree_view_append_column(view, column);
- gtk_tree_view_column_set_resizable(column, TRUE);
-
- gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(model), PREFS_ADDRESS_COLUMN,
- GTK_SORT_ASCENDING);
- g_object_unref(model);
+ dialog = gtk_dialog_new_with_buttons(_("HTML preferences"), parent, GTK_DIALOG_DESTROY_WITH_PARENT |
libbalsa_dialog_flags(),
+ _("_Close"), GTK_RESPONSE_CLOSE, NULL);
+ geometry_manager_attach(GTK_WINDOW(dialog), "HTMLPrefsDB");
+
+ vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 12);
+ gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), vbox);
+ gtk_widget_set_vexpand(vbox, TRUE);
+
+ scrolled_window = gtk_scrolled_window_new(NULL, NULL);
+ gtk_container_set_border_width(GTK_CONTAINER(scrolled_window), 12U);
+ gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled_window), GTK_SHADOW_ETCHED_IN);
+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window), GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
+ gtk_box_pack_start(GTK_BOX(vbox), scrolled_window, TRUE, TRUE, 0);
+
+ model = gtk_list_store_new(PREFS_DB_VIEW_COLUMNS,
+ G_TYPE_STRING, /* address */
+ G_TYPE_BOOLEAN, /* prefer html over plain text */
+ G_TYPE_BOOLEAN); /* auto-load external content */
+
+ tree_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model));
+
+ gesture = gtk_gesture_multi_press_new(tree_view);
+ gtk_gesture_single_set_button(GTK_GESTURE_SINGLE(gesture), 0);
+ g_signal_connect(gesture, "pressed", G_CALLBACK(button_press_cb), NULL);
+ gtk_event_controller_set_propagation_phase(GTK_EVENT_CONTROLLER(gesture), GTK_PHASE_CAPTURE);
+ g_signal_connect(tree_view, "popup-menu", G_CALLBACK(popup_menu_cb), NULL);
+
+ gtk_container_add(GTK_CONTAINER(scrolled_window), tree_view);
+ selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view));
+ gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);
+
+ /* add all database items */
+ G_LOCK(db_mutex);
+ sqlite_res = sqlite3_step(query[4]);
+ while (sqlite_res == SQLITE_ROW) {
+ GtkTreeIter iter;
+
+ gtk_list_store_append(model, &iter);
+ gtk_list_store_set(model, &iter,
+ PREFS_ADDRESS_COLUMN, sqlite3_column_text(query[4], 0),
+ PREFS_PREFER_HTML_COLUMN, sqlite3_column_int(query[4], 1),
+ PREFS_LOAD_EXT_CONTENT, sqlite3_column_int(query[4], 2),
+ -1);
+ sqlite_res = sqlite3_step(query[4]);
+ }
+ sqlite3_reset(query[4]);
+ G_UNLOCK(db_mutex);
+
+ /* set up the tree view */
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes(_("Sender"), renderer, "text",
PREFS_ADDRESS_COLUMN, NULL);
+ gtk_tree_view_column_set_sort_column_id(column, PREFS_ADDRESS_COLUMN);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view), column);
+ gtk_tree_view_column_set_resizable(column, TRUE);
+
+ renderer = gtk_cell_renderer_toggle_new();
+ g_object_set_data(G_OBJECT(renderer), "dbcol", GINT_TO_POINTER(PREFS_PREFER_HTML_COLUMN));
+ g_signal_connect(renderer, "toggled", G_CALLBACK(on_prefs_button_toggled), model);
+ column = gtk_tree_view_column_new_with_attributes(_("Prefer HTML"), renderer, "active",
PREFS_PREFER_HTML_COLUMN, NULL);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view), column);
+ gtk_tree_view_column_set_resizable(column, TRUE);
+ gtk_widget_show_all(vbox);
+
+ renderer = gtk_cell_renderer_toggle_new();
+ g_object_set_data(G_OBJECT(renderer), "dbcol", GINT_TO_POINTER(PREFS_LOAD_EXT_CONTENT));
+ g_signal_connect(renderer, "toggled", G_CALLBACK(on_prefs_button_toggled), model);
+ column = gtk_tree_view_column_new_with_attributes(_("Auto-load external content"), renderer,
"active", PREFS_LOAD_EXT_CONTENT,
+ NULL);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view), column);
+ gtk_tree_view_column_set_resizable(column, TRUE);
+ gtk_widget_show_all(vbox);
+
+ gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(model), PREFS_ADDRESS_COLUMN,
GTK_SORT_ASCENDING);
+ g_object_unref(model);
g_signal_connect(dialog, "response", G_CALLBACK(gtk_window_destroy), NULL);
gtk_widget_show(dialog);
diff --git a/libbalsa/html.c b/libbalsa/html.c
index 025f7e7e4..15e2396bb 100644
--- a/libbalsa/html.c
+++ b/libbalsa/html.c
@@ -432,12 +432,12 @@ lbh_info_bar(LibBalsaWebKitInfo * info)
GtkInfoBar *info_bar;
GtkWidget *label;
static const gchar text[] =
- N_("This message part references contents on one or more external servers. "
- "To protect your privacy, Balsa has not downloaded them. You may choose "
- "to download them if you trust the sender of the message.");
+ N_("This message part references content on one or more external servers. "
+ "To protect your privacy, Balsa has not downloaded it. You may choose "
+ "to download it if you trust the sender of the message.");
info_bar_widget =
- gtk_info_bar_new_with_buttons(_("_Download external contents"),
+ gtk_info_bar_new_with_buttons(_("_Download external content"),
GTK_RESPONSE_OK,
_("_Close"), GTK_RESPONSE_CLOSE,
NULL);
@@ -701,8 +701,8 @@ lbh_web_view_new(LibBalsaWebKitInfo *info,
webkit_settings_set_enable_java(settings, FALSE);
webkit_settings_set_enable_hyperlink_auditing(settings, TRUE);
webkit_settings_set_auto_load_images(settings,
- auto_load_images || (g_atomic_int_get(&html_filter_found) != 0));
- lbh_load_external_resources(view, auto_load_images);
+ auto_load_ext_content || (g_atomic_int_get(&html_filter_found) != 0));
+ lbh_load_external_resources(view, auto_load_ext_content);
g_signal_connect(view, "web-process-terminated", G_CALLBACK(lbh_web_process_terminated_cb), info);
g_signal_connect(view, "decide-policy", G_CALLBACK(lbh_decide_policy_cb), info);
diff --git a/src/balsa-mime-widget-text.c b/src/balsa-mime-widget-text.c
index 2e5a6b5b7..ab302ea53 100644
--- a/src/balsa-mime-widget-text.c
+++ b/src/balsa-mime-widget-text.c
@@ -1240,6 +1240,13 @@ bmwt_html_print_activated(GSimpleAction *action,
libbalsa_html_print(html);
}
+bmwt_html_load_external_content_changed(GtkCheckMenuItem *checkmenuitem,
+ gpointer user_data)
+{
+ libbalsa_html_prefer_set_load_content(INTERNET_ADDRESS_LIST(user_data),
+ gtk_check_menu_item_get_active(checkmenuitem));
+}
+
static void
bmwt_html_populate_popup_menu(BalsaMessage * bm,
GtkWidget * html,
@@ -1329,10 +1336,10 @@ bmwt_html_populate_popup_menu(BalsaMessage * bm,
g_variant_new_boolean(libbalsa_html_get_prefer_html(from)));
g_simple_action_set_enabled(G_SIMPLE_ACTION(prefer_html_action), from != NULL);
- g_menu_append(section, _("Load images for this sender"), "text-view-popup.load-images");
- g_simple_action_set_state(G_SIMPLE_ACTION(load_images_action),
- g_variant_new_boolean(libbalsa_html_get_load_images(from)));
- g_simple_action_set_enabled(G_SIMPLE_ACTION(load_images_action), from != NULL);
+ g_menu_append(section, _("Load external content for this sender"), "text-view-popup.load-ext-content");
+ g_simple_action_set_state(G_SIMPLE_ACTION(load_ext_content_action),
+ g_variant_new_boolean(libbalsa_html_get_load_ext_content(from)));
+ g_simple_action_set_enabled(G_SIMPLE_ACTION(load_ext_content_action), from != NULL);
g_menu_append_section(menu, NULL, G_MENU_MODEL(section));
g_object_unref(section);
@@ -1408,7 +1415,7 @@ bm_widget_new_html(BalsaMessage * bm, LibBalsaMessageBody * mime_body)
libbalsa_html_new(mime_body,
(LibBalsaHtmlCallback) bm_widget_on_url,
(LibBalsaHtmlCallback) handle_url,
- libbalsa_html_get_load_images(from));
+ libbalsa_html_get_load_content(from));
gtk_box_append(GTK_BOX(mwt), widget);
view_widget = libbalsa_html_get_view_widget(widget);
diff --git a/src/print-gtk.c b/src/print-gtk.c
index ad77e1d62..e2def0c00 100644
--- a/src/print-gtk.c
+++ b/src/print-gtk.c
@@ -710,9 +710,9 @@ message_prefs_apply(GtkPrintOperation * operation, GtkWidget * widget,
}
#ifdef HAVE_HTML_WIDGET
print_prefs->setup->print_alt_html =
- !gtk_check_button_get_active(GTK_CHECK_BUTTON(print_prefs->html_print));
- print_prefs->setup->html_load_images =
- gtk_check_button_get_active(GTK_CHECK_BUTTON(print_prefs->html_load_imgs));
+ !gtk_toggle_button_get_active(GTK_CHECK_BUTTON(print_prefs->html_print));
+ print_prefs->setup->html_load_ext_content =
+ gtk_toggle_button_get_active(GTK_CHECK_BUTTON(print_prefs->html_load_ext_content));
#endif
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]