[balsa/gtk4: 291/294] Various: Build with HTML enabled
- From: Peter Bloomfield <peterb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa/gtk4: 291/294] Various: Build with HTML enabled
- Date: Sun, 10 Oct 2021 00:03:57 +0000 (UTC)
commit 65c19db9d14ab023cf2eaa1c71ec6458eaddf78b
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Sun Jun 20 18:35:01 2021 -0400
Various: Build with HTML enabled
It will not work with current webkit, which is not ported to Gtk4, but
we can at least make sure it builds.
modified: libbalsa/html-pref-db.c
modified: libbalsa/html.c
modified: src/balsa-mime-widget-text.c
modified: src/main.c
libbalsa/html-pref-db.c | 375 ++++++++++++++++++++++++-------------------
libbalsa/html.c | 19 +--
src/balsa-mime-widget-text.c | 69 ++++----
src/main.c | 11 +-
4 files changed, 258 insertions(+), 216 deletions(-)
---
diff --git a/libbalsa/html-pref-db.c b/libbalsa/html-pref-db.c
index 70d8fdda1..deff74590 100644
--- a/libbalsa/html-pref-db.c
+++ b/libbalsa/html-pref-db.c
@@ -71,15 +71,16 @@ static gboolean pref_db_set_name(const gchar *sender,
static gboolean popup_menu_cb(GtkWidget *widget,
gpointer user_data);
-static void button_press_cb(GtkGestureMultiPress *multi_press_gesture,
- gint n_press,
- gdouble x,
- gdouble y,
- gpointer user_data);
-static void popup_menu_real(GtkWidget *widget,
- const GdkEvent *event);
-static void remove_item_cb(GtkMenuItem G_GNUC_UNUSED *menuitem,
- gpointer user_data);
+static void button_press_cb(GtkGestureClick *click_gesture,
+ int n_press,
+ double x,
+ double y,
+ gpointer user_data);
+static void popup_menu_real(GtkWidget *widget,
+ GdkEvent *event);
+static void delete_activated(GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data);
static void on_prefs_button_toggled(GtkCellRendererToggle *cell_renderer,
gchar *path,
gpointer user_data);
@@ -114,101 +115,143 @@ libbalsa_html_prefer_set_load_images(InternetAddressList *from, gboolean state)
pref_db_set_ial(from, 2, state);
}
+static void
+add_actions(GtkWidget *widget,
+ const char *namespace)
+{
+ GSimpleActionGroup *simple;
+ static const GActionEntry entries[] = {
+ {"delete", delete_activated},
+ };
+
+ simple = g_simple_action_group_new();
+ g_action_map_add_action_entries(G_ACTION_MAP(simple),
+ entries, G_N_ELEMENTS(entries),
+ widget);
+
+ gtk_widget_insert_action_group(widget,
+ namespace,
+ G_ACTION_GROUP(simple));
+ g_object_unref(simple);
+}
+
+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;
- GtkGesture *gesture;
- GtkTreeSelection *selection;
- GtkCellRenderer *renderer;
- GtkTreeViewColumn *column;
- int sqlite_res;
-
- 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_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 images */
-
- 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_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(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_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(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);
-
- (void) gtk_dialog_run(GTK_DIALOG(dialog));
- gtk_widget_destroy(dialog);
+ 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;
+
+ 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);
+
+ g_signal_connect(dialog, "response", G_CALLBACK(gtk_window_destroy), NULL);
+ gtk_widget_show(dialog);
}
@@ -401,82 +444,88 @@ popup_menu_cb(GtkWidget *widget, gpointer G_GNUC_UNUSED user_data)
/* callback: mouse click in html prefs database dialogue activated */
static void
-button_press_cb(GtkGestureMultiPress *multi_press_gesture, gint G_GNUC_UNUSED n_press, gdouble x,
- gdouble y, gpointer G_GNUC_UNUSED user_data)
+button_press_cb(GtkGestureClick *click_gesture,
+ int n_press G_GNUC_UNUSED,
+ double x,
+ double y,
+ gpointer user_data G_GNUC_UNUSED)
{
- GtkWidget *widget = gtk_event_controller_get_widget(GTK_EVENT_CONTROLLER(multi_press_gesture));
- GtkTreeView *tree_view = GTK_TREE_VIEW(widget);
- GtkGesture *gesture;
- GdkEventSequence *sequence;
- const GdkEvent *event;
-
- gesture = GTK_GESTURE(multi_press_gesture);
- sequence = gtk_gesture_single_get_current_sequence(GTK_GESTURE_SINGLE(multi_press_gesture));
- event = gtk_gesture_get_last_event(gesture, sequence);
- if (gdk_event_triggers_context_menu(event) && (gdk_event_get_window(event) ==
gtk_tree_view_get_bin_window(tree_view))) {
- gint bx;
- gint by;
- GtkTreePath *path;
-
- gtk_tree_view_convert_widget_to_bin_window_coords(tree_view, (gint) x, (gint) y, &bx, &by);
- if (gtk_tree_view_get_path_at_pos(tree_view, bx, by, &path, NULL, NULL, NULL)) {
- GtkTreeSelection *selection = gtk_tree_view_get_selection(tree_view);
- GtkTreeModel *model = gtk_tree_view_get_model(tree_view);
- GtkTreeIter iter;
-
- gtk_tree_selection_unselect_all(selection);
- gtk_tree_selection_select_path(selection, path);
- gtk_tree_view_set_cursor(GTK_TREE_VIEW(tree_view), path, NULL, FALSE);
- if (gtk_tree_model_get_iter(model, &iter, path)) {
- popup_menu_real(GTK_WIDGET(tree_view), event);
- }
- gtk_tree_path_free(path);
- }
- }
+ GtkWidget *widget = gtk_event_controller_get_widget(GTK_EVENT_CONTROLLER(click_gesture));
+ GtkTreeView *tree_view = GTK_TREE_VIEW(widget);
+ GtkGesture *gesture;
+ GdkEventSequence *sequence;
+ GdkEvent *event;
+
+ gesture = GTK_GESTURE(click_gesture);
+ sequence = gtk_gesture_single_get_current_sequence(GTK_GESTURE_SINGLE(gesture));
+ event = gtk_gesture_get_last_event(gesture, sequence);
+
+ if (gdk_event_triggers_context_menu(event)) {
+ int bx;
+ int by;
+ GtkTreePath *path;
+
+ gtk_tree_view_convert_widget_to_bin_window_coords(tree_view, (int) x, (int) y, &bx, &by);
+ if (gtk_tree_view_get_path_at_pos(tree_view, bx, by, &path, NULL, NULL, NULL)) {
+ GtkTreeSelection *selection = gtk_tree_view_get_selection(tree_view);
+ GtkTreeModel *model = gtk_tree_view_get_model(tree_view);
+ GtkTreeIter iter;
+
+ gtk_tree_selection_unselect_all(selection);
+ gtk_tree_selection_select_path(selection, path);
+ gtk_tree_view_set_cursor(GTK_TREE_VIEW(tree_view), path, NULL, FALSE);
+
+ if (gtk_tree_model_get_iter(model, &iter, path))
+ popup_menu_real(GTK_WIDGET(tree_view), event);
+
+ gtk_tree_path_free(path);
+ }
+ }
}
/* html prefs database dialogue context menu */
static void
-popup_menu_real(GtkWidget *widget, const GdkEvent *event)
+popup_menu_real(GtkWidget *widget,
+ GdkEvent *event)
{
- GtkWidget *popup_menu;
- GtkWidget* menu_item;
-
- popup_menu = gtk_menu_new();
- menu_item = gtk_menu_item_new_with_mnemonic(_("_Delete"));
- g_signal_connect(menu_item, "activate", G_CALLBACK(remove_item_cb), widget);
- gtk_menu_shell_append(GTK_MENU_SHELL(popup_menu), menu_item);
- gtk_widget_show_all(popup_menu);
- if (event != NULL) {
- gtk_menu_popup_at_pointer(GTK_MENU(popup_menu), event);
- } else {
- gtk_menu_popup_at_widget(GTK_MENU(popup_menu), widget, GDK_GRAVITY_CENTER,
GDK_GRAVITY_CENTER, NULL);
- }
+ GMenu *popup_menu;
+ GtkWidget *popup_widget;
+
+ popup_menu = g_menu_new();
+ g_menu_append(popup_menu, _("_Delete"), "delete");
+
+ popup_widget = libbalsa_popup_widget_new(widget, G_MENU_MODEL(popup_menu), action_namespace);
+ g_object_unref(popup_menu);
+
+ libbalsa_popup_widget_popup(popup_widget, event);
}
/* context menu callback: remove entry from database */
static void
-remove_item_cb(GtkMenuItem G_GNUC_UNUSED *menuitem, gpointer user_data)
+delete_activated(GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
- GtkTreeModel *model;
- GtkTreeSelection *selection;
- GtkTreeIter iter;
-
- selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(user_data));
- if (gtk_tree_selection_get_selected(selection, &model, &iter)) {
- gchar *addr;
-
- gtk_tree_model_get(model, &iter, PREFS_ADDRESS_COLUMN, &addr, -1);
- if ((sqlite3_bind_text(query[3], 1, addr, -1, SQLITE_STATIC) != SQLITE_OK) ||
- (sqlite3_step(query[3]) != SQLITE_DONE)) {
- libbalsa_information(LIBBALSA_INFORMATION_ERROR, _("Cannot delete database entry:
%s"), sqlite3_errmsg(pref_db));
- }
- gtk_list_store_remove(GTK_LIST_STORE(model), &iter);
- sqlite3_reset(query[3]);
- g_free(addr);
- }
+ GtkTreeModel *model;
+ GtkTreeSelection *selection;
+ GtkTreeIter iter;
+
+ selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(user_data));
+ if (gtk_tree_selection_get_selected(selection, &model, &iter)) {
+ gchar *addr;
+
+ gtk_tree_model_get(model, &iter, PREFS_ADDRESS_COLUMN, &addr, -1);
+ if ((sqlite3_bind_text(query[3], 1, addr, -1, SQLITE_STATIC) != SQLITE_OK) ||
+ (sqlite3_step(query[3]) != SQLITE_DONE)) {
+ libbalsa_information(LIBBALSA_INFORMATION_ERROR, _("Cannot delete database entry: %s"),
+ sqlite3_errmsg(pref_db));
+ }
+ gtk_list_store_remove(GTK_LIST_STORE(model), &iter);
+ sqlite3_reset(query[3]);
+ g_free(addr);
+ }
}
diff --git a/libbalsa/html.c b/libbalsa/html.c
index 003757ab7..7b1c0bd70 100644
--- a/libbalsa/html.c
+++ b/libbalsa/html.c
@@ -147,20 +147,11 @@ html2text(gchar ** text, gsize len)
#endif
/* Allow the build: */
+typedef gpointer GtkAction;
typedef gpointer GdkEventKey;
typedef gpointer GtkContainer;
typedef gpointer GtkContainerClass;
-
-/* WebKitContextMenuItem uses GtkAction, which is deprecated.
- * We don't use it, but it breaks the git-tree build, so we just mangle
- * it: */
-#if defined(GTK_DISABLE_DEPRECATED)
-#define GtkAction GAction
-#include <webkit2/webkit2.h>
-#undef GtkAction
-#else /* defined(GTK_DISABLE_DEPRECATED) */
#include <webkit2/webkit2.h>
-#endif /* defined(GTK_DISABLE_DEPRECATED) */
typedef struct {
LibBalsaMessageBody *body;
@@ -644,7 +635,7 @@ lbh_web_view_new(LibBalsaWebKitInfo *info,
}
-#ifdef HTML_PRINT_BITMAP
+#if 0
static void
dump_snapshot(GObject *source_object,
GAsyncResult *res,
@@ -664,6 +655,7 @@ dump_snapshot(GObject *source_object,
}
g_atomic_int_inc(&info->screenshot_done);
}
+#endif /* 0 */
/** \brief Render a HMTL part into a Cairo surface
*
@@ -677,6 +669,7 @@ libbalsa_html_print_bitmap(LibBalsaMessageBody *body,
gdouble width,
gboolean load_external_images)
{
+#if 0
gint render_width;
gchar *text;
gboolean have_src_cid;
@@ -737,8 +730,10 @@ libbalsa_html_print_bitmap(LibBalsaMessageBody *body,
/* return the surface */
return html_surface;
+#else /* 0 */
+ return NULL;
+#endif /* 0 */
}
-#endif /* HTML_PRINT_BITMAP */
/* Create a new WebKitWebView widget:
diff --git a/src/balsa-mime-widget-text.c b/src/balsa-mime-widget-text.c
index d30146efa..ffac7969a 100644
--- a/src/balsa-mime-widget-text.c
+++ b/src/balsa-mime-widget-text.c
@@ -1179,8 +1179,7 @@ bmwt_html_open_with_activated(GSimpleAction *action,
open_with_activated(action, parameter, mime_body);
- if (GTK_IS_POPOVER(popup_widget))
- gtk_popover_popdown((GtkPopover *) popup_widget);
+ gtk_popover_popdown(GTK_POPOVER(popup_widget));
}
static void
@@ -1193,7 +1192,7 @@ prefer_html_change_state(GSimpleAction *action,
InternetAddressList *from;
from = libbalsa_message_get_headers(balsa_message_get_message(bm))->from;
- libbalsa_html_prefer_set_prefer_html(from, g_variant_get_boolean(state);
+ libbalsa_html_prefer_set_prefer_html(from, g_variant_get_boolean(state));
g_simple_action_set_state(action, state);
}
@@ -1208,15 +1207,15 @@ load_images_change_state(GSimpleAction *action,
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_images(from, g_variant_get_boolean(state));
g_simple_action_set_state(action, state);
}
static void
-save_activated(GSimpleAction *action,
- GVariant *parameter,
- gpointer user_data)
+bmwt_html_save_activated(GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
GtkWidget *html = user_data;
gpointer mime_body = g_object_get_data(G_OBJECT(html), "mime-body");
@@ -1242,13 +1241,13 @@ bmwt_html_populate_popup_menu(BalsaMessage * bm,
{
GSimpleActionGroup *simple;
static const GActionEntry text_view_popup_entries[] = {
- {"zoom-in", zoom_in_activated},
- {"zoom-out", zoom_out_activated},
- {"zoom-reset", zoom_reset_activated},
- {"select-all", select_all_activated},
- {"open-with", NULL, "s", "''", html_open_with_change_state},
- {"save", save_activated},
- {"print", print_activated},
+ {"zoom-in", bmwt_html_zoom_in_activated},
+ {"zoom-out", bmwt_html_zoom_out_activated},
+ {"zoom-reset", bmwt_html_zoom_reset_activated},
+ {"select-all", bmwt_html_select_all_activated},
+ {"open-with", bmwt_html_open_with_activated, "s"},
+ {"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}
};
@@ -1323,7 +1322,7 @@ 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.prefer-html");
+ 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);
@@ -1339,19 +1338,19 @@ bmwt_html_popup_context_menu(GtkWidget *html,
BalsaMessage *bm)
{
GtkWidget *popup_widget;
- const GdkEvent *event;
- GdkEvent *current_event = NULL;
+ static const char namespace[] = "text-view-popup";
+ GdkEvent *event;
popup_widget = g_object_get_data(G_OBJECT(html), "popup-widget");
if (popup_widget == NULL) {
GMenu *menu;
menu = g_menu_new();
- bmwt_html_populate_popup_menu(bm, html, menu, "text-view-popup");
+ bmwt_html_populate_popup_menu(bm, html, menu, namespace);
popup_widget = libbalsa_popup_widget_new(libbalsa_html_get_view_widget(html),
- G_MENU_MODEL(menu),
- "text-view-popup");
+ G_MENU_MODEL(menu),
+ namespace);
g_object_unref(menu);
g_object_set_data(G_OBJECT(html), "popup-widget", popup_widget);
@@ -1361,29 +1360,24 @@ bmwt_html_popup_context_menu(GtkWidget *html,
* GdkEvent is no longer current; instead it is preserved and passed
* to us: */
event = g_object_get_data(G_OBJECT(html), LIBBALSA_HTML_POPUP_EVENT);
- if (event == NULL)
- event = current_event = gtk_get_current_event();
libbalsa_popup_widget_popup(popup_widget, event);
- if (current_event != NULL)
- gdk_event_free(current_event);
-
return TRUE;
}
static void
-bmwt_html_button_press_cb(GtkGestureMultiPress *multi_press,
- gint n_press,
- gdouble x,
- gdouble y,
- gpointer user_data)
+bmwt_html_button_press_cb(GtkGestureClick *click_gesture,
+ int n_press,
+ double x,
+ double y,
+ gpointer user_data)
{
BalsaMessage *bm = user_data;
GtkGesture *gesture;
- const GdkEvent *event;
+ GdkEvent *event;
- gesture = GTK_GESTURE(multi_press);
+ gesture = GTK_GESTURE(click_gesture);
event = gtk_gesture_get_last_event(gesture, gtk_gesture_get_last_updated_sequence(gesture));
if (gdk_event_triggers_context_menu(event)) {
@@ -1398,6 +1392,7 @@ bm_widget_new_html(BalsaMessage * bm, LibBalsaMessageBody * mime_body)
BalsaMimeWidgetText *mwt = g_object_new(BALSA_TYPE_MIME_WIDGET_TEXT, NULL);
InternetAddressList *from;
GtkWidget *widget;
+ GtkWidget *view_widget;
GtkEventController *key_controller;
GtkGesture *gesture;
@@ -1405,16 +1400,20 @@ bm_widget_new_html(BalsaMessage * bm, LibBalsaMessageBody * mime_body)
mwt->text_widget = widget =
libbalsa_html_new(mime_body,
(LibBalsaHtmlCallback) bm_widget_on_url,
- (LibBalsaHtmlCallback) handle_url);
+ (LibBalsaHtmlCallback) handle_url,
+ libbalsa_html_get_load_images(from));
gtk_box_append(GTK_BOX(mwt), widget);
+ view_widget = libbalsa_html_get_view_widget(widget);
g_object_set_data(G_OBJECT(widget), "mime-body", mime_body);
- key_controller = gtk_event_controller_key_new(libbalsa_html_get_view_widget(widget));
+ key_controller = gtk_event_controller_key_new();
+ gtk_widget_add_controller(view_widget, GTK_EVENT_CONTROLLER(key_controller));
g_signal_connect(key_controller, "key-pressed",
G_CALLBACK(balsa_mime_widget_key_pressed), bm);
- gesture = gtk_gesture_multi_press_new(libbalsa_html_get_view_widget(widget));
+ gesture = gtk_gesture_click_new();
+ gtk_widget_add_controller(view_widget, GTK_EVENT_CONTROLLER(gesture));
gtk_gesture_single_set_button(GTK_GESTURE_SINGLE(gesture), 0);
g_signal_connect(gesture, "pressed",
G_CALLBACK(bmwt_html_button_press_cb), bm);
diff --git a/src/main.c b/src/main.c
index 1bfb883ea..ef96cad8e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -56,13 +56,12 @@
#ifdef HAVE_HTML_WIDGET
#include <gtk/gtk.h>
-#if defined(GTK_DISABLE_DEPRECATED)
-#define GtkAction GAction
-#include <webkit2/webkit2.h>
-#undef GtkAction
-#else /* defined(GTK_DISABLE_DEPRECATED) */
+
+typedef gpointer GtkAction;
+typedef gpointer GdkEventKey;
+typedef gpointer GtkContainer;
+typedef gpointer GtkContainerClass;
#include <webkit2/webkit2.h>
-#endif /* defined(GTK_DISABLE_DEPRECATED) */
#endif /* HAVE_HTML_WIDGET */
/* We need separate variable for storing command line requests to check the
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]