[balsa] Find in message: Make it work again
- From: Peter Bloomfield <peterb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa] Find in message: Make it work again
- Date: Sat, 6 Jun 2020 19:04:26 +0000 (UTC)
commit 52781e198e661e05f7a46d0b8a967f13dff1a47f
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Sat Jun 6 15:03:32 2020 -0400
Find in message: Make it work again
* src/balsa-mime-widget-text.c
(balsa_mime_widget_text_get_text_widget): new getter;
* src/balsa-mime-widget-text.h: ditto;
* src/balsa-message.c (bm_find_entry_changed_cb), (bm_find_again),
(bm_find_pass_to_entry), (balsa_message_find_in_message): use it
to get the real text widget (GtkTextView, GtkSourceView).
ChangeLog | 11 +++++++++++
src/balsa-message.c | 28 +++++++++++++++++++++-------
src/balsa-mime-widget-text.c | 8 ++++++++
src/balsa-mime-widget-text.h | 1 +
4 files changed, 41 insertions(+), 7 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index bed56837f..d03489a10 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2020-06-06 Peter Bloomfield <pbloomfield bellsouth net>
+
+ Find in message: Make it work again
+
+ * src/balsa-mime-widget-text.c
+ (balsa_mime_widget_text_get_text_widget): new getter;
+ * src/balsa-mime-widget-text.h: ditto;
+ * src/balsa-message.c (bm_find_entry_changed_cb), (bm_find_again),
+ (bm_find_pass_to_entry), (balsa_message_find_in_message): use it
+ to get the real text widget (GtkTextView, GtkSourceView).
+
2020-06-06 Peter Bloomfield <pbloomfield bellsouth net>
mblist: Stop using direct access to GdkEvent structs
diff --git a/src/balsa-message.c b/src/balsa-message.c
index 933391e98..2bc9fcb2b 100644
--- a/src/balsa-message.c
+++ b/src/balsa-message.c
@@ -38,6 +38,7 @@
#include "balsa-mime-widget-callbacks.h"
#include "balsa-mime-widget-message.h"
#include "balsa-mime-widget-image.h"
+#include "balsa-mime-widget-text.h"
#include "balsa-mime-widget-crypto.h"
#include "libbalsa-gpgme.h"
#include "autocrypt.h"
@@ -417,7 +418,8 @@ bm_find_entry_changed_cb(GtkEditable * editable, gpointer data)
{
const gchar *text = gtk_entry_get_text(GTK_ENTRY(editable));
BalsaMessage *balsa_message = data;
- GtkWidget *widget = GTK_WIDGET(balsa_message->current_part->mime_widget);
+ BalsaMimeWidget *mime_widget = balsa_message->current_part->mime_widget;
+ GtkWidget *widget = balsa_mime_widget_text_get_text_widget(BALSA_MIME_WIDGET_TEXT(mime_widget));
gboolean found = FALSE;
if (GTK_IS_TEXT_VIEW(widget)) {
@@ -477,7 +479,8 @@ static void
bm_find_again(BalsaMessage * balsa_message, gboolean find_forward)
{
const gchar *text = gtk_entry_get_text(GTK_ENTRY(balsa_message->find_entry));
- GtkWidget *widget = GTK_WIDGET(balsa_message->current_part->mime_widget);
+ BalsaMimeWidget *mime_widget = balsa_message->current_part->mime_widget;
+ GtkWidget *widget = balsa_mime_widget_text_get_text_widget(BALSA_MIME_WIDGET_TEXT(mime_widget));
gboolean found;
balsa_message->find_forward = find_forward;
@@ -597,19 +600,25 @@ bm_find_bar_new(BalsaMessage * balsa_message)
static void bm_disable_find_entry(BalsaMessage * balsa_message);
static gboolean
-bm_find_pass_to_entry(BalsaMessage * balsa_message, GdkEventKey * event)
+bm_find_pass_to_entry(BalsaMessage * balsa_message, GdkEvent * event)
{
+ guint keyval;
+ GdkModifierType state;
gboolean res = TRUE;
- switch (event->keyval) {
+ if (!gdk_event_get_keyval(event, &keyval))
+ return FALSE;
+
+ switch (keyval) {
case GDK_KEY_Escape:
case GDK_KEY_Return:
case GDK_KEY_KP_Enter:
bm_disable_find_entry(balsa_message);
return res;
case GDK_KEY_g:
- if ((event->state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK)) ==
- GDK_CONTROL_MASK && gtk_widget_get_sensitive(balsa_message->find_next)) {
+ if (gdk_event_get_state(event, &state) &&
+ (state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK)) == GDK_CONTROL_MASK &&
+ gtk_widget_get_sensitive(balsa_message->find_next)) {
bm_find_again(balsa_message, balsa_message->find_forward);
return res;
}
@@ -3260,13 +3269,18 @@ balsa_message_recheck_crypto(BalsaMessage *balsa_message)
void
balsa_message_find_in_message(BalsaMessage * balsa_message)
{
+ BalsaMimeWidget *mime_widget;
GtkWidget *w;
if (balsa_message->current_part == NULL ||
balsa_message->current_part->mime_widget == NULL)
return;
- w = GTK_WIDGET(balsa_message->current_part->mime_widget);
+ mime_widget = balsa_message->current_part->mime_widget;
+ if (!BALSA_IS_MIME_WIDGET_TEXT(mime_widget))
+ return;
+
+ w = balsa_mime_widget_text_get_text_widget((BalsaMimeWidgetText *) mime_widget);
if (GTK_IS_TEXT_VIEW(w)
#ifdef HAVE_HTML_WIDGET
|| libbalsa_html_can_search(w)
diff --git a/src/balsa-mime-widget-text.c b/src/balsa-mime-widget-text.c
index 19a0be73f..a6a0f51e6 100644
--- a/src/balsa-mime-widget-text.c
+++ b/src/balsa-mime-widget-text.c
@@ -1498,3 +1498,11 @@ fill_text_buf_cited(BalsaMimeWidgetText *mwt,
if (rex != NULL)
g_regex_unref(rex);
}
+
+GtkWidget *
+balsa_mime_widget_text_get_text_widget(BalsaMimeWidgetText *mime_widget_text)
+{
+ g_return_val_if_fail(BALSA_IS_MIME_WIDGET_TEXT(mime_widget_text), NULL);
+
+ return mime_widget_text->text_widget;
+}
diff --git a/src/balsa-mime-widget-text.h b/src/balsa-mime-widget-text.h
index da89dfe59..441262fed 100644
--- a/src/balsa-mime-widget-text.h
+++ b/src/balsa-mime-widget-text.h
@@ -47,6 +47,7 @@ BalsaMimeWidget *balsa_mime_widget_new_text(BalsaMessage *bm,
const gchar *content_type,
gpointer data);
+GtkWidget *balsa_mime_widget_text_get_text_widget(BalsaMimeWidgetText * mime_widget_text);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]