[balsa/gtk4] Various: Build with HTML enabled



commit 595af270e67f250c3ebefe5ea83ec336eae74a58
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Sat Dec 18 18:36:52 2021 -0500

    Various: Build with HTML enabled

 libbalsa/html-pref-db.c      | 28 ++++++++++++++++++----------
 libbalsa/html.c              |  2 +-
 libbalsa/meson.build         | 14 ++++++++------
 src/balsa-mime-widget-text.c | 28 ++++++++++------------------
 src/print-gtk.c              | 10 ++++++----
 5 files changed, 43 insertions(+), 39 deletions(-)
---
diff --git a/libbalsa/html-pref-db.c b/libbalsa/html-pref-db.c
index a06523c6e..735d2086c 100644
--- a/libbalsa/html-pref-db.c
+++ b/libbalsa/html-pref-db.c
@@ -162,14 +162,20 @@ libbalsa_html_pref_dialog_run(GtkWindow *parent)
        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_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(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);
+       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_policy(GTK_SCROLLED_WINDOW(scrolled_window),
+                                       GTK_POLICY_AUTOMATIC,
+                                       GTK_POLICY_AUTOMATIC);
+       gtk_box_append(GTK_BOX(vbox), scrolled_window);
 
        model = gtk_list_store_new(PREFS_DB_VIEW_COLUMNS,
                G_TYPE_STRING,                  /* address */
@@ -178,16 +184,20 @@ libbalsa_html_pref_dialog_run(GtkWindow *parent)
 
        tree_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model));
 
-       gesture = gtk_gesture_multi_press_new(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);
 
-       gtk_container_add(GTK_CONTAINER(scrolled_window), tree_view);
+        add_actions(tree_view, action_namespace);
+
        selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_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]);
@@ -218,7 +228,6 @@ libbalsa_html_pref_dialog_run(GtkWindow *parent)
        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));
@@ -227,7 +236,6 @@ libbalsa_html_pref_dialog_run(GtkWindow *parent)
                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);
diff --git a/libbalsa/html.c b/libbalsa/html.c
index 15e2396bb..bcaa11ee4 100644
--- a/libbalsa/html.c
+++ b/libbalsa/html.c
@@ -661,7 +661,7 @@ lbh_get_web_view_context(void)
                view = WEBKIT_WEB_VIEW(webkit_web_view_new_with_context(tmp));
                webkit_web_view_load_uri(view, "about:blank");
                while (webkit_web_view_is_loading(view)) {
-                       gtk_main_iteration_do(FALSE);
+                       g_main_context_iteration(NULL, FALSE);
                        g_usleep(100);
                }
                g_object_ref_sink(view);
diff --git a/libbalsa/meson.build b/libbalsa/meson.build
index 7bd721ba1..97926c9c7 100644
--- a/libbalsa/meson.build
+++ b/libbalsa/meson.build
@@ -147,11 +147,13 @@ libbalsa_a = static_library('balsa', libbalsa_a_sources,
                                                    libimap_include],
                             install             : false)
 
-libhtmlfilter_la = shared_library('htmlfilter',
-                                  'html-filter.c',
-                                  dependencies        : balsa_deps,
-                                  include_directories : [top_include],
-                                  install             : true,
-                                  install_dir         : balsa_web_extensions)
+if html_widget == 'webkit2'
+  libhtmlfilter_la = shared_library('htmlfilter',
+                                    'html-filter.c',
+                                    dependencies        : balsa_deps,
+                                    include_directories : [top_include],
+                                    install             : true,
+                                    install_dir         : balsa_web_extensions)
+endif
 
 subdir('imap')
diff --git a/src/balsa-mime-widget-text.c b/src/balsa-mime-widget-text.c
index ab302ea53..4f3d88ccb 100644
--- a/src/balsa-mime-widget-text.c
+++ b/src/balsa-mime-widget-text.c
@@ -1022,7 +1022,6 @@ draw_cite_bar_real(gpointer data, gpointer user_data)
     BalsaMimeWidgetText *mwt = user_data;
     GtkTextView * view;
     GtkTextBuffer * buffer;
-    gint dimension;
     gint buffer_y;
     gint y_pos;
     gint height;
@@ -1205,16 +1204,16 @@ prefer_html_change_state(GSimpleAction *action,
 }
 
 static void
-load_images_change_state(GSimpleAction *action,
-                         GVariant      *state,
-                         gpointer       user_data)
+load_content_change_state(GSimpleAction *action,
+                          GVariant      *state,
+                          gpointer       user_data)
 {
     GtkWidget *html = user_data;
     BalsaMessage *bm = g_object_get_data(G_OBJECT(html), "bm");
     InternetAddressList *from;
 
     from = libbalsa_message_get_headers(balsa_message_get_message(bm))->from;
-    libbalsa_html_prefer_set_load_images(from, g_variant_get_boolean(state));
+    libbalsa_html_prefer_set_load_content(from, g_variant_get_boolean(state));
 
     g_simple_action_set_state(action, state);
 }
@@ -1240,13 +1239,6 @@ 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,
@@ -1263,12 +1255,12 @@ bmwt_html_populate_popup_menu(BalsaMessage * bm,
         {"save", bmwt_html_save_activated},
         {"print", bmwt_html_print_activated},
         {"prefer-html", NULL, NULL, "false", prefer_html_change_state},
-        {"load-images", NULL, NULL, "false", load_images_change_state}
+        {"load-content", NULL, NULL, "false", load_content_change_state}
     };
     GActionMap *action_map;
     GAction *print_action;
     GAction *prefer_html_action;
-    GAction *load_images_action;
+    GAction *load_content_action;
     GMenu *section;
     GMenu *open_menu;
     InternetAddressList *from;
@@ -1286,7 +1278,7 @@ bmwt_html_populate_popup_menu(BalsaMessage * bm,
 
     print_action = g_action_map_lookup_action(action_map, "print");
     prefer_html_action = g_action_map_lookup_action(action_map, "prefer-html");
-    load_images_action = g_action_map_lookup_action(action_map, "load-images");
+    load_content_action = g_action_map_lookup_action(action_map, "load-content");
 
     g_object_unref(simple);
 
@@ -1337,9 +1329,9 @@ bmwt_html_populate_popup_menu(BalsaMessage * bm,
     g_simple_action_set_enabled(G_SIMPLE_ACTION(prefer_html_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_simple_action_set_state(G_SIMPLE_ACTION(load_content_action),
+                              g_variant_new_boolean(libbalsa_html_get_load_content(from)));
+    g_simple_action_set_enabled(G_SIMPLE_ACTION(load_content_action), from != NULL);
 
     g_menu_append_section(menu, NULL, G_MENU_MODEL(section));
     g_object_unref(section);
diff --git a/src/print-gtk.c b/src/print-gtk.c
index e2def0c00..d280dab17 100644
--- a/src/print-gtk.c
+++ b/src/print-gtk.c
@@ -614,12 +614,14 @@ message_prefs_widget(GtkPrintOperation * operation,
     grid = create_options_group(_("Highlighting"), page, 1, 1, 1);
 
     print_prefs->html_print = gtk_check_button_new_with_mnemonic(_("Prefer text/plain over HTML"));
-    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(print_prefs->html_print), print_prefs->prefer_text);
+    gtk_check_button_set_active(GTK_CHECK_BUTTON(print_prefs->html_print),
+                                print_prefs->prefer_text);
     gtk_grid_attach(GTK_GRID(grid), print_prefs->html_print, 1, 0, 1, 1);
 
     print_prefs->html_load_ext_content =
        gtk_check_button_new_with_mnemonic(_("Download content from remote servers (may be dangerous)"));
-    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(print_prefs->html_load_ext_content), 
print_prefs->load_ext_content);
+    gtk_check_button_set_active(GTK_CHECK_BUTTON(print_prefs->html_load_ext_content),
+                                print_prefs->load_ext_content);
     gtk_grid_attach(GTK_GRID(grid), print_prefs->html_load_ext_content, 1, 1, 1, 1);
 
     /* phantom alignment */
@@ -710,9 +712,9 @@ message_prefs_apply(GtkPrintOperation * operation, GtkWidget * widget,
     }
 #ifdef HAVE_HTML_WIDGET
     print_prefs->setup->print_alt_html =
-       !gtk_toggle_button_get_active(GTK_CHECK_BUTTON(print_prefs->html_print));
+       !gtk_check_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));
+       gtk_check_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]