...
 
Commits (7)
......@@ -52,7 +52,7 @@ AC_SUBST(GSPELL_API_VERSION)
# Dependencies
enchant_req=2.1.3
glib_req=2.44
gtk_req=3.20
gtk_req=3.89
AC_CONFIG_SRCDIR([gspell/gspell-checker.c])
AC_CONFIG_HEADER([config.h])
......@@ -90,7 +90,7 @@ AX_COMPILER_FLAGS([WARN_CFLAGS], [WARN_LDFLAGS], [yes])
# Dynamic linking dependencies
AX_REQUIRE_DEFINED([AX_PKG_CHECK_MODULES])
AX_PKG_CHECK_MODULES([DEP],
[glib-2.0 >= $glib_req gtk+-3.0 >= $gtk_req enchant-2 >= $enchant_req],
[glib-2.0 >= $glib_req gtk+-4.0 >= $gtk_req enchant-2 >= $enchant_req],
[])
# iso-codes
......
......@@ -102,7 +102,6 @@ init_view (GspellAppContent *content)
GspellTextView *gspell_view;
GtkStyleContext *style_context;
GtkCssProvider *css_provider;
GError *error = NULL;
g_assert (content->view == NULL);
......@@ -125,20 +124,11 @@ init_view (GspellAppContent *content)
css_provider = gtk_css_provider_new ();
gtk_css_provider_load_from_data (css_provider,
"textview { font-size: 120%; }\n",
-1,
&error);
-1);
if (error == NULL)
{
gtk_style_context_add_provider (style_context,
GTK_STYLE_PROVIDER (css_provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
}
else
{
g_warning ("CSS error: %s", error->message);
g_clear_error (&error);
}
gtk_style_context_add_provider (style_context,
GTK_STYLE_PROVIDER (css_provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
g_object_unref (css_provider);
}
......@@ -169,7 +159,7 @@ gspell_app_content_init (GspellAppContent *content)
gtk_container_add (GTK_CONTAINER (scrolled_window), GTK_WIDGET (content->view));
gtk_container_add (GTK_CONTAINER (content), scrolled_window);
gtk_widget_show_all (GTK_WIDGET (content));
gtk_widget_show (GTK_WIDGET (content));
}
static GspellAppContent *
......
......@@ -151,7 +151,7 @@ _gspell_context_menu_get_language_menu_item (const GspellLanguage *cu
menu_item = GTK_MENU_ITEM (gtk_menu_item_new_with_mnemonic (_("_Language")));
gtk_menu_item_set_submenu (menu_item, lang_menu);
gtk_widget_show_all (GTK_WIDGET (menu_item));
gtk_widget_show (GTK_WIDGET (menu_item));
return menu_item;
}
......@@ -339,7 +339,7 @@ _gspell_context_menu_get_suggestions_menu_item (GspellChecker
menu_item = GTK_MENU_ITEM (gtk_menu_item_new_with_mnemonic (_("_Spelling Suggestions…")));
gtk_menu_item_set_submenu (menu_item, suggestion_menu);
gtk_widget_show_all (GTK_WIDGET (menu_item));
gtk_widget_show (GTK_WIDGET (menu_item));
return menu_item;
}
......
......@@ -235,12 +235,15 @@ _gspell_entry_utils_get_char_position_at_event (GtkEntry *entry,
gint layout_index; /* in bytes */
gint text_index; /* in bytes */
const gchar *buffer_text;
double event_x, event_y;
g_object_get (entry,
"scroll-offset", &scroll_offset,
NULL);
x = event->x + scroll_offset;
gdk_event_get_coords ((GdkEvent *)event, &event_x, &event_y);
x = event_x + scroll_offset;
layout_index = get_layout_index (entry, x);
text_index = gtk_entry_layout_index_to_text_index (entry, layout_index);
......
......@@ -597,21 +597,30 @@ popup_menu_cb (GtkEntry *gtk_entry,
return FALSE;
}
static gboolean
button_press_event_cb (GtkEntry *gtk_entry,
GdkEventButton *event,
GspellEntry *gspell_entry)
static void
multipress_gesture_pressed_cb (GtkGestureMultiPress *gesture,
double x,
double y,
GspellEntry *gspell_entry)
{
if (event->button == GDK_BUTTON_SECONDARY)
GtkEntry *gtk_entry;
guint button;
GdkEventSequence *sequence;
const GdkEvent *event;
gtk_entry = GTK_ENTRY (gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (gesture)));
sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
event = gtk_gesture_get_last_event (GTK_GESTURE (gesture), sequence);
button = gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (gesture));
if (button == GDK_BUTTON_SECONDARY)
{
gspell_entry->popup_char_position =
_gspell_entry_utils_get_char_position_at_event (gtk_entry, event);
_gspell_entry_utils_get_char_position_at_event (gtk_entry, (GdkEventButton *)event);
}
_gspell_current_word_policy_cursor_moved (gspell_entry->current_word_policy);
recheck_all (gspell_entry);
return GDK_EVENT_PROPAGATE;
}
static void
......@@ -866,6 +875,8 @@ static void
set_entry (GspellEntry *gspell_entry,
GtkEntry *gtk_entry)
{
GtkGesture *multipress_gesture;
g_return_if_fail (GTK_IS_ENTRY (gtk_entry));
g_assert (gspell_entry->entry == NULL);
......@@ -893,9 +904,12 @@ set_entry (GspellEntry *gspell_entry,
G_CALLBACK (popup_menu_cb),
gspell_entry);
g_signal_connect (gtk_entry,
"button-press-event",
G_CALLBACK (button_press_event_cb),
multipress_gesture = gtk_gesture_multi_press_new (GTK_WIDGET (gtk_entry));
/* TODO: We leak the gesture for now but the Gesture API is supposed to change soon so that
* may not be a long-lasting problem. */
g_signal_connect (multipress_gesture,
"pressed",
G_CALLBACK (multipress_gesture_pressed_cb),
gspell_entry);
/* connect_after, so when menu items are prepended, they have more
......
......@@ -997,29 +997,34 @@ language_notify_cb (GspellChecker *checker,
* Here, we do NOT move the cursor to the location of the clicked-upon word
* since that prevents the use of edit functions on the context menu.
*/
static gboolean
button_press_event_cb (GtkTextView *view,
GdkEventButton *event,
GspellInlineCheckerTextBuffer *spell)
static void
multipress_gesture_pressed_cb (GtkGestureMultiPress *gesture,
double x,
double y,
GspellInlineCheckerTextBuffer *spell)
{
if (event->button == GDK_BUTTON_SECONDARY)
GtkTextView *view;
guint button;
view = GTK_TEXT_VIEW (gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (gesture)));
button = gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (gesture));
if (button == GDK_BUTTON_SECONDARY)
{
GtkTextBuffer *buffer = gtk_text_view_get_buffer (view);
GtkTextIter iter;
gint x;
gint y;
int buffer_x;
int buffer_y;
gtk_text_view_window_to_buffer_coords (view,
GTK_TEXT_WINDOW_TEXT,
event->x, event->y,
&x, &y);
x, y,
&buffer_x, &buffer_y);
gtk_text_view_get_iter_at_location (view, &iter, x, y);
gtk_text_view_get_iter_at_location (view, &iter, buffer_x, buffer_y);
gtk_text_buffer_move_mark (buffer, spell->mark_click, &iter);
}
return GDK_EVENT_PROPAGATE;
}
/* Move the insert mark before popping up the menu, otherwise it
......@@ -1407,16 +1412,17 @@ void
_gspell_inline_checker_text_buffer_attach_view (GspellInlineCheckerTextBuffer *spell,
GtkTextView *view)
{
GtkGesture *multipress_gesture;
g_return_if_fail (GSPELL_IS_INLINE_CHECKER_TEXT_BUFFER (spell));
g_return_if_fail (GTK_IS_TEXT_VIEW (view));
g_return_if_fail (gtk_text_view_get_buffer (view) == spell->buffer);
g_return_if_fail (g_slist_find (spell->views, view) == NULL);
g_signal_connect_object (view,
"button-press-event",
G_CALLBACK (button_press_event_cb),
spell,
0);
multipress_gesture = gtk_gesture_multi_press_new (GTK_WIDGET (view));
/* TODO: We leak the gesture for now but the Gesture API is supposed to change soon so that
* may not be a long-lasting problem. */
g_signal_connect (multipress_gesture, "pressed", G_CALLBACK (multipress_gesture_pressed_cb), spell);
g_signal_connect_object (view,
"popup-menu",
......
......@@ -102,8 +102,6 @@
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
......@@ -244,8 +242,6 @@
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
......
......@@ -24,8 +24,6 @@
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
......@@ -47,8 +45,6 @@
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
......
......@@ -120,7 +120,7 @@ create_sidebar (TestSpell *spell)
G_BINDING_SYNC_CREATE |
G_BINDING_INVERT_BOOLEAN);
gtk_widget_show_all (vgrid);
gtk_widget_show (vgrid);
return vgrid;
}
......@@ -144,7 +144,7 @@ test_spell_init (TestSpell *spell)
gtk_container_add (GTK_CONTAINER (spell),
GTK_WIDGET (spell->entry));
gtk_widget_show_all (GTK_WIDGET (spell));
gtk_widget_show (GTK_WIDGET (spell));
}
static TestSpell *
......@@ -160,7 +160,7 @@ main (gint argc,
GtkWidget *window;
TestSpell *spell;
gtk_init (&argc, &argv);
gtk_init ();
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
......
......@@ -28,7 +28,7 @@ main (gint argc,
GtkTextView *gtk_view;
GspellTextView *gspell_view;
gtk_init (&argc, &argv);
gtk_init ();
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size (GTK_WINDOW (window), 600, 400);
......@@ -46,7 +46,7 @@ main (gint argc,
gtk_container_add (GTK_CONTAINER (scrolled_window), GTK_WIDGET (gtk_view));
gtk_container_add (GTK_CONTAINER (window), scrolled_window);
gtk_widget_show_all (window);
gtk_widget_show (window);
gtk_main ();
......
......@@ -196,7 +196,7 @@ test_spell_init (TestSpell *spell)
gtk_container_add (GTK_CONTAINER (spell),
scrolled_window);
gtk_widget_show_all (GTK_WIDGET (spell));
gtk_widget_show (GTK_WIDGET (spell));
}
static TestSpell *
......@@ -242,7 +242,7 @@ main (gint argc,
GtkWidget *window;
TestSpell *spell;
gtk_init (&argc, &argv);
gtk_init ();
print_available_language_codes ();
......