static void update_ui (GeditSpellPlugin *plugin) { GeditSpellPluginPrivate *priv; GeditView *view; GAction *check_spell_action; GAction *config_spell_action; GAction *auto_spell_action; gedit_debug (DEBUG_PLUGINS); priv = plugin->priv; view = gedit_window_get_active_view (priv->window); check_spell_action = g_action_map_lookup_action (G_ACTION_MAP (priv->window), "check-spell"); g_simple_action_set_enabled (G_SIMPLE_ACTION (check_spell_action), (view != NULL) && gtk_text_view_get_editable (GTK_TEXT_VIEW (view))); config_spell_action = g_action_map_lookup_action (G_ACTION_MAP (priv->window), "config-spell"); g_simple_action_set_enabled (G_SIMPLE_ACTION (config_spell_action), (view != NULL) && gtk_text_view_get_editable (GTK_TEXT_VIEW (view))); auto_spell_action = g_action_map_lookup_action (G_ACTION_MAP (priv->window), "auto-spell"); g_simple_action_set_enabled (G_SIMPLE_ACTION (auto_spell_action), (view != NULL) && gtk_text_view_get_editable (GTK_TEXT_VIEW (view))); if (view != NULL) { GeditDocument *doc; GeditTab *tab; GeditTabState state; gboolean autospell; doc = GEDIT_DOCUMENT (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view))); tab = gedit_window_get_active_tab (priv->window); state = gedit_tab_get_state (tab); autospell = (doc != NULL && gedit_automatic_spell_checker_get_from_document (doc) != NULL); /* If the document is loading we can't get the metadata so we endup with an useless speller */ if (state == GEDIT_TAB_STATE_NORMAL) { g_action_change_state (auto_spell_action, g_variant_new_boolean (autospell)); } g_simple_action_set_enabled (G_SIMPLE_ACTION (check_spell_action), gtk_text_buffer_get_char_count (GTK_TEXT_BUFFER (doc)) > 0); } }
static void update_ui_real (GeditWindow *window, WindowData *data) { GeditDocument *doc; GeditView *view; gboolean autospell; GtkAction *action; gedit_debug (DEBUG_PLUGINS); doc = gedit_window_get_active_document (window); view = gedit_window_get_active_view (window); autospell = (doc != NULL && gedit_automatic_spell_checker_get_from_document (doc) != NULL); if (doc != NULL) { GeditTab *tab; GeditTabState state; tab = gedit_window_get_active_tab (window); state = gedit_tab_get_state (tab); /* If the document is loading we can't get the metadata so we endup with an useless speller */ if (state == GEDIT_TAB_STATE_NORMAL) { action = gtk_action_group_get_action (data->action_group, "AutoSpell"); g_signal_handlers_block_by_func (action, auto_spell_cb, window); set_auto_spell (window, doc, autospell); gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), autospell); g_signal_handlers_unblock_by_func (action, auto_spell_cb, window); } } gtk_action_group_set_sensitive (data->action_group, (view != NULL) && gtk_text_view_get_editable (GTK_TEXT_VIEW (view))); }